extras.pyc
1 o 2 [��c�� � @ st d Z g d�ZddlZddlZddlmZ ddlmZmZm Z m 3 Z 4 mZmZm Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlZddlmZm 5 Z ddl!m"Z" dd l#m$Z$ dd 6 l%m&Z& ddl'm(Z( dd � Z)dsdd�Z*e+fdd�Z,dd� Z-G dd� d�Z.G dd� de.�Z/G dd� de.�Z0G dd� de.�Z1G dd� de.�Z2e2d�Z3e2d�Z4e2d �Z5e0d!� Z6Z7e0d"�Z8e0d#�Z9e0d$�Z:e0d%�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 �Ad.�� �B� d/ e@_ dtejCd1�d2d3�ZDdud4d5�ZEdtd6d7�ZFdsd8d9�ZGdsd:d;�ZHd<d=� ZId>d?� ZJejCfd@dA�ZKejCfdBdC�ZLdvdDdE�ZMdwdFdG�ZNdxdHdI�ZOdxdJdK�ZPdwdLdM�ZQdwdNdO�ZRdPdQ� ZSdxdRdS�ZTdydUdV�ZUdzdWdX�ZVddTejCdTejCfdYdZ�ZWG d[d\� d\e(�ZXG d]d^� d^eX�ZYeY� ZZd{d_d`�Z[dadb� Z\dsdcdd�Z]dedf� Z^dsdgdh�Z_didj� Z`dkdl� Zadmdn� Zbdsdodp�Zce�dejcj ecj �ec_ d|dqdr�Zee�dejej eej �ee_ dS )}z� 7 Masked arrays add-ons. 8 9 A collection of utilities for `numpy.ma`. 10 11 :author: Pierre Gerard-Marchant 12 :contact: pierregm_at_uga_dot_edu 13 :version: $Id: extras.py 3473 2007-10-29 15:18:13Z jarrod.millman $ 14 15 ).�apply_along_axis�apply_over_axes� 16 atleast_1d� 17 atleast_2d� 18 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� 19 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 r )�ndarrayr5 )�normalize_axis_index)�normalize_axis_tuple)�_ureduce)�AxisConcatenatorc C s t | tttf�S )z6 20 Is seq a sequence (ndarray, list or tuple)? 21 22 )� 23 isinstancerF �tuple�list)�seq� rO ��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\numpy\ma\extras.py� 24 issequence* s rQ c C s t | �}|�|�S )a� 25 Count the number of masked elements along the given axis. 26 27 Parameters 28 ---------- 29 arr : array_like 30 An array with (possibly) masked elements. 31 axis : int, optional 32 Axis along which to count. If None (default), a flattened 33 version of the array is used. 34 35 Returns 36 ------- 37 count : int, ndarray 38 The total number of masked elements (axis=None) or the number 39 of masked elements along each slice of the given axis. 40 41 See Also 42 -------- 43 MaskedArray.count : Count non-masked elements. 44 45 Examples 46 -------- 47 >>> import numpy.ma as ma 48 >>> a = np.arange(9).reshape((3,3)) 49 >>> a = ma.array(a) 50 >>> a[1, 0] = ma.masked 51 >>> a[1, 2] = ma.masked 52 >>> a[2, 1] = ma.masked 53 >>> a 54 masked_array( 55 data=[[0, 1, 2], 56 [--, 4, --], 57 [6, --, 8]], 58 mask=[[False, False, False], 59 [ True, False, True], 60 [False, True, False]], 61 fill_value=999999) 62 >>> ma.count_masked(a) 63 3 64 65 When the `axis` keyword is used an array is returned. 66 67 >>> ma.count_masked(a, axis=0) 68 array([1, 1, 1]) 69 >>> ma.count_masked(a, axis=1) 70 array([0, 2, 1]) 71 72 )r; �sum)�arr�axis�mrO rO rP r 2 s 2 73 r c C s$ t t�| |�t�| t|��d�}|S )aC 74 Empty masked array with all elements masked. 75 76 Return an empty masked array of the given shape and dtype, where all the 77 data are masked. 78 79 Parameters 80 ---------- 81 shape : int or tuple of ints 82 Shape of the required MaskedArray, e.g., ``(2, 3)`` or ``2``. 83 dtype : dtype, optional 84 Data type of the output. 85 86 Returns 87 ------- 88 a : MaskedArray 89 A masked array with all data masked. 90 91 See Also 92 -------- 93 masked_all_like : Empty masked array modelled on an existing array. 94 95 Examples 96 -------- 97 >>> import numpy.ma as ma 98 >>> ma.masked_all((3, 3)) 99 masked_array( 100 data=[[--, --, --], 101 [--, --, --], 102 [--, --, --]], 103 mask=[[ True, True, True], 104 [ True, True, True], 105 [ True, True, True]], 106 fill_value=1e+20, 107 dtype=float64) 108 109 The `dtype` parameter defines the underlying data type. 110 111 >>> a = ma.masked_all((3, 3)) 112 >>> a.dtype 113 dtype('float64') 114 >>> a = ma.masked_all((3, 3), dtype=np.int32) 115 >>> a.dtype 116 dtype('int32') 117 118 ��mask)r>