nanfunctions.pyc
1 o 2 [��cl � @ sZ d Z ddlZddlZddlZddlmZ ddlmZ ej ej 3 dd�Z 4 g d�Zd[dd �Zd 5 d� Z dd � Zd\dd�Zd[dd�Z d]dd�Ze 6 e�ddejejejfdd��Z d]dd�Ze 7 e�ddejejejfdd��Zd^dd�dd�Ze 8 e�d^ejd�dd��Zd^dd�d d!�Ze 9 e�d^ejd�d"d#��Z d_d$d%�Ze 10 e�dddejejejfd&d'��Z d_d(d)�Ze 11 e�dddejejejfd*d+��Zd`d,d-�Ze 12 e�d`d.d/��Zd`d0d1�Z e 13 e �d`d2d3��Z!dadd4�d5d6�Z"e 14 e"�dddejfejd4�d7d8��Z#d\d9d:�Z$dbd;d<�Z%dbd=d>�Z& dad?d@�Z'e 15 e'�dddejfdAdB��Z( d]ddC�dDdE�Z)e 16 e)�ddddFejfddC�dGdH��Z* d]ddC�dIdJ�Z+e 17 e+�ddddFejfddC�dKdL��Z,ddddFejfdMdN�Z- FdcdOdP�Z.dddQdR�Z/ d]dd4�dSdT�Z0e 18 e0�ddddejfejd4�dUdV��Z1 d]dd4�dWdX�Z2e 19 e2�ddddejfejd4�dYdZ��Z3dS )ea� 20 Functions that ignore NaN. 21 22 Functions 23 --------- 24 25 - `nanmin` -- minimum non-NaN value 26 - `nanmax` -- maximum non-NaN value 27 - `nanargmin` -- index of minimum non-NaN value 28 - `nanargmax` -- index of maximum non-NaN value 29 - `nansum` -- sum of non-NaN values 30 - `nanprod` -- product of non-NaN values 31 - `nancumsum` -- cumulative sum of non-NaN values 32 - `nancumprod` -- cumulative product of non-NaN values 33 - `nanmean` -- mean of non-NaN values 34 - `nanvar` -- variance of non-NaN values 35 - `nanstd` -- standard deviation of non-NaN values 36 - `nanmedian` -- median of non-NaN values 37 - `nanquantile` -- qth quantile of non-NaN values 38 - `nanpercentile` -- qth percentile of non-NaN values 39 40 � N)� function_base)� overrides�numpy)�module)�nansum�nanmax�nanmin� nanargmax� nanargmin�nanmean� nanmedian� nanpercentile�nanvar�nanstd�nanprod� nancumsum� 41 nancumprod�nanquantilec C s0 | j jdvrdS tj| |d�}tj||d�}|S )ap 42 Parameters 43 ---------- 44 a : array-like 45 Input array with at least 1 dimension. 46 out : ndarray, optional 47 Alternate output array in which to place the result. The default 48 is ``None``; if provided, it must have the same shape as the 49 expected output and will prevent the allocation of a new array. 50 51 Returns 52 ------- 53 y : bool ndarray or True 54 A bool array where ``np.nan`` positions are marked with ``False`` 55 and other positions are marked with ``True``. If the type of ``a`` 56 is such that it can't possibly contain ``np.nan``, returns ``True``. 57 �fcT��out)�dtype�kind�np�isnan�invert)�ar �y� r ��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\numpy\lib\nanfunctions.py� _nan_mask) s 58 r c C sx t �| �} | jt jkrt j| | td�}nt| jjt j�r"t � | �}nd}|dur8t j 59 | ddd�} t j| ||d� | |fS )a� 60 If `a` is of inexact type, make a copy of `a`, replace NaNs with 61 the `val` value, and return the copy together with a boolean mask 62 marking the locations where NaNs were present. If `a` is not of 63 inexact type, do nothing and return `a` together with a mask of None. 64 65 Note that scalars will end up as array scalars, which is important 66 for using the result as the value of the out argument in some 67 operations. 68 69 Parameters 70 ---------- 71 a : array-like 72 Input array. 73 val : float 74 NaN values are set to val before doing the operation. 75 76 Returns 77 ------- 78 y : ndarray 79 If `a` is of inexact type, return a copy of `a` with the NaNs 80 replaced by the fill value, otherwise return `a`. 81 mask: {bool, None} 82 If `a` is of inexact type, return a boolean mask marking locations of 83 NaNs, otherwise return None. 84 85 �r NT)�subok�copy��where)r � 86 asanyarrayr �object_� not_equal�bool� 87 issubclass�type�inexactr �array�copyto�r �val�maskr r r �_replace_nanD s 88 r2 c C s2 t | tj�rtj| ||dd� | S | j�|�} | S )a\ 89 Replace values in `a` with NaN where `mask` is True. This differs from 90 copyto in that it will deal with the case where `a` is a numpy scalar. 91 92 Parameters 93 ---------- 94 a : ndarray or numpy scalar 95 Array or numpy scalar some of whose values are to be replaced 96 by val. 97 val : numpy scalar 98 Value used a replacement. 99 mask : ndarray, scalar 100 Boolean array. Where True the corresponding element of `a` is 101 replaced by `val`. Broadcasts. 102 103 Returns 104 ------- 105 res : ndarray, scalar 106 Array with elements replaced or scalar `val`. 107 108 �unsafe)r% �casting)� 109 isinstancer �ndarrayr. r r+ r/ r r r �_copytoq s 110 �r7 Fc C s� | j tkrtj| | td�}nt�| �}t�|�d }|j| jkr0tj dt 111 dd� | dd� dfS |jdkr9| |fS |s?| �� } | |j d� ||j d� }|| |d|j� <