
    e	                    v    d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
 dZddZddZddd
ZddZddZddZy	)z)Different utilities for the numpy brains.    )annotations)extract_node)InferenceContext)	AttributeImportName)1200c                 0    t               } | xr	 | t        kD  S )z*Returns True if numpy supports type hints.)_get_numpy_version NUMPY_VERSION_TYPE_HINTS_SUPPORT)np_vers    A/usr/lib/python3/dist-packages/astroid/brain/brain_numpy_utils.pynumpy_supports_type_hintsr      s    !F?f???    c                     	 ddl } t        | j                  j                  j                  d            S # t        t
        f$ r Y yw xY w)zj
    Return the numpy version number if numpy can be imported.

    Otherwise returns ('0', '0', '0')
    r   N.)r   r   r   )numpytupleversionsplitImportErrorAttributeError)r   s    r   r   r      sA    U]]**00566( s   14 AANc                <    t        |       }|j                  |      S )N)context)r   infer)srcnoder   s      r   infer_numpy_memberr    %   s    D::g:&&r   c                    | j                   | j                        d   D cg c]  }t        |t              s| }}t	        fd|D              S c c}w )a>  
    Returns True if the node is a representation of a numpy module.

    For example in :
        import numpy as np
        x = np.linspace(1, 2)
    The node <Name.np> is a representation of the numpy module.

    :param node: node to test
    :return: True if the node is a representation of the numpy module.
       c              3  ^   K   | ]$  }d f|j                   v xs d|j                   v  & yw)r   )r   NN)names).0targetmodule_nicknames     r   	<genexpr>z%_is_a_numpy_module.<locals>.<genexpr>:   s8       
/"fll2Uo6UUs   *-)namelookup
isinstancer   any)r   xpotential_import_targetr'   s      @r   _is_a_numpy_moduler/   *   sa     iiO;;/2jF6K   -  s
   AAc                v    |j                   | k(  xr) |j                         j                   j                  d      S )zV
    Returns True if the Name is a member of numpy whose
    name is member_name.
    r   )r)   root
startswithmember_namer   s     r   name_looks_like_numpy_memberr5   @   s/    
 99#L		(8(8(C(CG(LLr   c                    |j                   | k(  xr1 t        |j                  t              xr t	        |j                        S )z[
    Returns True if the Attribute is a member of numpy whose
    name is member_name.
    )attrnamer+   exprr   r/   r3   s     r   !attribute_looks_like_numpy_memberr9   H   s9     	$ 	*tyy$'	*tyy)r   )returnbool)r:   ztuple[str, str, str])N)r   zInferenceContext | None)r   r   r:   r;   )r4   strr   r   r:   r;   )r4   r<   r   r   r:   r;   )__doc__
__future__r   astroid.builderr   astroid.contextr   astroid.nodes.node_classesr   r   r   r   r   r   r    r/   r5   r9    r   r   <module>rC      sA   
 0 " ( , > > $4  @'
,M	r   