File: //usr/local/lib/python3.10/dist-packages/numpy/lib/__pycache__/nanfunctions.cpython-310.pyc
o
���g� � @ sZ d Z ddlZddlZddlZddlmZ ddlmZ ej ej
dd�Z
g d�Zd[dd �Zd
d� Z
dd
� Zd\dd�Zd[dd�Z d]dd�Ze
e�ddejejejfdd��Z d]dd�Ze
e�ddejejejfdd��Zd^dd�dd�Ze
e�d^ejd�dd��Zd^dd�d d!�Ze
e�d^ejd�d"d#��Z d_d$d%�Ze
e�dddejejejfd&d'��Z d_d(d)�Ze
e�dddejejejfd*d+��Zd`d,d-�Ze
e�d`d.d/��Zd`d0d1�Z e
e �d`d2d3��Z!dadd4�d5d6�Z"e
e"�dddejfejd4�d7d8��Z#d\d9d:�Z$dbd;d<�Z%dbd=d>�Z& dad?d@�Z'e
e'�dddejfdAdB��Z( d]ddC�dDdE�Z)e
e)�ddddFejfddC�dGdH��Z* d]ddC�dIdJ�Z+e
e+�ddddFejfddC�dKdL��Z,ddddFejfdMdN�Z- FdcdOdP�Z.dddQdR�Z/ d]dd4�dSdT�Z0e
e0�ddddejfejd4�dUdV��Z1 d]dd4�dWdX�Z2e
e2�ddddejfejd4�dYdZ��Z3dS )ea�
Functions that ignore NaN.
Functions
---------
- `nanmin` -- minimum non-NaN value
- `nanmax` -- maximum non-NaN value
- `nanargmin` -- index of minimum non-NaN value
- `nanargmax` -- index of maximum non-NaN value
- `nansum` -- sum of non-NaN values
- `nanprod` -- product of non-NaN values
- `nancumsum` -- cumulative sum of non-NaN values
- `nancumprod` -- cumulative product of non-NaN values
- `nanmean` -- mean of non-NaN values
- `nanvar` -- variance of non-NaN values
- `nanstd` -- standard deviation of non-NaN values
- `nanmedian` -- median of non-NaN values
- `nanquantile` -- qth quantile of non-NaN values
- `nanpercentile` -- qth percentile of non-NaN values
� N)�
function_base)� overrides�numpy)�module)�nansum�nanmax�nanmin� nanargmax� nanargmin�nanmean� nanmedian�
nanpercentile�nanvar�nanstd�nanprod� nancumsum�
nancumprod�nanquantilec C s0 | j jdvrdS tj| |d�}tj||d�}|S )ap
Parameters
----------
a : array-like
Input array with at least 1 dimension.
out : ndarray, optional
Alternate output array in which to place the result. The default
is ``None``; if provided, it must have the same shape as the
expected output and will prevent the allocation of a new array.
Returns
-------
y : bool ndarray or True
A bool array where ``np.nan`` positions are marked with ``False``
and other positions are marked with ``True``. If the type of ``a``
is such that it can't possibly contain ``np.nan``, returns ``True``.
�fcT��out)�dtype�kind�np�isnan�invert)�ar �y� r �A/usr/local/lib/python3.10/dist-packages/numpy/lib/nanfunctions.py� _nan_mask) s
r c C sx t �| �} | jt jkrt j| | td�}nt| jjt j�r"t � | �}nd}|dur8t j
| ddd�} t j| ||d� | |fS )a�
If `a` is of inexact type, make a copy of `a`, replace NaNs with
the `val` value, and return the copy together with a boolean mask
marking the locations where NaNs were present. If `a` is not of
inexact type, do nothing and return `a` together with a mask of None.
Note that scalars will end up as array scalars, which is important
for using the result as the value of the out argument in some
operations.
Parameters
----------
a : array-like
Input array.
val : float
NaN values are set to val before doing the operation.
Returns
-------
y : ndarray
If `a` is of inexact type, return a copy of `a` with the NaNs
replaced by the fill value, otherwise return `a`.
mask: {bool, None}
If `a` is of inexact type, return a boolean mask marking locations of
NaNs, otherwise return None.
�r NT)�subok�copy��where)r �
asanyarrayr �object_� not_equal�bool�
issubclass�type�inexactr �array�copyto�r �val�maskr r r �_replace_nanD s
r2 c C s2 t | tj�rtj| ||dd� | S | j�|�} | S )a\
Replace values in `a` with NaN where `mask` is True. This differs from
copyto in that it will deal with the case where `a` is a numpy scalar.
Parameters
----------
a : ndarray or numpy scalar
Array or numpy scalar some of whose values are to be replaced
by val.
val : numpy scalar
Value used a replacement.
mask : ndarray, scalar
Boolean array. Where True the corresponding element of `a` is
replaced by `val`. Broadcasts.
Returns
-------
res : ndarray, scalar
Array with elements replaced or scalar `val`.
�unsafe)r% �casting)�
isinstancer �ndarrayr. r r+ r/ r r r �_copytoq s
�r7 Fc C s� | j tkrtj| | td�}nt�| �}t�|�d }|j| jkr0tj dt
dd� | dd� dfS |jdkr9| |fS |s?| �� } | |j d� ||j d� }|| |d|j� <