Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/numpy/lib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/numpy/lib/__pycache__/utils.cpython-35.pyc



(��^��@s ddlmZmZmZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZmZmZddlZddlmZmZdddd	d
ddd
ddddgZdd�Zdd�ZGdd�de�Zdd	�Zdd�Zdd�Zddd�Zdd�Zda da!ddd �Z"ej#d!d"�Z$dd#ej#dd$d�Z%ej#d%d
�Z&ia'ej(d&ej)�Z*dd'd(dd)d�Z+d*d+�Z,d,d-�Z-Gd.d/�d/e�Z.d0d�Z/d1d2�Z0dS)3�)�division�absolute_import�print_functionN)�issubclass_�issubsctype�
issubdtype)�ndarray�ufunc�asarray)�
getargspec�
formatargspecrrr�	deprecate�deprecate_with_doc�get_include�info�source�who�lookfor�byte_bounds�	safe_evalcCs|ddl}|jdkrEtjjtjj|j�dd�}n3ddlj}tjjtjj|j�d�}|S)a�
    Return the directory that contains the NumPy \*.h header files.

    Extension modules that need to compile against NumPy should use this
    function to locate the appropriate include directory.

    Notes
    -----
    When using ``distutils``, for example in ``setup.py``.
    ::

        import numpy as np
        ...
        Extension('extension_name', ...
                include_dirs=[np.get_include()])
        ...

    rN�core�include)	�numpyZshow_config�os�path�join�dirname�__file__�
numpy.corer)r�dr�r �B/opt/alt/python35/lib64/python3.5/site-packages/numpy/lib/utils.pyrs*$cCs
||_|S)N)�__name__)�func�namer r r!�_set_function_name4s	r%c@s7eZdZdZddddd�Zdd�ZdS)�
_Deprecatez�
    Decorator class to deprecate old functions.

    Refer to `deprecate` for details.

    See Also
    --------
    deprecate

    NcCs||_||_||_dS)N)�old_name�new_name�message)�selfr'r(r)r r r!�__init__Es		z_Deprecate.__init__c
s:|j}|j}|j}ddl�|dkr^y
�j}Wntk
r]�j}YnX|dkrwd|�nd||f�|dk	r��d|7����fdd�}t||�}�j}|dkr��}ndj�|g�}||_y
�j	}	Wntk
r%YnX|j	j
|	�|S)	z:
        Decorator call.  Refer to ``decorate``.

        rNz`%s` is deprecated!z%`%s` is deprecated, use `%s` instead!�
cs#�j�tdd��||�S)z1`arrayrange` is deprecated, use `arange` instead!�
stacklevel�)�warn�DeprecationWarning)�args�kwds)�depdocr#�warningsr r!�newfuncbsz$_Deprecate.__call__.<locals>.newfuncz

)r'r(r)r4r"�AttributeErrorr%�__doc__r�__dict__�update)
r*r#r1�kwargsr'r(r)r5�docrr )r3r#r4r!�__call__Js8			



			

z_Deprecate.__call__)r"�
__module__�__qualname__r7r+r<r r r r!r&9s
r&cOs�|rq|d}|dd�}d|kr?|jd�|d<d|kr^|jd�|d<t||�|�St||�SdS)a
    Issues a DeprecationWarning, adds warning to `old_name`'s
    docstring, rebinds ``old_name.__name__`` and returns the new
    function object.

    This function may also be used as a decorator.

    Parameters
    ----------
    func : function
        The function to be deprecated.
    old_name : str, optional
        The name of the function to be deprecated. Default is None, in
        which case the name of `func` is used.
    new_name : str, optional
        The new name for the function. Default is None, in which case the
        deprecation message is that `old_name` is deprecated. If given, the
        deprecation message is that `old_name` is deprecated and `new_name`
        should be used instead.
    message : str, optional
        Additional explanation of the deprecation.  Displayed in the
        docstring after the warning.

    Returns
    -------
    old_func : function
        The deprecated function.

    Examples
    --------
    Note that ``olduint`` returns a value after printing Deprecation
    Warning:

    >>> olduint = np.deprecate(np.uint)
    >>> olduint(6)
    /usr/lib/python2.5/site-packages/numpy/lib/utils.py:114:
    DeprecationWarning: uint32 is deprecated
      warnings.warn(str1, DeprecationWarning, stacklevel=2)
    6

    r�NZnewnamer(�oldnamer')�popr&)r1r:�fnr r r!r
vs.
cCs
td|�S)Nr))r&)�msgr r r!�<lambda>�srDc
Cs�|j}|dd}|d}|d}t|�jj}|}}|dkrg||j|7}n]xPt||�D]?\}}	|	dkr�||d|	7}qw||d|	7}qwW||7}||fS)a1
    Returns pointers to the end-points of an array.

    Parameters
    ----------
    a : ndarray
        Input array. It must conform to the Python-side of the array
        interface.

    Returns
    -------
    (low, high) : tuple of 2 integers
        The first integer is the first byte of the array, the second
        integer is just past the last byte of the array.  If `a` is not
        contiguous it will not use every byte between the (`low`, `high`)
        values.

    Examples
    --------
    >>> I = np.eye(2, dtype='f'); I.dtype
    dtype('float32')
    >>> low, high = np.byte_bounds(I)
    >>> high - low == I.size*I.itemsize
    True
    >>> I = np.eye(2, dtype='G'); I.dtype
    dtype('complex192')
    >>> low, high = np.byte_bounds(I)
    >>> high - low == I.size*I.itemsize
    True

    �datar�strides�shapeNr?)Z__array_interface__r
�dtype�itemsize�size�zip)
�a�aiZa_dataZastridesZashapeZbytes_aZa_lowZa_highrGZstrider r r!r�s 	



c
Cs�|dkr$tj�j}|j}g}i}x�|j�D]�}t||t�r=||}t|�}||j�kr�|d||}d}n|||<|}d}djt	t
|j��}	t
|j�}
|j
||	|
|jj|g�q=Wd}d}d}
d}x�tt|��D]�}||}|t|d�kr`t|d�}|t|d�kr�t|d�}|
t|d�kr�t|d�}
|dr*|t|d�7}q*Wt|�dkrPtd|�}td|�}td|
�}d	|d
|d
|d
f}t|ddt|�d
d�x�tt|��D]�}||}td|dd
|t|d�d|dd
|t|d�d
|dd
|t|d�d
|df�qcWtd|�dS)a%
    Print the NumPy arrays in the given dictionary.

    If there is no dictionary passed in or `vardict` is None then returns
    NumPy arrays in the globals() dictionary (all NumPy arrays in the
    namespace).

    Parameters
    ----------
    vardict : dict, optional
        A dictionary possibly containing ndarrays.  Default is globals().

    Returns
    -------
    out : None
        Returns 'None'.

    Notes
    -----
    Prints out the name, shape, bytes and type of all of the ndarrays
    present in `vardict`.

    Examples
    --------
    >>> a = np.arange(10)
    >>> b = np.ones(20)
    >>> np.who()
    Name            Shape            Bytes            Type
    ===========================================================
    a               10               40               int32
    b               20               160              float64
    Upper bound on total bytes  =       200

    >>> d = {'x': np.arange(2.0), 'y': np.arange(3.0), 'txt': 'Some str',
    ... 'idx':5}
    >>> np.who(d)
    Name            Shape            Bytes            Type
    ===========================================================
    y               3                24               float64
    x               2                16               float64
    Upper bound on total bytes  =       40

    Nz (%s)rr?z x r.��
zName %s Shape %s Bytes %s Type� r,�=�z%s %s %s %s %s %s %s�z'
Upper bound on total bytes  =       %d)�sys�	_getframe�f_back�	f_globals�keys�
isinstancer�idr�map�strrG�nbytes�appendrHr$�range�len�int�max�print)�vardict�frameZsta�cacher$�varZidv�namestr�originalZshapestrZbytestrZmaxnameZmaxshapeZmaxbyteZ
totalbytes�k�valZsp1Zsp2Zsp3Zprvalr r r!r�s^,	
	


$
&  c
Cs�t|�}|}|}d}|j|�}x�|D]�}||krOd}	n|}	|t|�t|	�}||kr�|dt|�}|dd|d|}q4||	|}q4W|S)Nz, �r?z,
rPr.)r`�split)
r$�	arguments�widthZ
firstwidthrj�newstrZsepstr�arglist�argumentZaddstrr r r!�_split_line\s
	rsrcCs�t|t�t�g�}|j|ji}|jg}|jg}x�t|�dkr[P|jd�}xt|j�D]f}t||t	j
�rw||j}||krw||j}|j|�|j|�|||<qwWqHW||fS)Nr)�
__import__�globals�localsr"r8r`rArXrY�types�
ModuleTyper^)�module�thedictZdictlistZ
totraverseZthisdict�x�modnameZmoddictr r r!�
_makenamedictts"



r}c
Cs	d}d}dd�}t|dt|��}t|d|�}|j}|jj}td|d|�td|jd|�td	|d|�td
|jd|�td||jj	�d|�td||jj
�d|�td
|jjd|�tdt|j
jj�|fd|�tdddd|�|dkrttd|tj|fd|�d}	na|dkr�td||fd|�tjdk}	n)td||fd|�tjdk}	td||	�d|�td|jd|�dS)aOProvide information about ndarray obj.

    Parameters
    ----------
    obj : ndarray
        Must be ndarray, not checked.
    output
        Where printed output goes.

    Notes
    -----
    Copied over from the numarray module prior to its removal.
    Adapted somewhat as only numpy is an option now.

    Called by info.

    rlcSs|S)Nr )r{r r r!rD�sz_info.<locals>.<lambda>�	__class__r"zclass: �filezshape: z	strides: z
itemsize: z	aligned: zcontiguous: z	fortran: zdata pointer: %s%szbyteorder: �endrP�|rQz%s%s%sF�>z%sbig%s�bigz
%slittle%s�littlez
byteswap: ztype: %sN)r�rQ)�getattr�typerFrH�	byteorderrcrGrI�flagsZaligned�
contiguousZfortran�hex�ctypesZ_as_parameter_�valuerT)
�obj�output�extraZticZbp�cls�nmrFZendian�byteswapr r r!�_info�s8	 	r��LcCs
ddl}ddl}t|d�s6t|d�rB|j}nt|d�rZ|j}|dkrstt�n�t|t�r�t|d|�nqt|t	�r�t
dkr�t|�\a
ad}g}x�tD]�}y�t
||}	t
|	�|krtd|d|�nE|jt
|	��td	|d|�t|	�td
|d|�|d7}Wq�tk
ryYq�Xq�W|dkr�td|d|�qtd
|d|�nN|j|�rK|j}
tt|��}t|
|�|kr
t|
||�}n
|
|}td|dd|�t|j|�d|�n�|j|�rH|j}
d}ywt|d�r�tt|jj��}|jd�}
t|
�dkr�d|
d|
d<dj|
dd��}WnYnXt|
|�|krt|
||�}n
|
|}td|dd|�|j|�}|dkr�t|d�r�t|j|j�d|�nt|j|�d|�|j|�}|gkrtdd|�x>|D]u}|ddkr�q�t||d�}|dk	r'|j|j|�pd�\}}td||fd|�q�Wn�t j!ddkr�t|t"j#�r�td|j$jd|�td|�t|d�r�tt|j%j��}|jd�}
t|
�dkr	d|
d|
d<dj|
dd��}nd}t|d�r.d|j&}
nd}
t|
|�|kr_t|
||�}n
|
|}td|dd|�|j|j%�}|dk	r�t|j|j%�d|�t|j|�d|�qt|j|�d|�n|j'|�r�|j}
tt|j��}|jd�}
t|
�dkrod|
d|
d<dj|
dd��}nd}t|
|�|kr�t|
||�}n
|
|}td|dd|�t|j|�d|�n(t|d�rt|j|�d|�dS)a�
    Get help information for a function, class, or module.

    Parameters
    ----------
    object : object or str, optional
        Input object or name to get information about. If `object` is a
        numpy object, its docstring is given. If it is a string, available
        modules are searched for matching objects.  If None, information
        about `info` itself is returned.
    maxwidth : int, optional
        Printing width.
    output : file like object, optional
        File like object that the output is written to, default is
        ``stdout``.  The object has to be opened in 'w' or 'a' mode.
    toplevel : str, optional
        Start search at this level.

    See Also
    --------
    source, lookfor

    Notes
    -----
    When used interactively with an object, ``np.info(obj)`` is equivalent
    to ``help(obj)`` on the Python prompt or ``obj?`` on the IPython
    prompt.

    Examples
    --------
    >>> np.info(np.polyval) # doctest: +SKIP
       polyval(p, x)
         Evaluate the polynomial p at x.
         ...

    When using a string for `object` it is possible to get multiple results.

    >>> np.info('fft') # doctest: +SKIP
         *** Found in numpy ***
    Core FFT routines
    ...
         *** Found in numpy.fft ***
     fft(a, n=None, axis=-1)
    ...
         *** Repeat reference found in numpy.fft.fftpack ***
         *** Total of 3 references found. ***

    rNZ_ppimport_importer�_ppimport_module�_ppimport_attrr�z+
     *** Repeat reference found in %s *** rz     *** Found in %s ***�-r?zHelp for %s not found.z+
     *** Total of %d references found. ***rPr,z()r+z, �(z

Methods:
�_�Nonez  %s  --  %srSzInstance of class: r<r$z%sz<name>r7)(�pydoc�inspect�hasattrr�r�rrYrr�r\�	_namedictr}�	_dictlistrZrcr^�KeyError�
isfunctionr"rrr`rs�getdoc�isclassr+�__func__rmrZ
allmethodsr�ZsplitdocrT�version_inforwZInstanceTyper~r<r$�ismethod)�objectZmaxwidthr�Ztoplevelr�r�ZnumfoundZobjlistrhr�r$rn�argstrrqZdoc1�methods�methZthisobjZmethstr�otherr;r r r!r�s�3	




	
	
	

!

	
c
Cseddl}y:td|j|�d|�t|j|�d|�Wntdd|�YnXdS)a�
    Print or write to a file the source code for a NumPy object.

    The source code is only returned for objects written in Python. Many
    functions and classes are defined in C and will therefore not return
    useful information.

    Parameters
    ----------
    object : numpy object
        Input object. This can be any object (function, class, module,
        ...).
    output : file object, optional
        If `output` not supplied then source code is printed to screen
        (sys.stdout).  File object must be created with either write 'w' or
        append 'a' modes.

    See Also
    --------
    lookfor, info

    Examples
    --------
    >>> np.source(np.interp)                        #doctest: +SKIP
    In file: /usr/lib/python2.6/dist-packages/numpy/lib/function_base.py
    def interp(x, xp, fp, left=None, right=None):
        """.... (full docstring printed)"""
        if isinstance(x, (float, int, number)):
            return compiled_interp([x], xp, fp, left, right).item()
        else:
            return compiled_interp(x, xp, fp, left, right)

    The source code is only returned for objects written in Python.

    >>> np.source(np.array)                         #doctest: +SKIP
    Not available for this object.

    rNzIn file: %s
rzNot available for this object.)r�rc�
getsourcefile�	getsource)r�r�r�r r r!r�s(z[a-z0-9_]+\(.*[,=].*\)TFc
s�ddl}t|||��g}t|�j�j���sFdSx{�j�D]m\}\}}	}
|	dkrwqSd}|j�}x!�D]}
|
|kr�d}Pq�W|rS|j|�qSWddd	dddddi���fd
d����fdd
�}|jd|�ddj��}|dt	|�g}x�|ddd�D]�}�|\}}	}dd�|j
�jd�D�}y3|dj
�}tj|�r�|dj
�}Wnt
k
r�d}YnX|jd||f�qYW|s|jd�|dk	r5|jdj|��nGt	|�dkri|j�}|dj|��ntdj|��dS)a�
    Do a keyword search on docstrings.

    A list of of objects that matched the search is displayed,
    sorted by relevance. All given keywords need to be found in the
    docstring for it to be returned as a result, but the order does
    not matter.

    Parameters
    ----------
    what : str
        String containing words to look for.
    module : str or list, optional
        Name of module(s) whose docstrings to go through.
    import_modules : bool, optional
        Whether to import sub-modules in packages. Default is True.
    regenerate : bool, optional
        Whether to re-generate the docstring cache. Default is False.
    output : file-like, optional
        File-like object to write the output to. If omitted, use a pager.

    See Also
    --------
    source, info

    Notes
    -----
    Relevance is determined only roughly, by checking if the keywords occur
    in the function name, at the start of a docstring, etc.

    Examples
    --------
    >>> np.lookfor('binary representation')
    Search results for 'binary representation'
    ------------------------------------------
    numpy.binary_repr
        Return the binary representation of the input number as a string.
    numpy.core.setup_common.long_double_representation
        Given a binary dump as given by GNU od -b, look for long double
    numpy.base_repr
        Return a string representation of a number in the given base system.
    ...

    rNryr�TFr#i��classcs�d}dj|j�j�jd�dd���|t�fdd��D��7}|t�fdd��D��7}|t��d7}|�j|d�7}|�jd	�d
7}|t|dd
�7}|S)Nrr,rScs"g|]}|�krd�qS)��r )�.0�w)�	first_docr r!�
<listcomp>s	z.lookfor.<locals>.relevance.<locals>.<listcomp>cs"g|]}|�krd�qS)�r )r�r�)r$r r!r�s	rRi��.rO�di���i����)	r�lower�striprm�sumr`�get�countrb)r$Zdocstr�kind�index�r)�kind_relevance�whats)r�r$r!�	relevances.##zlookfor.<locals>.relevancecs�|�|�S)Nr )rL)rfr�r r!�relevance_valuesz lookfor.<locals>.relevance_value�keyzSearch results for '%s'rPr�r?cSs(g|]}|j�r|j��qSr )r�)r��liner r r!r�)s	zlookfor.<locals>.<listcomp>r,rlz	%s
    %szNothing found.rO)ryr�i���i������)r��_lookfor_generate_cacher\r�rm�itemsr^�sortrr`r��_function_signature_re�search�
IndexError�writeZgetpagerrc)�whatry�import_modules�
regenerater�r��foundr$�	docstringr�r��okr;r�r��s�	help_textZixZdoclinesr�Zpagerr )rfr�r�r�r!r�sT."
"

c#Cs�ddl}tjddkr2ddlm}nddlm}|dkrTd}t|t�r�yt|�Wntk
r�iSYnXtj	|}nRt|t
�s�t|t�r�i}x'|D]}|jt
|||��q�W|St|�tkr|rtt|�Si}|tt|�<i}d}|j|fg}	x�|	r�|	jd�\}
}t|�|krzqJd|t|�<|d7}d}|j|�r-d	}y
|j}
Wntk
r�d}
YnX|rt|d
�rx-|jD]"}xtj|�D]}tjj||�}tjj||d�}tjj|�rs|jd�rs|dd�}ntjj|�r|}nq|d
kr�qy\tj}tj}z0|�t_|�t_td|
|f�Wd|t_|t_XWqtk
rwYqXqWq�Wxut |�D]�\}}y2t!|dd|
|f�}t!|dd�}Wn(t"k
r�d|
|f}d}YnXd|kr�|r�d||f}|j#|
d�s�t|t$�r)q	q)n*|j|�p|
dkp||
ks	q)|	j%d|
|f|f�q)Wng|j&|�rd}xOt |�D])\}}|	j%d|
|f|f�qOWnt|d�r�d}y|j'|�}Wnt"k
r�d}YnX|dk	rJ|||f||
<qJW|S)a�
    Generate docstring cache for given module.

    Parameters
    ----------
    module : str, None, module
        Module for which to generate docstring cache
    import_modules : bool
        Whether to import sub-modules in packages.
    regenerate : bool
        Re-generate the docstring cache

    Returns
    -------
    cache : dict {obj_full_name: (docstring, kind, index), ...}
        Docstring cache for the module, either cached one (regenerate=False)
        or newly generated.

    rNrS)�StringIOrTr?r�ry�__path__z__init__.pyz.pyr+z%s.%sr"r=r�r�r<r#���)(r�rTr��ior�rYr\rt�ImportError�modules�list�tupler9r�rZ�_lookfor_cachesr"rA�ismodule�__all__r6r�r�r�listdirrr�isfile�endswith�stdout�stderr�
BaseException�_getmembersr��	NameError�
startswithr	r^r�r�)ryr�r�r�r�rf�mod�seenr��stackr$�itemr�Z_all�pthZmod_pathZthis_py�init_pyZ	to_importZ
old_stdoutZ
old_stderr�n�vZ	item_name�mod_namer;r r r!r�As�
	
	


				

'$$
r�csWddl}y|j��}Wn1tk
rR�fdd�t��D�}YnX|S)Nrcs4g|]*}t�|�r|t�|�f�qSr )r�r�)r�r{)r�r r!r��s	z_getmembers.<locals>.<listcomp>)r��
getmembers�	Exception�dir)r�r��membersr )r�r!r��s
$r�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�SafeEvalz�
    Object to evaluate constant string expressions.

    This includes strings with lists, dicts and tuples using the abstract
    syntax tree created by ``compiler.parse``.

    .. deprecated:: 1.10.0

    See Also
    --------
    safe_eval

    cCstjdtdd�dS)Nz3SafeEval is deprecated in 1.10 and will be removed.r-r.)r4r/r0)r*r r r!r+�s	zSafeEval.__init__cCs/|j}t|d|j|j�}||�S)N�visit)r~r�r"�default)r*�noder�r�r r r!r��s	zSafeEval.visitcCstd|j��dS)Nz Unsupported source construct: %s)�SyntaxErrorr~)r*r�r r r!r��szSafeEval.defaultcCs|j|j�S)N)r��body)r*r�r r r!�visitExpressionszSafeEval.visitExpressioncCs|jS)N)r�)r*r�r r r!�visitNumszSafeEval.visitNumcCs|jS)N)r�)r*r�r r r!�visitStrszSafeEval.visitStrcCs|jS)N)r�)r*r�r r r!�
visitBytes
szSafeEval.visitBytescs,t�fdd�t|j|j�D��S)Ncs4g|]*\}}�j|��j|�f�qSr )r�)r�rjr�)r*r r!r�s	z&SafeEval.visitDict.<locals>.<listcomp>)�dictrKrX�values)r*r��kwr )r*r!�	visitDict
szSafeEval.visitDictcs t�fdd�|jD��S)Ncsg|]}�j|��qSr )r�)r��i)r*r r!r�s	z'SafeEval.visitTuple.<locals>.<listcomp>)r��elts)r*r�r )r*r!�
visitTupleszSafeEval.visitTuplecs�fdd�|jD�S)Ncsg|]}�j|��qSr )r�)r�r)r*r r!r�s	z&SafeEval.visitList.<locals>.<listcomp>)r)r*r�r )r*r!�	visitListszSafeEval.visitListcCsoddl}t|j|j�r2|j|j�
St|j|j�rX|j|j�Std|j��dS)NrzUnknown unary op: %r)�astrY�op�UAddr��operand�USubr�)r*r�rr r r!�visitUnaryOpszSafeEval.visitUnaryOpcCsP|jdkrdS|jdkr&dS|jdkr9dStd|j��dS)N�FalseF�TrueTr�zUnknown name: %s)rZr�)r*r�r r r!�	visitName szSafeEval.visitNamecCs|jS)N)r�)r*r�r r r!�visitNameConstant*szSafeEval.visitNameConstantN)r"r=r>r7r+r�r�r�r�r�r�rrrr
rrr r r r!r��s
	
r�cCsddl}|j|�S)a�
    Protected string evaluation.

    Evaluate a string containing a Python literal expression without
    allowing the execution of arbitrary non-literal code.

    Parameters
    ----------
    source : str
        The string to evaluate.

    Returns
    -------
    obj : object
       The result of evaluating `source`.

    Raises
    ------
    SyntaxError
        If the code has invalid Python syntax, or if it contains
        non-literal code.

    Examples
    --------
    >>> np.safe_eval('1')
    1
    >>> np.safe_eval('[1, 2, 3]')
    [1, 2, 3]
    >>> np.safe_eval('{"foo": ("bar", 10.0)}')
    {'foo': ('bar', 10.0)}

    >>> np.safe_eval('import os')
    Traceback (most recent call last):
      ...
    SyntaxError: invalid syntax

    >>> np.safe_eval('open("/home/user/.ssh/id_dsa").read()')
    Traceback (most recent call last):
      ...
    SyntaxError: Unsupported source construct: compiler.ast.CallFunc

    rN)r�literal_eval)rrr r r!r.s,cCs/|jdkr|Stj|||j�}tj|d
�}tjj|�r_|jd�}|jdkr�|dkr+tj	dt
dd�|d	k	r�|jjtj
�|d<|}q+|jjtj
�}nUtj|j��dkr+tj	d
dtj|j��t
dd�tj
||<|S)aj
    Utility function to check median result from data for NaN values at the end
    and return NaN in that case. Input result can also be a MaskedArray.

    Parameters
    ----------
    data : array
        Input data to median function
    result : Array or MaskedArray
        Result of median function
    axis : {int, sequence of int, None}, optional
        Axis or axes along which the median was computed.
    out : ndarray, optional
        Output array in which to place the result.
    Returns
    -------
    median : scalar or ndarray
        Median or NaN in axes which contained NaN in the input.
    r.r?FTz#Invalid value encountered in medianr-rSNz'Invalid value encountered in median forz %d resultsr�).r�)rJ�npZrollaxis�ndim�isnan�maZ
isMaskedArrayZfilledr4r/�RuntimeWarningrHr��nanZ
count_nonzeroZravel)rE�resultZaxis�outr�r r r!�_median_nancheck_s(	
		

r)1�
__future__rrrrrTrw�rer4Znumpy.core.numerictypesrrrrrr	r
rr�numpy.compatrrr�rr%r�r&r
rrrrsr�r�r}r�r�rrr��compile�Ir�rr�r�r�rrr r r r!�<module>sF==9i3�3	�I1