403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.148.217.26
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib64/python3.7/site-packages/numpy/ma/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib64/python3.7/site-packages/numpy/ma/__pycache__/extras.cpython-37.pyc
B

��Fd���,@s�dZddlmZmZmZddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.g,Zdd/lZdd/lZd0d1lm	Z
d0d2l	mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z dd/l!Z"dd3l!m#Z#mZ$dd/l%m	m&Z&dd4l'm(Z(dd5l)m*Z*dd6l+m,Z,dd7l-m.Z.d8d9�Z/dsd:d�Z0e1fd;d!�Z2d<d"�Z3Gd=d>�d>�Z4Gd?d@�d@e4�Z5GdAdB�dBe4�Z6GdCdD�dDe4�Z7GdEdF�dFe4�Z8e8d�Z9e8d�Z:e8d�Z;e6d.�Z<Z=e6d�Z>e6d�Z?e6d�Z@e5d�ZAe5d�ZBdGdH�ZCdId�ZDe"jDjeD_dJd�ZEeEjd/k	�r\e"jEjd/e"jEj�FdK���G�dLeE_dtdNd�ZHdudOd#�ZIdvdPdQ�ZJdwdRd
�ZKdxdSd�ZLdTd�ZMdUd�ZNdydVd �ZOdzdWd�ZPd{dXd�ZQd|dYd+�ZRd}dZd�ZSd~d[d*�ZTdd\d�ZUd�d]d�ZVd^d,�ZWd�d_d)�ZXd�dadb�ZYd�dcd�ZZd/d`e"j[d`e"j[fddd�Z\Gdedf�dfe.�Z]Gdgdh�dhe]�Z^e^�Z_did�Z`d�djd&�Zadkd�Zbd�dld%�Zcdmdn�Zddod
�Zedpd	�Zfd�dqd-�Zge
�he"jgjegj�eg_d�drd'�Zie
�he"jijeij�ei_d/S)�z�
Masked arrays add-ons.

A collection of utilities for `numpy.ma`.

:author: Pierre Gerard-Marchant
:contact: pierregm_at_uga_dot_edu
:version: $Id: extras.py 3473 2007-10-29 15:18:13Z jarrod.millman $

�)�division�absolute_import�print_function�apply_along_axis�apply_over_axes�
atleast_1d�
atleast_2d�
atleast_3d�average�clump_masked�clump_unmasked�column_stack�
compress_cols�compress_nd�compress_rowcols�
compress_rows�count_masked�corrcoef�cov�diagflat�dot�dstack�ediff1d�flatnotmasked_contiguous�flatnotmasked_edges�hsplit�hstack�isin�in1d�intersect1d�	mask_cols�mask_rowcols�	mask_rows�
masked_all�masked_all_like�median�mr_�notmasked_contiguous�notmasked_edges�polyfit�	row_stack�	setdiff1d�setxor1d�unique�union1d�vander�vstackN�)�core)�MaskedArray�MAError�add�array�asarray�concatenate�filled�count�getmask�getmaskarray�make_mask_descr�masked�masked_array�mask_or�nomask�ones�sort�zeros�getdata�get_masked_subclassrr!)�ndarrayr6)�normalize_axis_index)�normalize_axis_tuple)�_ureduce)�AxisConcatenatorcCst|tttf�S)z6
    Is seq a sequence (ndarray, list or tuple)?

    )�
isinstancerG�tuple�list)�seq�rP�B/opt/alt/python37/lib64/python3.7/site-packages/numpy/ma/extras.py�
issequence-srRcCst|�}|�|�S)a�
    Count the number of masked elements along the given axis.

    Parameters
    ----------
    arr : array_like
        An array with (possibly) masked elements.
    axis : int, optional
        Axis along which to count. If None (default), a flattened
        version of the array is used.

    Returns
    -------
    count : int, ndarray
        The total number of masked elements (axis=None) or the number
        of masked elements along each slice of the given axis.

    See Also
    --------
    MaskedArray.count : Count non-masked elements.

    Examples
    --------
    >>> import numpy.ma as ma
    >>> a = np.arange(9).reshape((3,3))
    >>> a = ma.array(a)
    >>> a[1, 0] = ma.masked
    >>> a[1, 2] = ma.masked
    >>> a[2, 1] = ma.masked
    >>> a
    masked_array(data =
     [[0 1 2]
     [-- 4 --]
     [6 -- 8]],
          mask =
     [[False False False]
     [ True False  True]
     [False  True False]],
          fill_value=999999)
    >>> ma.count_masked(a)
    3

    When the `axis` keyword is used an array is returned.

    >>> ma.count_masked(a, axis=0)
    array([1, 1, 1])
    >>> ma.count_masked(a, axis=1)
    array([0, 2, 1])

    )r<�sum)�arr�axis�mrPrPrQr5s3cCs$tt�||�t�|t|��d�}|S)a�
    Empty masked array with all elements masked.

    Return an empty masked array of the given shape and dtype, where all the
    data are masked.

    Parameters
    ----------
    shape : tuple
        Shape of the required MaskedArray.
    dtype : dtype, optional
        Data type of the output.

    Returns
    -------
    a : MaskedArray
        A masked array with all data masked.

    See Also
    --------
    masked_all_like : Empty masked array modelled on an existing array.

    Examples
    --------
    >>> import numpy.ma as ma
    >>> ma.masked_all((3, 3))
    masked_array(data =
     [[-- -- --]
     [-- -- --]
     [-- -- --]],
          mask =
     [[ True  True  True]
     [ True  True  True]
     [ True  True  True]],
          fill_value=1e+20)

    The `dtype` parameter defines the underlying data type.

    >>> a = ma.masked_all((3, 3))
    >>> a.dtype
    dtype('float64')
    >>> a = ma.masked_all((3, 3), dtype=np.int32)
    >>> a.dtype
    dtype('int32')

    )�mask)r?�np�emptyrBr=)�shape�dtype�arPrPrQr#ls/cCs,t�|��t�}tj|jt|j�d�|_|S)az
    Empty masked array with the properties of an existing array.

    Return an empty masked array of the same shape and dtype as
    the array `arr`, where all the data are masked.

    Parameters
    ----------
    arr : ndarray
        An array describing the shape and dtype of the required MaskedArray.

    Returns
    -------
    a : MaskedArray
        A masked array with all data masked.

    Raises
    ------
    AttributeError
        If `arr` doesn't have a shape attribute (i.e. not an ndarray)

    See Also
    --------
    masked_all : Empty masked array with all elements masked.

    Examples
    --------
    >>> import numpy.ma as ma
    >>> arr = np.zeros((2, 3), dtype=np.float32)
    >>> arr
    array([[ 0.,  0.,  0.],
           [ 0.,  0.,  0.]], dtype=float32)
    >>> ma.masked_all_like(arr)
    masked_array(data =
     [[-- -- --]
     [-- -- --]],
          mask =
     [[ True  True  True]
     [ True  True  True]],
          fill_value=1e+20)

    The dtype of the masked array matches the dtype of `arr`.

    >>> arr.dtype
    dtype('float32')
    >>> ma.masked_all_like(arr).dtype
    dtype('float32')

    )r[)	rXZ
empty_like�viewr3rBrZr=r[�_mask)rTr\rPrPrQr$�s2c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_fromnxfunctionaV
    Defines a wrapper to adapt NumPy functions to masked arrays.


    An instance of `_fromnxfunction` can be called with the same parameters
    as the wrapped NumPy function. The docstring of `newfunc` is adapted from
    the wrapped function as well, see `getdoc`.

    This class should not be used directly. Instead, one of its extensions that
    provides support for a specific type of input should be used.

    Parameters
    ----------
    funcname : str
        The name of the function to be adapted. The function should be
        in the NumPy namespace (i.e. ``np.funcname``).

    cCs||_|��|_dS)N)�__name__�getdoc�__doc__)�self�funcnamerPrPrQ�__init__�sz_fromnxfunction.__init__cCsFtt|jd�}t|dd�}|rB|jt�|�}d}d�|||f�SdS)a 
        Retrieve the docstring and signature from the function.

        The ``__doc__`` attribute of the function is used as the docstring for
        the new masked array version of the function. A note on application
        of the function to the mask is appended.

        .. warning::
          If the function docstring already contained a Notes section, the
          new docstring will have two Notes sections instead of appending a note
          to the existing section.

        Parameters
        ----------
        None

        NrbzLNotes
-----
The function is applied to both the _data and the _mask, if any.�
)�getattrrXr`�maZget_object_signature�join)rcZnpfunc�doc�sigZlocdocrPrPrQra�sz_fromnxfunction.getdoccOsdS)NrP)rc�args�paramsrPrPrQ�__call__
sz_fromnxfunction.__call__N)r`�
__module__�__qualname__rbrerarnrPrPrPrQr_�sr_c@seZdZdZdd�ZdS)�_fromnxfunction_singlez�
    A version of `_fromnxfunction` that is called with a single array
    argument followed by auxiliary args that are passed verbatim for
    both the data and mask calls.
    cOs�tt|j�}t|t�rJ||��f|�|�}|t|�f|�|�}t||d�S|t�|�f|�|�}|t|�f|�|�}t||d�SdS)N)rW)	rgrXr`rLrGZ	__array__r<r?r7)rc�xrlrm�func�_d�_mrPrPrQrns
z_fromnxfunction_single.__call__N)r`rorprbrnrPrPrPrQrqsrqc@seZdZdZdd�ZdS)�_fromnxfunction_seqz�
    A version of `_fromnxfunction` that is called with a single sequence
    of arrays followed by auxiliary args that are passed verbatim for
    both the data and mask calls.
    cOsTtt|j�}|tdd�|D��f|�|�}|tdd�|D��f|�|�}t||d�S)NcSsg|]}t�|��qSrP)rXr7)�.0r\rPrPrQ�
<listcomp>+sz0_fromnxfunction_seq.__call__.<locals>.<listcomp>cSsg|]}t|��qSrP)r<)rwr\rPrPrQrx,s)rW)rgrXr`rMr?)rcrrrlrmrsrtrurPrPrQrn)sz_fromnxfunction_seq.__call__N)r`rorprbrnrPrPrPrQrv#srvc@seZdZdZdd�ZdS)�_fromnxfunction_argsa�
    A version of `_fromnxfunction` that is called with multiple array
    arguments. The first non-array-like input marks the beginning of the
    arguments that are passed verbatim for both the data and mask calls.
    Array arguments are processed independently and the results are
    returned in a list. If only one array is found, the return value is
    just the processed array instead of a list.
    c	Os�tt|j�}g}t|�}x,t|�dkrDt|d�rD|�|�d��qWg}xH|D]@}|t�|�f|�|�}|t	|�f|�|�}|�t
||d��qPWt|�dkr�|dS|S)Nr)rWr1)rgrXr`rN�lenrR�append�popr7r<r?)	rcrlrmrs�arrays�resrrrtrurPrPrQrn9s
z_fromnxfunction_args.__call__N)r`rorprbrnrPrPrPrQry0sryc@seZdZdZdd�ZdS)�_fromnxfunction_allargsa
    A version of `_fromnxfunction` that is called with multiple array
    arguments. Similar to `_fromnxfunction_args` except that all args
    are converted to arrays even if they are not so already. This makes
    it possible to process scalars as 1-D arrays. Only keyword arguments
    are passed through verbatim for the data and mask calls. Arrays
    arguments are processed independently and the results are returned
    in a list. If only one arg is present, the return value is just the
    processed array instead of a list.
    cOsjtt|j�}g}x@|D]8}|t�|�f|�}|t|�f|�}|�t||d��qWt|�dkrf|dS|S)N)rWr1r)rgrXr`r7r<r{r?rz)rcrlrmrsr~rrrtrurPrPrQrnTs
z _fromnxfunction_allargs.__call__N)r`rorprbrnrPrPrPrQrIs
rcCsJd}x@|t|�krDx&t||d�r8|||||d�<qW|d7}qW|S)zFlatten a sequence in place.r�__iter__r1)rz�hasattr)rO�krPrPrQ�flatten_inplaceqsr�cOs�t|ddd�}|j}t||�}dg|d}t�|d�}tt|��}|�|�tdd�||<t�	|j
��|�}	|�||�|�
�}
||t|���f|�|�}t�|�}|s�yt|�Wntk
r�d}YnXg}
|�r�|
�t�	|�j�t|	t�}||t|�<t�|	�}d}x�||k�r�|dd7<d}xJ|||	|k�r||d|k�r|||dd7<d||<|d8}�q4W|�||�||t|���f|�|�}||t|�<|
�t	|�j�|d7}�qW�nft|ddd�}|�
�}
tdd�g|j|
|<|
�||�t�|	�}|	}t|j
�}	|j
|	|<|
�t	|�j�t|	�}	t|	t�}||tt|
����<d}x�||k�r8|dd7<d}xJ||||k�r�|d|k�r�||dd7<d||<|d8}�q�W|�||�|
�||�||t|���f|�|�}||tt|
����<|
�t	|�j�|d7}�qjWt�t�	|
����}t|d	��sjtj	||d
�}nt	||d
�}t�|�|_|S)z0
    (This docstring should be overwritten)
    FT)�copy�subokrr1�ON���r^)r[)r6�ndimrHrXrDrN�range�remove�slicer7rZ�take�putr�rM�tolistZisscalarrz�	TypeErrorr{r[�object�productr��maxr�rhZdefault_fill_value�
fill_value)Zfunc1drUrTrl�kwargs�nd�ind�iZindlistZoutshape�jr~ZasscalarZdtypesZoutarrZNtotr��nZ	holdshapeZ
max_dtypes�resultrPrPrQr{s�





"



"cCs�t|�}|j}t|�jdkr"|f}xd|D]\}|dkr<||}||f}||�}|j|jkr^|}q(t�||�}|j|jkr||}q(td��q(W|S)z.
    (This docstring will be overwritten)
    rz7function is not returning an array of the correct shape)r7r�r6rhZexpand_dims�
ValueError)rsr\�axes�val�NrUrlr~rPrPrQr�s 
ZNotesa�

    Examples
    --------
    >>> a = ma.arange(24).reshape(2,3,4)
    >>> a[:,0,1] = ma.masked
    >>> a[:,1,:] = ma.masked
    >>> print(a)
    [[[0 -- 2 3]
      [-- -- -- --]
      [8 9 10 11]]

     [[12 -- 14 15]
      [-- -- -- --]
      [20 21 22 23]]]
    >>> print(ma.apply_over_axes(ma.sum, a, [0,2]))
    [[[46]
      [--]
      [124]]]

    Tuple axis arguments to ufuncs are equivalent:

    >>> print(ma.sum(a, axis=(0,2)).reshape((1,-1,1)))
    [[[46]
      [--]
      [124]]]
    Fc	Cs`t|�}t|�}|dkr6|�|�}|j�|�|��}n�t�|�}t|jjtj	tj
f�rjt�|j|jd�}nt�|j|j�}|j|jkr�|dkr�t
d��|jdkr�t
d��|jd|j|kr�td��t�||jdd|j�}|�d	|�}|tk	�r||j}|j||d
�}tj|||d��|�|}|�rX|j|jk�rPt�||j���}||fS|SdS)as
    Return the weighted average of array over the given axis.

    Parameters
    ----------
    a : array_like
        Data to be averaged.
        Masked entries are not taken into account in the computation.
    axis : int, optional
        Axis along which to average `a`. If `None`, averaging is done over
        the flattened array.
    weights : array_like, optional
        The importance that each element has in the computation of the average.
        The weights array can either be 1-D (in which case its length must be
        the size of `a` along the given axis) or of the same shape as `a`.
        If ``weights=None``, then all data in `a` are assumed to have a
        weight equal to one.   If `weights` is complex, the imaginary parts
        are ignored.
    returned : bool, optional
        Flag indicating whether a tuple ``(result, sum of weights)``
        should be returned as output (True), or just the result (False).
        Default is False.

    Returns
    -------
    average, [sum_of_weights] : (tuple of) scalar or MaskedArray
        The average along the specified axis. When returned is `True`,
        return a tuple with the average as the first element and the sum
        of the weights as the second element. The return type is `np.float64`
        if `a` is of integer type and floats smaller than `float64`, or the
        input data-type, otherwise. If returned, `sum_of_weights` is always
        `float64`.

    Examples
    --------
    >>> a = np.ma.array([1., 2., 3., 4.], mask=[False, False, True, True])
    >>> np.ma.average(a, weights=[3, 1, 0, 0])
    1.25

    >>> x = np.ma.arange(6.).reshape(3, 2)
    >>> print(x)
    [[ 0.  1.]
     [ 2.  3.]
     [ 4.  5.]]
    >>> avg, sumweights = np.ma.average(x, axis=0, weights=[1, 2, 3],
    ...                                 returned=True)
    >>> print(avg)
    [2.66666666667 3.66666666667]

    NZf8z;Axis must be specified when shapes of a and weights differ.r1z81D weights expected when shapes of a and weights differ.rz5Length of weights not compatible with specified axis.)r1r�)rUr[)r[)r7r;�meanr[�typer:rX�
asanyarray�
issubclass�integerZbool_Zresult_typerZr�r�r�Zbroadcast_toZswapaxesrArWrS�multiplyr�)	r\rU�weightsZreturnedrV�avgZsclZwgtZresult_dtyperPrPrQr
s<3



cCsxt|d�sLtjt|dd�||||d�}t|tj�rHd|jkrHt|dd�S|St|t	|||d�\}}|rp|�
|�S|Sd	S)
a:	
    Compute the median along the specified axis.

    Returns the median of the array elements.

    Parameters
    ----------
    a : array_like
        Input array or object that can be converted to an array.
    axis : int, optional
        Axis along which the medians are computed. The default (None) is
        to compute the median along a flattened version of the array.
    out : ndarray, optional
        Alternative output array in which to place the result. It must
        have the same shape and buffer length as the expected output
        but the type will be cast if necessary.
    overwrite_input : bool, optional
        If True, then allow use of memory of input array (a) for
        calculations. The input array will be modified by the call to
        median. This will save memory when you do not need to preserve
        the contents of the input array. Treat the input as undefined,
        but it will probably be fully or partially sorted. Default is
        False. Note that, if `overwrite_input` is True, and the input
        is not already an `ndarray`, an error will be raised.
    keepdims : bool, optional
        If this is set to True, the axes which are reduced are left
        in the result as dimensions with size one. With this option,
        the result will broadcast correctly against the input array.

        .. versionadded:: 1.10.0

    Returns
    -------
    median : ndarray
        A new array holding the result is returned unless out is
        specified, in which case a reference to out is returned.
        Return data-type is `float64` for integers and floats smaller than
        `float64`, or the input data-type, otherwise.

    See Also
    --------
    mean

    Notes
    -----
    Given a vector ``V`` with ``N`` non masked values, the median of ``V``
    is the middle value of a sorted copy of ``V`` (``Vs``) - i.e.
    ``Vs[(N-1)/2]``, when ``N`` is odd, or ``{Vs[N/2 - 1] + Vs[N/2]}/2``
    when ``N`` is even.

    Examples
    --------
    >>> x = np.ma.array(np.arange(8), mask=[0]*4 + [1]*4)
    >>> np.ma.median(x)
    1.5

    >>> x = np.ma.array(np.arange(10).reshape(2, 5), mask=[0]*6 + [1]*4)
    >>> np.ma.median(x)
    2.5
    >>> np.ma.median(x, axis=-1, overwrite_input=True)
    masked_array(data = [ 2.  5.],
                 mask = False,
           fill_value = 1e+20)

    rWT)r�)rU�out�overwrite_input�keepdimsr1F)r�)rsrUr�r�N)r�rXr%rErLrGr�r?rJ�_median�reshape)r\rUr�r�r�rV�rr�rPrPrQr%isB


cs�t�|jtj�rtj}nd}|rR�dkr>|����j|d�q`|j�|d�|�nt|�|d���dkrnd�nt��j���j	�dkr�t
d�g�j}t
dd�|�<tjj�|�|d�S�jdk�r�t
��}tt
��d�\}}�||d|d�}	t��jtj��rR�jdk�rR|	j|d�}
|�s<tj|
dd	|d
�}
tjj��|
�|�}
n|	j|d�}
tj�|
��r�t��j��s�tj���S|
St
��d�}|d}�fdd
�t�j	�D�}tj|ddd��}
|
��|d��t|
�}t�|�j	�d�|
�<�t|
�}��fdd�}||�||�|ddk}tj|||d�ytj|j|j|d�WnYnXt��jtj��r�tjj||gd|d�}
tj|
jdd|
jd
�tjj��|
�|�}
ntjj||gd|d�}
|
S)N)r�)rUr�r)rUr�r1�)r�g@�safe)Zcastingr�)rUcs"g|]\}}|�krt�|��qSrP)rXZarange)rwr�rr)rUrPrQrx�sz_median.<locals>.<listcomp>TZij)�sparseZindexingcsDtj�|�r@tj�j�d�|j@}tj���|j|<d|j|<dS)N)rUF)rXrh�	is_masked�allrW�minimum_fill_value�data)�s�rep)�asortedrUrPrQ�replace_masked�sz_median.<locals>.replace_masked)�whereZunsafe) rXZ
issubdtyper[�inexact�inf�ravelrCrHr�rZr�rhr�r:�divmod�sizerS�true_divide�lib�utilsZ_median_nancheckr�r�rWr��	enumerateZmeshgrid�insertrM�minimumZcopytor�)r\rUr�r�r�Zindexer�counts�idxZodd�midr��hZ	axes_gridr��low�highr�rP)r�rUrQr��sj
r�cCs�t|�}t|�}|dkr(tt|j��}nt||j�}|tksD|��sJ|jS|�	�rZt
g�S|j}xR|D]J}ttt|��tt|d|j���}|td�f||j|d�f}qfW|S)a�Suppress slices from multiple dimensions which contain masked values.

    Parameters
    ----------
    x : array_like, MaskedArray
        The array to operate on. If not a MaskedArray instance (or if no array
        elements are masked, `x` is interpreted as a MaskedArray with `mask`
        set to `nomask`.
    axis : tuple of ints or int, optional
        Which dimensions to suppress slices from can be configured with this
        parameter.
        - If axis is a tuple of ints, those are the axes to suppress slices from.
        - If axis is an int, then that is the only axis to suppress slices from.
        - If axis is None, all axis are selected.

    Returns
    -------
    compress_array : ndarray
        The compressed array.
    Nr1)rU)
r7r;rMr�r�rIrA�any�_datar��nxarrayrNr�)rrrUrVr�Zaxr�rPrPrQrs
$&cCs"t|�jdkrtd��t||d�S)a�
    Suppress the rows and/or columns of a 2-D array that contain
    masked values.

    The suppression behavior is selected with the `axis` parameter.

    - If axis is None, both rows and columns are suppressed.
    - If axis is 0, only rows are suppressed.
    - If axis is 1 or -1, only columns are suppressed.

    Parameters
    ----------
    x : array_like, MaskedArray
        The array to operate on.  If not a MaskedArray instance (or if no array
        elements are masked), `x` is interpreted as a MaskedArray with
        `mask` set to `nomask`. Must be a 2D array.
    axis : int, optional
        Axis along which to perform the operation. Default is None.

    Returns
    -------
    compressed_array : ndarray
        The compressed array.

    Examples
    --------
    >>> x = np.ma.array(np.arange(9).reshape(3, 3), mask=[[1, 0, 0],
    ...                                                   [1, 0, 0],
    ...                                                   [0, 0, 0]])
    >>> x
    masked_array(data =
     [[-- 1 2]
     [-- 4 5]
     [6 7 8]],
                 mask =
     [[ True False False]
     [ True False False]
     [False False False]],
           fill_value = 999999)

    >>> np.ma.compress_rowcols(x)
    array([[7, 8]])
    >>> np.ma.compress_rowcols(x, 0)
    array([[6, 7, 8]])
    >>> np.ma.compress_rowcols(x, 1)
    array([[1, 2],
           [4, 5],
           [7, 8]])

    r�z*compress_rowcols works for 2D arrays only.)rU)r7r��NotImplementedErrorr)rrrUrPrPrQrFs3cCs$t|�}|jdkrtd��t|d�S)z�
    Suppress whole rows of a 2-D array that contain masked values.

    This is equivalent to ``np.ma.compress_rowcols(a, 0)``, see
    `extras.compress_rowcols` for details.

    See Also
    --------
    extras.compress_rowcols

    r�z'compress_rows works for 2D arrays only.r)r7r�r�r)r\rPrPrQr~s
cCs$t|�}|jdkrtd��t|d�S)z�
    Suppress whole columns of a 2-D array that contain masked values.

    This is equivalent to ``np.ma.compress_rowcols(a, 1)``, see
    `extras.compress_rowcols` for details.

    See Also
    --------
    extras.compress_rowcols

    r�z'compress_cols works for 2D arrays only.r1)r7r�r�r)r\rPrPrQr�s
cCs
t|d�S)a�
    Mask rows of a 2D array that contain masked values.

    This function is a shortcut to ``mask_rowcols`` with `axis` equal to 0.

    See Also
    --------
    mask_rowcols : Mask rows and/or columns of a 2D array.
    masked_where : Mask where a condition is met.

    Examples
    --------
    >>> import numpy.ma as ma
    >>> a = np.zeros((3, 3), dtype=np.int)
    >>> a[1, 1] = 1
    >>> a
    array([[0, 0, 0],
           [0, 1, 0],
           [0, 0, 0]])
    >>> a = ma.masked_equal(a, 1)
    >>> a
    masked_array(data =
     [[0 0 0]
     [0 -- 0]
     [0 0 0]],
          mask =
     [[False False False]
     [False  True False]
     [False False False]],
          fill_value=999999)
    >>> ma.mask_rows(a)
    masked_array(data =
     [[0 0 0]
     [-- -- --]
     [0 0 0]],
          mask =
     [[False False False]
     [ True  True  True]
     [False False False]],
          fill_value=999999)

    r)r!)r\rUrPrPrQr"�s+cCs
t|d�S)a�
    Mask columns of a 2D array that contain masked values.

    This function is a shortcut to ``mask_rowcols`` with `axis` equal to 1.

    See Also
    --------
    mask_rowcols : Mask rows and/or columns of a 2D array.
    masked_where : Mask where a condition is met.

    Examples
    --------
    >>> import numpy.ma as ma
    >>> a = np.zeros((3, 3), dtype=np.int)
    >>> a[1, 1] = 1
    >>> a
    array([[0, 0, 0],
           [0, 1, 0],
           [0, 0, 0]])
    >>> a = ma.masked_equal(a, 1)
    >>> a
    masked_array(data =
     [[0 0 0]
     [0 -- 0]
     [0 0 0]],
          mask =
     [[False False False]
     [False  True False]
     [False False False]],
          fill_value=999999)
    >>> ma.mask_cols(a)
    masked_array(data =
     [[0 -- 0]
     [0 -- 0]
     [0 -- 0]],
          mask =
     [[False  True False]
     [False  True False]
     [False  True False]],
          fill_value=999999)

    r1)r!)r\rUrPrPrQr �s+cCsht�|�j}|dd�|dd�}|g}|dk	r>|�d|�|dk	rP|�|�t|�dkrdt|�}|S)a!
    Compute the differences between consecutive elements of an array.

    This function is the equivalent of `numpy.ediff1d` that takes masked
    values into account, see `numpy.ediff1d` for details.

    See Also
    --------
    numpy.ediff1d : Equivalent function for ndarrays.

    r1Nr�r)rhr�Zflatr�r{rzr)rTZto_endZto_beginZedr}rPrPrQr�s
cCsLtj|||d�}t|t�r>t|�}|d�t�|d<t|�}n
|�t�}|S)a
    Finds the unique elements of an array.

    Masked values are considered the same element (masked). The output array
    is always a masked array. See `numpy.unique` for more details.

    See Also
    --------
    numpy.unique : Equivalent function for ndarrays.

    )�return_index�return_inverser)rXr-rLrMrNr]r3)�ar1r�r��outputrPrPrQr-s


cCsV|rt�||f�}nt�t|�t|�f�}|��|dd�|dd�|dd�kS)a.
    Returns the unique elements common to both arrays.

    Masked values are considered equal one to the other.
    The output is always a masked array.

    See `numpy.intersect1d` for more details.

    See Also
    --------
    numpy.intersect1d : Equivalent function for ndarrays.

    Examples
    --------
    >>> x = array([1, 3, 3, 3], mask=[0, 0, 0, 1])
    >>> y = array([3, 1, 1, 1], mask=[0, 0, 0, 1])
    >>> intersect1d(x, y)
    masked_array(data = [1 3 --],
                 mask = [False False  True],
           fill_value = 999999)

    Nr�r1)rhr8r-rC)r��ar2�
assume_unique�auxrPrPrQr4s
cCs�|st|�}t|�}t�||f�}|jdkr0|S|��|��}t�dg|dd�|dd�kdgf�}|dd�|dd�k}||S)z�
    Set exclusive-or of 1-D arrays with unique elements.

    The output is always a masked array. See `numpy.setxor1d` for more details.

    See Also
    --------
    numpy.setxor1d : Equivalent function for ndarrays.

    rTr1Nr�)r-rhr8r�rCr9)r�r�r�r�Zauxf�flagZflag2rPrPrQr,Ts
(cCs�|st|dd�\}}t|�}t�||f�}|jdd�}||}|r\|dd�|dd�k}n|dd�|dd�k}t�||gf�}	|jdd�dt|��}
|r�|	|
S|	|
|SdS)a�
    Test whether each element of an array is also present in a second
    array.

    The output is always a masked array. See `numpy.in1d` for more details.

    We recommend using :func:`isin` instead of `in1d` for new code.

    See Also
    --------
    isin       : Version of this function that preserves the shape of ar1.
    numpy.in1d : Equivalent function for ndarrays.

    Notes
    -----
    .. versionadded:: 1.4.0

    T)r�Z	mergesort)�kindr1Nr�)r-rhr8Zargsortrz)r�r�r��invertZrev_idx�ar�orderZsarZbool_arr�ZindxrPrPrQroscCs"t�|�}t||||d��|j�S)a|
    Calculates `element in test_elements`, broadcasting over
    `element` only.

    The output is always a masked array of the same shape as `element`.
    See `numpy.isin` for more details.

    See Also
    --------
    in1d       : Flattened version of this function.
    numpy.isin : Equivalent function for ndarrays.

    Notes
    -----
    .. versionadded:: 1.13.0

    )r�r�)rhr7rr�rZ)�elementZ
test_elementsr�r�rPrPrQr�s
cCstt�||f��S)z�
    Union of two arrays.

    The output is always a masked array. See `numpy.union1d` for more details.

    See also
    --------
    numpy.union1d : Equivalent function for ndarrays.

    )r-rhr8)r�r�rPrPrQr.�scCs8|rt�|���}nt|�}t|�}|t||ddd�S)a�
    Set difference of 1D arrays with unique elements.

    The output is always a masked array. See `numpy.setdiff1d` for more
    details.

    See Also
    --------
    numpy.setdiff1d : Equivalent function for ndarrays.

    Examples
    --------
    >>> x = np.ma.array([1, 2, 3, 4], mask=[0, 1, 0, 1])
    >>> np.ma.setdiff1d(x, [1, 2])
    masked_array(data = [3 --],
                 mask = [False  True],
           fill_value = 999999)

    T)r�r�)rhr7r�r-r)r�r�r�rPrPrQr+�s
Tc
Cs\tj|ddtd�}t�|�}|s0|��r0td��|jddkrBd}tt|��}d|}|rht	d�df}ndt	d�f}|dkr�t
�|��t�}n�t|ddtd	�}t�|�}|s�|��r�td��|��s�|���r|j|jk�rt
�
||�}	|	tk	�r|	}|_|_}d|_d|_t�||f|�}t
�t
�||f|���t�}||j|d
�|8}|||fS)z_
    Private function for the computation of covariance and correlation
    coefficients.

    r�T)�ndminr�r[zCannot process masked data.rr1NF)r�r�r[)rU)rhr6�floatr<r�r�rZ�int�boolr�rX�logical_not�astype�
logical_orrAr^�_sharedmaskr8r�)
rr�y�rowvar�allow_maskedZxmaskrU�tup�xnotmaskZymaskZcommon_maskrPrPrQ�
_covhelper�s8


r�c	Cs�|dk	r|t|�krtd��|dkr2|r.d}nd}t||||�\}}}|s~t�|j|�d|}t|j|��dd�|��}n2t�||j�d|}t||j��dd�|��}|S)aJ
    Estimate the covariance matrix.

    Except for the handling of missing data this function does the same as
    `numpy.cov`. For more details and examples, see `numpy.cov`.

    By default, masked values are recognized as such. If `x` and `y` have the
    same shape, a common mask is allocated: if ``x[i,j]`` is masked, then
    ``y[i,j]`` will also be masked.
    Setting `allow_masked` to False will raise an exception if values are
    missing in either of the input arrays.

    Parameters
    ----------
    x : array_like
        A 1-D or 2-D array containing multiple variables and observations.
        Each row of `x` represents a variable, and each column a single
        observation of all those variables. Also see `rowvar` below.
    y : array_like, optional
        An additional set of variables and observations. `y` has the same
        form as `x`.
    rowvar : bool, optional
        If `rowvar` is True (default), then each row represents a
        variable, with observations in the columns. Otherwise, the relationship
        is transposed: each column represents a variable, while the rows
        contain observations.
    bias : bool, optional
        Default normalization (False) is by ``(N-1)``, where ``N`` is the
        number of observations given (unbiased estimate). If `bias` is True,
        then normalization is by ``N``. This keyword can be overridden by
        the keyword ``ddof`` in numpy versions >= 1.5.
    allow_masked : bool, optional
        If True, masked values are propagated pair-wise: if a value is masked
        in `x`, the corresponding value is masked in `y`.
        If False, raises a `ValueError` exception when some values are missing.
    ddof : {None, int}, optional
        If not ``None`` normalization is by ``(N - ddof)``, where ``N`` is
        the number of observations; this overrides the value implied by
        ``bias``. The default value is ``None``.

        .. versionadded:: 1.5

    Raises
    ------
    ValueError
        Raised if some values are missing and `allow_masked` is False.

    See Also
    --------
    numpy.cov

    Nzddof must be an integerrr1g�?F)�strict)r�r�r�rXr�T�conj�squeeze)	rrr�r��biasr��ddofr��factr�rPrPrQr
s6cCsd}|tjk	s|tjk	r(tj|tdd�t||||�\}}}|spt�|j|�d}t|j|��dd�|�	�}	n.t�||j�d}t||j��dd�|�	�}	yt
�|	�}
Wntk
r�dSX|�
�r�t
�t
j�|
|
��}�n$t|
�}d|_|jd|}|�r~xvt|d�D]f}
x^t|
d|�D]L}tt||
||f��jdd�}t
�t
j�|��||
|f<|||
f<�q&W�qWn�x�t|d�D]v}
xnt|
d|�D]\}tt|d	d	�|
f|d	d	�|ff��jdd�}t
�t
j�|��||
|f<|||
f<�q�W�q�W|	|S)
a6
    Return Pearson product-moment correlation coefficients.

    Except for the handling of missing data this function does the same as
    `numpy.corrcoef`. For more details and examples, see `numpy.corrcoef`.

    Parameters
    ----------
    x : array_like
        A 1-D or 2-D array containing multiple variables and observations.
        Each row of `x` represents a variable, and each column a single
        observation of all those variables. Also see `rowvar` below.
    y : array_like, optional
        An additional set of variables and observations. `y` has the same
        shape as `x`.
    rowvar : bool, optional
        If `rowvar` is True (default), then each row represents a
        variable, with observations in the columns. Otherwise, the relationship
        is transposed: each column represents a variable, while the rows
        contain observations.
    bias : _NoValue, optional
        Has no effect, do not use.

        .. deprecated:: 1.10.0
    allow_masked : bool, optional
        If True, masked values are propagated pair-wise: if a value is masked
        in `x`, the corresponding value is masked in `y`.
        If False, raises an exception.  Because `bias` is deprecated, this
        argument needs to be treated as keyword only to avoid a warning.
    ddof : _NoValue, optional
        Has no effect, do not use.

        .. deprecated:: 1.10.0

    See Also
    --------
    numpy.corrcoef : Equivalent function in top-level NumPy module.
    cov : Estimate the covariance matrix.

    Notes
    -----
    This function accepts but discards arguments `bias` and `ddof`.  This is
    for backwards compatibility with previous versions of this function.  These
    arguments had no effect on the return values of the function and can be
    safely ignored in this and previous versions of numpy.
    z/bias and ddof have no effect and are deprecatedr�)�
stacklevelg�?F)r�r1)rUN)rX�_NoValue�warnings�warn�DeprecationWarningr�rr�r�r�rhZdiagonalr�r��sqrtr�Zouterrr�rZr�r r0�var�reduce)rrr�r�r�r�r��msgr�r��cZdiagZ_denomr�r�r�Z_xrPrPrQrSs:0 4.2cs4eZdZdZee�Zedd��Z�fdd�Z�ZS)�MAxisConcatenatorz�
    Translate slice objects to concatenation along an axis.

    For documentation on usage, see `mr_class`.

    See Also
    --------
    mr_class

    cCst|j�tj�|jd�S)N)rW)r6r�r]rXZmatrixrW)rTrPrPrQ�makemat�szMAxisConcatenator.makematcs"t|t�rtd��tt|��|�S)NzUnavailable for masked array.)rL�strr4�superr��__getitem__)rc�key)�	__class__rPrQr��s
zMAxisConcatenator.__getitem__)	r`rorprb�staticmethodr8r�r��
__classcell__rPrP)rrQr��s
r�c@seZdZdZdd�ZdS)�mr_classaG
    Translate slice objects to concatenation along the first axis.

    This is the masked array version of `lib.index_tricks.RClass`.

    See Also
    --------
    lib.index_tricks.RClass

    Examples
    --------
    >>> np.ma.mr_[np.ma.array([1,2,3]), 0, 0, np.ma.array([4,5,6])]
    array([1, 2, 3, 0, 0, 4, 5, 6])

    cCst�|d�dS)Nr)r�re)rcrPrPrQre�szmr_class.__init__N)r`rorprbrerPrPrPrQr�srcCsZt|�}|tkst�|�s.t�d|jdg�St�|�}t|�dkrR|ddgSdSdS)a�
    Find the indices of the first and last unmasked values.

    Expects a 1-D `MaskedArray`, returns None if all values are masked.

    Parameters
    ----------
    a : array_like
        Input 1-D `MaskedArray`

    Returns
    -------
    edges : ndarray or None
        The indices of first and last non-masked value in the array.
        Returns None if all values are masked.

    See Also
    --------
    flatnotmasked_contiguous, notmasked_contiguous, notmasked_edges,
    clump_masked, clump_unmasked

    Notes
    -----
    Only accepts 1-D arrays.

    Examples
    --------
    >>> a = np.ma.arange(10)
    >>> flatnotmasked_edges(a)
    [0,-1]

    >>> mask = (a < 3) | (a > 8) | (a == 5)
    >>> a[mask] = np.ma.masked
    >>> np.array(a[~a.mask])
    array([3, 4, 6, 7, 8])

    >>> flatnotmasked_edges(a)
    array([3, 8])

    >>> a[:] = np.ma.masked
    >>> print(flatnotmasked_edges(ma))
    None

    rr1r�N)r;rArXr�r6r�Zflatnonzerorz)r\rVZunmaskedrPrPrQr�s-cs�t|�}�dks|jdkr"t|�St|�}tt�|j�t�|g|j�d��t��fdd�t	|j�D��t��fdd�t	|j�D��gS)a`
    Find the indices of the first and last unmasked values along an axis.

    If all values are masked, return None.  Otherwise, return a list
    of two tuples, corresponding to the indices of the first and last
    unmasked values respectively.

    Parameters
    ----------
    a : array_like
        The input array.
    axis : int, optional
        Axis along which to perform the operation.
        If None (default), applies to a flattened version of the array.

    Returns
    -------
    edges : ndarray or list
        An array of start and end indexes if there are any masked data in
        the array. If there are no masked data in the array, `edges` is a
        list of the first and last index.

    See Also
    --------
    flatnotmasked_contiguous, flatnotmasked_edges, notmasked_contiguous,
    clump_masked, clump_unmasked

    Examples
    --------
    >>> a = np.arange(9).reshape((3, 3))
    >>> m = np.zeros_like(a)
    >>> m[1:, 1:] = 1

    >>> am = np.ma.array(a, mask=m)
    >>> np.array(am[~am.mask])
    array([0, 1, 2, 3, 6])

    >>> np.ma.notmasked_edges(ma)
    array([0, 6])

    Nr1)rWcsg|]}�|������qSrP)�min�
compressed)rwr�)rUr�rPrQrxEsz#notmasked_edges.<locals>.<listcomp>csg|]}�|������qSrP)r�r)rwr�)rUr�rPrQrxFs)
r7r�rr<r6rX�indicesrZrMr�)r\rUrVrP)rUr�rQr(s*"cCsvt|�}|tkrtd|jd�Sd}g}xFt�|���D]4\}}tt|��}|sb|�	t|||��||7}q6W|ptdS)a^
    Find contiguous unmasked data in a masked array along the given axis.

    Parameters
    ----------
    a : narray
        The input array.

    Returns
    -------
    slice_list : list
        A sorted sequence of slices (start index, end index).

    See Also
    --------
    flatnotmasked_edges, notmasked_contiguous, notmasked_edges,
    clump_masked, clump_unmasked

    Notes
    -----
    Only accepts 2-D arrays at most.

    Examples
    --------
    >>> a = np.ma.arange(10)
    >>> np.ma.flatnotmasked_contiguous(a)
    slice(0, 10, None)

    >>> mask = (a < 3) | (a > 8) | (a == 5)
    >>> a[mask] = np.ma.masked
    >>> np.array(a[~a.mask])
    array([3, 4, 6, 7, 8])

    >>> np.ma.flatnotmasked_contiguous(a)
    [slice(3, 5, None), slice(6, 9, None)]
    >>> a[:] = np.ma.masked
    >>> print(np.ma.flatnotmasked_edges(a))
    None

    rN)
r;rAr�r��	itertools�groupbyr�rzrNr{)r\rVr�r�r��gr�rPrPrQrIs)cCs�t|�}|j}|dkrtd��|dks.|dkr6t|�Sg}|dd}ddg}tdd�||<x4t|j|�D]"}|||<|�t||�p�d�qlW|S)a�
    Find contiguous unmasked data in a masked array along the given axis.

    Parameters
    ----------
    a : array_like
        The input array.
    axis : int, optional
        Axis along which to perform the operation.
        If None (default), applies to a flattened version of the array.

    Returns
    -------
    endpoints : list
        A list of slices (start and end indexes) of unmasked indexes
        in the array.

    See Also
    --------
    flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges,
    clump_masked, clump_unmasked

    Notes
    -----
    Only accepts 2-D arrays at most.

    Examples
    --------
    >>> a = np.arange(9).reshape((3, 3))
    >>> mask = np.zeros_like(a)
    >>> mask[1:, 1:] = 1

    >>> ma = np.ma.array(a, mask=mask)
    >>> np.array(ma[~ma.mask])
    array([0, 1, 2, 3, 6])

    >>> np.ma.notmasked_contiguous(ma)
    [slice(0, 4, None), slice(6, 7, None)]

    r�z%Currently limited to atmost 2D array.Nr1r)r7r�r�rr�r�rZr{)r\rUr�r��otherr�r�rPrPrQr'~s)c	Cs�|jdkr|��}|dd�|dd�A��}|dd}|dr�t|�dkr\td|j�gStd|d�g}|�dd�t|ddd�|ddd��D��n8t|�dkr�gSdd	�t|ddd�|ddd��D�}|dr�|�t|d|j��|S)
zv
    Finds the clumps (groups of data with the same values) for a 1D bool array.

    Returns a series of slices.
    r1Nr�rcss|]\}}t||�VqdS)N)r�)rw�left�rightrPrPrQ�	<genexpr>�sz_ezclump.<locals>.<genexpr>r�cSsg|]\}}t||��qSrP)r�)rwrrrPrPrQrx�sz_ezclump.<locals>.<listcomp>)	r�r�Znonzerorzr�r��extend�zipr{)rWr�r�rPrPrQ�_ezclump�s 

&(rcCs,t|dt�}|tkr"td|j�gSt|�S)a�
    Return list of slices corresponding to the unmasked clumps of a 1-D array.
    (A "clump" is defined as a contiguous region of the array).

    Parameters
    ----------
    a : ndarray
        A one-dimensional masked array.

    Returns
    -------
    slices : list of slice
        The list of slices, one for each continuous region of unmasked
        elements in `a`.

    Notes
    -----
    .. versionadded:: 1.4.0

    See Also
    --------
    flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges,
    notmasked_contiguous, clump_masked

    Examples
    --------
    >>> a = np.ma.masked_array(np.arange(10))
    >>> a[[0, 1, 2, 6, 8, 9]] = np.ma.masked
    >>> np.ma.clump_unmasked(a)
    [slice(3, 6, None), slice(7, 8, None)]

    r^r)rgrAr�r�r)r\rWrPrPrQr�s!cCst�|�}|tkrgSt|�S)a
    Returns a list of slices corresponding to the masked clumps of a 1-D array.
    (A "clump" is defined as a contiguous region of the array).

    Parameters
    ----------
    a : ndarray
        A one-dimensional masked array.

    Returns
    -------
    slices : list of slice
        The list of slices, one for each continuous region of masked elements
        in `a`.

    Notes
    -----
    .. versionadded:: 1.4.0

    See Also
    --------
    flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges,
    notmasked_contiguous, clump_unmasked

    Examples
    --------
    >>> a = np.ma.masked_array(np.arange(10))
    >>> a[[0, 1, 2, 6, 8, 9]] = np.ma.masked
    >>> np.ma.clump_masked(a)
    [slice(0, 3, None), slice(6, 7, None), slice(8, 10, None)]

    )rhr;rAr)r\rWrPrPrQr�s!
cCs(t�||�}t|�}|tk	r$d||<|S)zD
    Masked values in the input array result in rows of zeros.

    r)rXr/r;rA)rrr�Z_vanderrVrPrPrQr/*s
c
	Cst|�}t|�}t|�}|jdkr2t|t|��}n>|jdkrhtt|��}|tk	rpt||dd�df�}ntd��|dk	r�t|�}|jdkr�td��|jd|jdkr�td��t|t|��}|tk	r�|}	|dk	r�||	}t�	||	||	|||||�St�	|||||||�SdS)zE
    Any masked values in x is propagated in y, and vice-versa.

    r1r�Nrz Expected a 1D or 2D array for y!z expected a 1-d array for weightsz(expected w and y to have the same length)
r7r;r�r@r"rAr�rZrXr))
rrr��degZrcond�full�wrrVZmyZnot_mrPrPrQr)8s.


)N)NNF)NNFF)NNF)N)N)N)N)NN)FF)F)F)FF)FF)F)NTT)NTFTN)N)N)N)NFNF)jrb�
__future__rrr�__all__rr��r2rhr3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrr!�numpyrXrGr�Znumpy.core.umath�umathZnumpy.core.multiarrayrHZnumpy.core.numericrIZnumpy.lib.function_baserJZnumpy.lib.index_tricksrKrRrr�r#r$r_rqrvryrrrr	r0r*rr
rrrr�rr�find�rstripr
r%r�rrrrr"r rr-rr,rrr.r+r�rr�rr�rr&rr(rr'rrrr/Zdoc_noter)rPrPrPrQ�<module>
s�
`
74:7

Q

b
R
a
*
8
-
2


 

*

!
+
I
Y7
35
<',

"

Youez - 2016 - github.com/yon3zu
LinuXploit