3
tûœ]V  ã               @   sD   d Z ddlZddd„Zejjedœdd„Zeejjedœd	d
„Z	dS )z(Different utilities for the numpy brainsé    Nc             C   s   t j| ƒ}|j|d�S )N)Úcontext)ÚastroidZextract_nodeZinfer)ÚsrcÚnoder   © r   úB/tmp/pip-build-fn42xldr/astroid/astroid/brain/brain_numpy_utils.pyÚinfer_numpy_member   s    
r   )r   Úreturnc             C   sB   | j }dd„ | j|ƒd D ƒ}x|D ]}d|f|jkr$dS q$W dS )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             S   s   g | ]}t |tjƒr|‘qS r   )Ú
isinstancer   ÚImport)Ú.0Úxr   r   r   ú
<listcomp>    s    z&_is_a_numpy_module.<locals>.<listcomp>é   ÚnumpyTF)ÚnameÚlookupÚnames)r   Zmodule_nicknameZpotential_import_targetÚtargetr   r   r   Ú_is_a_numpy_module   s    
r   )Úmember_namer   r	   c             C   s.   t |tjƒo,|j| ko,t |jtjƒo,t|jƒS )zÓ
    Returns True if the node is a member of numpy whose
    name is member_name.

    :param member_name: name of the member
    :param node: node to test
    :return: True if the node is a member of numpy
    )r
   r   Ú	AttributeÚattrnameÚexprÚNamer   )r   r   r   r   r   Úlooks_like_numpy_member(   s    
r   )N)
Ú__doc__r   r   Znode_classesr   Úboolr   ÚstrZNodeNGr   r   r   r   r   Ú<module>   s
   
