File: //home/arjun/.local/lib/python3.10/site-packages/numpy/ma/__pycache__/extras.cpython-310.pyc
o
���g� � @ sz d Z g d�ZddlZddlZddlmZ ddlmZmZm Z m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlZddlmZm
Z ddl m!Z! dd l"m#Z# dd
l$m%Z% ddl&m'Z' dd
� Z(dudd�Z)e*fdd�Z+dd� Z,G dd� d�Z-G dd� de-�Z.G dd� de-�Z/G dd� de-�Z0G dd� de-�Z1e1d�Z2e1d�Z3e1d �Z4e/d!� Z5Z6e/d"�Z7e/d#�Z8e/d$�Z9e/d%�Z:e.d&�Z;e.d'�Z<d(d)� Z=d*d+� Z>ej>j e>_ d,d-� Z?e?j dur�ej?j dej?j �@d.�� �A� d/ e?_ dvejBd1�d2d3�ZCdwd4d5�ZDdvd6d7�ZEdud8d9�ZFdud:d;�ZGd<d=� ZHd>d?� ZIdud@dA�ZJejBfdBdC�ZKejBfdDdE�ZLdxdFdG�ZMdydHdI�ZNdzdJdK�ZOdzdLdM�ZPdydNdO�ZQdydPdQ�ZRdRdS� ZSdzdTdU�ZTd{dWdX�ZUd|dYdZ�ZVddVejBdVejBfd[d\�ZWG d]d^� d^e'�ZXG d_d`� d`eX�ZYeY� ZZd}dadb�Z[dcdd� Z\dudedf�Z]dgdh� Z^dudidj�Z_dkdl� Z`dmdn� Zadodp� Zbdudqdr�Zce�dejcj ecj �ec_ d~dsdt�Zee�dejej eej �ee_ dS )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 $
).�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_�ndenumerate�notmasked_contiguous�notmasked_edges�polyfit� row_stack� setdiff1d�setxor1d�stack�unique�union1d�vander�vstack� N� )�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_subclassr )�ndarrayr5 )�normalize_axis_index)�normalize_axis_tuple)�_ureduce)�AxisConcatenatorc C s t | tttf�S )z6
Is seq a sequence (ndarray, list or tuple)?
)�
isinstancerF �tuple�list)�seq� rO �B/home/arjun/.local/lib/python3.10/site-packages/numpy/ma/extras.py�
issequence) s rQ c C s t | �}|�|�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�mrO rO rP r 1 s 2
r c C s$ t t�| |�t�| t|��d�}|S )aC
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 : int or tuple of ints
Shape of the required MaskedArray, e.g., ``(2, 3)`` or ``2``.
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,
dtype=float64)
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>