a
    E
a&                     @   sX   d Z ddlmZ ddlmZmZmZmZ dddZee	ddd	Z
eee	d
ddZdS )z(Different utilities for the numpy brains    )extract_node)	AttributeImportNameNodeNGNc                 C   s   t | }|j|dS )N)context)r   Zinfer)srcnoder    r
   >lib/python3.9/site-packages/astroid/brain/brain_numpy_utils.pyinfer_numpy_member   s    r   )r	   returnc                 C   sJ   | j }dd | |d D }|D ]"}d|f|jv s>d|jv r" dS q"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r|qS r
   )
isinstancer   ).0xr
   r
   r   
<listcomp>!   s   z&_is_a_numpy_module.<locals>.<listcomp>   numpy)r   NTF)namelookupnames)r	   Zmodule_nicknameZpotential_import_targettargetr
   r
   r   _is_a_numpy_module   s    r   )member_namer	   r   c                 C   sZ   t |tr.|j| kr.t |jtr.t|jr.dS t |trV|j| krV| jdrVdS d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
    Tr   F)	r   r   attrnameexprr   r   r   root
startswith)r   r	   r
   r
   r   looks_like_numpy_member-   s"    

r   )N)__doc__Zastroid.builderr   Zastroid.node_classesr   r   r   r   r   boolr   strr   r
   r
   r
   r   <module>
   s
   
