numpy.ma.clip   ma.clip(*args, **kwargs) = <numpy.ma.core._convert2ma object>

Clip (limit) the values in an array. Given an interval, values outside the interval are clipped to the interval edges. For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, and values larger than 1 become 1. Equivalent to but faster than np.minimum(a_max, np.maximum(a, a_min)). No check is performed to ensure a_min < a_max.  Parameters

aarray_like

Array containing elements to clip.
a_min, a_maxarray_like or None

Minimum and maximum value. If None, clipping is not performed on the corresponding edge. Only one of a_min and a_max may be None. Both are broadcast against a.
outndarray, optional

The results will be placed in this array. It may be the input array for in-place clipping. out must be of the right shape to hold the output. Its type is preserved.  **kwargs

For other keyword-only arguments, see the ufunc docs.  New in version 1.17.0.     Returns

clipped_arrayMaskedArray

An array with the elements of a, but where values < a_min are replaced with a_min, and those > a_max with a_max.      See also  Output type determination
  Notes When a_min is greater than a_max, clip returns an array in which all values are equal to a_max, as shown in the second example. Examples >>> a = np.arange(10)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.clip(a, 1, 8)
array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8])
>>> np.clip(a, 8, 1)
array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
>>> np.clip(a, 3, 6, out=a)
array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
>>> a
array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
>>> a = np.arange(10)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.clip(a, [3, 4, 1, 1, 1, 4, 4, 4, 4, 4], 8)
array([3, 4, 2, 3, 4, 5, 6, 7, 8, 8])


numpy.ma.clump_masked   ma.clump_masked(a)[source]

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

andarray

A one-dimensional masked array.    Returns

sliceslist of slice

The list of slices, one for each continuous region of masked elements in a.      See also
flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges

notmasked_contiguous, clump_unmasked

  Notes  New in version 1.4.0.  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)]


numpy.ma.clump_unmasked   ma.clump_unmasked(a)[source]

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

andarray

A one-dimensional masked array.    Returns

sliceslist of slice

The list of slices, one for each continuous region of unmasked elements in a.      See also
flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges

notmasked_contiguous, clump_masked

  Notes  New in version 1.4.0.  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)]


numpy.ma.column_stack   ma.column_stack(*args, **kwargs) = <numpy.ma.extras._fromnxfunction_seq object>

Stack 1-D arrays as columns into a 2-D array. Take a sequence of 1-D arrays and stack them as columns to make a single 2-D array. 2-D arrays are stacked as-is, just like with hstack. 1-D arrays are turned into 2-D columns first.  Parameters

tupsequence of 1-D or 2-D arrays.

Arrays to stack. All of them must have the same first dimension.    Returns

stacked2-D array

The array formed by stacking the given arrays.      See also
stack, hstack, vstack, concatenate

  Notes The function is applied to both the _data and the _mask, if any. Examples >>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.column_stack((a,b))
array([[1, 2],
       [2, 3],
       [3, 4]])


numpy.ma.common_fill_value   ma.common_fill_value(a, b)[source]

Return the common filling value of two masked arrays, if any. If a.fill_value == b.fill_value, return the fill value, otherwise return None.  Parameters

a, bMaskedArray

The masked arrays for which to compare fill values.    Returns

fill_valuescalar or None

The common fill value, or None.     Examples >>> x = np.ma.array([0, 1.], fill_value=3)
>>> y = np.ma.array([0, 1.], fill_value=3)
>>> np.ma.common_fill_value(x, y)
3.0


numpy.ma.compress_cols   ma.compress_cols(a)[source]

Suppress whole columns of a 2-D array that contain masked values. This is equivalent to np.ma.compress_rowcols(a, 1), see compress_rowcols for details.  See also  compress_rowcols


numpy.ma.compress_rowcols   ma.compress_rowcols(x, axis=None)[source]

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

xarray_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.
axisint, optional

Axis along which to perform the operation. Default is None.    Returns

compressed_arrayndarray

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]])


numpy.ma.compress_rows   ma.compress_rows(a)[source]

Suppress whole rows of a 2-D array that contain masked values. This is equivalent to np.ma.compress_rowcols(a, 0), see compress_rowcols for details.  See also  compress_rowcols


numpy.ma.compressed   ma.compressed(x)[source]

Return all the non-masked data as a 1-D array. This function is equivalent to calling the “compressed” method of a ma.MaskedArray, see ma.MaskedArray.compressed for details.  See also  ma.MaskedArray.compressed

Equivalent method.


numpy.ma.concatenate   ma.concatenate(arrays, axis=0)[source]

Concatenate a sequence of arrays along the given axis.  Parameters

arrayssequence of array_like

The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
axisint, optional

The axis along which the arrays will be joined. Default is 0.    Returns

resultMaskedArray

The concatenated array with any masked entries preserved.      See also  numpy.concatenate

Equivalent function in the top-level NumPy module.    Examples >>> import numpy.ma as ma
>>> a = ma.arange(3)
>>> a[1] = ma.masked
>>> b = ma.arange(2, 5)
>>> a
masked_array(data=[0, --, 2],
             mask=[False,  True, False],
       fill_value=999999)
>>> b
masked_array(data=[2, 3, 4],
             mask=False,
       fill_value=999999)
>>> ma.concatenate([a, b])
masked_array(data=[0, --, 2, 2, 3, 4],
             mask=[False,  True, False, False, False, False],
       fill_value=999999)


numpy.ma.conjugate   ma.conjugate(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <numpy.ma.core._MaskedUnaryOperation object>

Return the complex conjugate, element-wise. The complex conjugate of a complex number is obtained by changing the sign of its imaginary part.  Parameters

xarray_like

Input value.
outndarray, None, or tuple of ndarray and None, optional

A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
wherearray_like, optional

This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.  **kwargs

For other keyword-only arguments, see the ufunc docs.    Returns

yndarray

The complex conjugate of x, with same dtype as y. This is a scalar if x is a scalar.     Notes conj is an alias for conjugate: >>> np.conj is np.conjugate
True
 Examples >>> np.conjugate(1+2j)
(1-2j)
 >>> x = np.eye(2) + 1j * np.eye(2)
>>> np.conjugate(x)
array([[ 1.-1.j,  0.-0.j],
       [ 0.-0.j,  1.-1.j]])


numpy.ma.copy   ma.copy(self, *args, **params) a.copy(order='C') = <numpy.ma.core._frommethod object>
  Return a copy of the array.  Parameters

order{‘C’, ‘F’, ‘A’, ‘K’}, optional

Controls the memory layout of the copy. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible. (Note that this function and numpy.copy are very similar but have different default values for their order= arguments, and this function always passes sub-classes through.)      See also  numpy.copy

Similar function with different default behavior numpy.copyto    Notes This function is the preferred method for creating an array copy. The function numpy.copy is similar, but it defaults to using order ‘K’, and will not pass sub-classes through by default. Examples >>> x = np.array([[1,2,3],[4,5,6]], order='F')
 >>> y = x.copy()
 >>> x.fill(0)
 >>> x
array([[0, 0, 0],
       [0, 0, 0]])
 >>> y
array([[1, 2, 3],
       [4, 5, 6]])
 >>> y.flags['C_CONTIGUOUS']
True


numpy.ma.corrcoef   ma.corrcoef(x, y=None, rowvar=True, bias=<no value>, allow_masked=True, ddof=<no value>)[source]

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

xarray_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.
yarray_like, optional

An additional set of variables and observations. y has the same shape as x.
rowvarbool, 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 since version 1.10.0.
allow_maskedbool, 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 since version 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.


numpy.ma.count   ma.count(self, axis=None, keepdims=<no value>) = <numpy.ma.core._frommethod object>

Count the non-masked elements of the array along the given axis.  Parameters

axisNone or int or tuple of ints, optional

Axis or axes along which the count is performed. The default, None, performs the count over all the dimensions of the input array. axis may be negative, in which case it counts from the last to the first axis.  New in version 1.10.0.  If this is a tuple of ints, the count is performed on multiple axes, instead of a single axis or all the axes as before.
keepdimsbool, 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 array.    Returns

resultndarray or scalar

An array with the same shape as the input array, with the specified axis removed. If the array is a 0-d array, or if axis is None, a scalar is returned.      See also  ma.count_masked

Count masked elements in array or along a given axis.    Examples >>> import numpy.ma as ma
>>> a = ma.arange(6).reshape((2, 3))
>>> a[1, :] = ma.masked
>>> a
masked_array(
  data=[[0, 1, 2],
        [--, --, --]],
  mask=[[False, False, False],
        [ True,  True,  True]],
  fill_value=999999)
>>> a.count()
3
 When the axis keyword is specified an array of appropriate size is returned. >>> a.count(axis=0)
array([1, 1, 1])
>>> a.count(axis=1)
array([3, 0])


numpy.ma.count_masked   ma.count_masked(arr, axis=None)[source]

Count the number of masked elements along the given axis.  Parameters

arrarray_like

An array with (possibly) masked elements.
axisint, optional

Axis along which to count. If None (default), a flattened version of the array is used.    Returns

countint, 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])


numpy.ma.cov   ma.cov(x, y=None, rowvar=True, bias=False, allow_masked=True, ddof=None)[source]

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

xarray_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.
yarray_like, optional

An additional set of variables and observations. y has the same shape as x.
rowvarbool, 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.
biasbool, 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_maskedbool, 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.  New in version 1.5.     Raises
 ValueError

Raised if some values are missing and allow_masked is False.      See also  numpy.cov


numpy.ma.cumprod   ma.cumprod(self, axis=None, dtype=None, out=None) = <numpy.ma.core._frommethod object>

Return the cumulative product of the array elements over the given axis. Masked values are set to 1 internally during the computation. However, their position is saved, and the result will be masked at the same locations. Refer to numpy.cumprod for full documentation.  See also  numpy.ndarray.cumprod

corresponding function for ndarrays  numpy.cumprod

equivalent function    Notes The mask is lost if out is not a valid MaskedArray ! Arithmetic is modular when using integer types, and no error is raised on overflow.


numpy.ma.cumsum   ma.cumsum(self, axis=None, dtype=None, out=None) = <numpy.ma.core._frommethod object>

Return the cumulative sum of the array elements over the given axis. Masked values are set to 0 internally during the computation. However, their position is saved, and the result will be masked at the same locations. Refer to numpy.cumsum for full documentation.  See also  numpy.ndarray.cumsum

corresponding function for ndarrays  numpy.cumsum

equivalent function    Notes The mask is lost if out is not a valid ma.MaskedArray ! Arithmetic is modular when using integer types, and no error is raised on overflow. Examples >>> marr = np.ma.array(np.arange(10), mask=[0,0,0,1,1,1,0,0,0,0])
>>> marr.cumsum()
masked_array(data=[0, 1, 3, --, --, --, 9, 16, 24, 33],
             mask=[False, False, False,  True,  True,  True, False, False,
                   False, False],
       fill_value=999999)


numpy.ma.default_fill_value   ma.default_fill_value(obj)[source]

Return the default fill value for the argument object. The default filling value depends on the datatype of the input array or the type of the input scalar:
datatype default
bool True
int 999999
float 1.e20
complex 1.e20+0j
object ‘?’
string ‘N/A’   For structured types, a structured scalar is returned, with each field the default fill value for its type. For subarray types, the fill value is an array of the same size containing the default scalar fill value.  Parameters

objndarray, dtype or scalar

The array data-type or scalar for which the default fill value is returned.    Returns

fill_valuescalar

The default fill value.     Examples >>> np.ma.default_fill_value(1)
999999
>>> np.ma.default_fill_value(np.array([1.1, 2., np.pi]))
1e+20
>>> np.ma.default_fill_value(np.dtype(complex))
(1e+20+0j)


numpy.ma.diag   ma.diag(v, k=0)[source]

Extract a diagonal or construct a diagonal array. This function is the equivalent of numpy.diag that takes masked values into account, see numpy.diag for details.  See also  numpy.diag

Equivalent function for ndarrays.


numpy.ma.diff   ma.diff(*args, **kwargs) = <numpy.ma.core._convert2ma object>

Calculate the n-th discrete difference along the given axis. The first difference is given by out[i] = a[i+1] - a[i] along the given axis, higher differences are calculated by using diff recursively.  Parameters

aarray_like

Input array
nint, optional

The number of times values are differenced. If zero, the input is returned as-is.
axisint, optional

The axis along which the difference is taken, default is the last axis.
prepend, appendarray_like, optional

Values to prepend or append to a along axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match a except along axis.  New in version 1.16.0.     Returns

diffMaskedArray

The n-th differences. The shape of the output is the same as a except along axis where the dimension is smaller by n. The type of the output is the same as the type of the difference between any two elements of a. This is the same as the type of a in most cases. A notable exception is datetime64, which results in a timedelta64 output array.      See also
gradient, ediff1d, cumsum

  Notes Type is preserved for boolean arrays, so the result will contain False when consecutive elements are the same and True when they differ. For unsigned integer arrays, the results will also be unsigned. This should not be surprising, as the result is consistent with calculating the difference directly: >>> u8_arr = np.array([1, 0], dtype=np.uint8)
>>> np.diff(u8_arr)
array([255], dtype=uint8)
>>> u8_arr[1,...] - u8_arr[0,...]
255
 If this is not desirable, then the array should be cast to a larger integer type first: >>> i16_arr = u8_arr.astype(np.int16)
>>> np.diff(i16_arr)
array([-1], dtype=int16)
 Examples >>> x = np.array([1, 2, 4, 7, 0])
>>> np.diff(x)
array([ 1,  2,  3, -7])
>>> np.diff(x, n=2)
array([  1,   1, -10])
 >>> x = np.array([[1, 3, 6, 10], [0, 5, 6, 8]])
>>> np.diff(x)
array([[2, 3, 4],
       [5, 1, 2]])
>>> np.diff(x, axis=0)
array([[-1,  2,  0, -2]])
 >>> x = np.arange('1066-10-13', '1066-10-16', dtype=np.datetime64)
>>> np.diff(x)
array([1, 1], dtype='timedelta64[D]')


numpy.ma.dot   ma.dot(a, b, strict=False, out=None)[source]

Return the dot product of two arrays. This function is the equivalent of numpy.dot that takes masked values into account. Note that strict and out are in different position than in the method version. In order to maintain compatibility with the corresponding method, it is recommended that the optional arguments be treated as keyword only. At some point that may be mandatory.  Note Works only with 2-D arrays at the moment.   Parameters

a, bmasked_array_like

Inputs arrays.
strictbool, optional

Whether masked data are propagated (True) or set to 0 (False) for the computation. Default is False. Propagating the mask means that if a masked value appears in a row or column, the whole row or column is considered masked.
outmasked_array, optional

Output argument. This must have the exact kind that would be returned if it was not used. In particular, it must have the right type, must be C-contiguous, and its dtype must be the dtype that would be returned for dot(a,b). This is a performance feature. Therefore, if these conditions are not met, an exception is raised, instead of attempting to be flexible.  New in version 1.10.2.       See also  numpy.dot

Equivalent function for ndarrays.    Examples >>> a = np.ma.array([[1, 2, 3], [4, 5, 6]], mask=[[1, 0, 0], [0, 0, 0]])
>>> b = np.ma.array([[1, 2], [3, 4], [5, 6]], mask=[[1, 0], [0, 0], [0, 0]])
>>> np.ma.dot(a, b)
masked_array(
  data=[[21, 26],
        [45, 64]],
  mask=[[False, False],
        [False, False]],
  fill_value=999999)
>>> np.ma.dot(a, b, strict=True)
masked_array(
  data=[[--, --],
        [--, 64]],
  mask=[[ True,  True],
        [ True, False]],
  fill_value=999999)


numpy.ma.dstack   ma.dstack(*args, **kwargs) = <numpy.ma.extras._fromnxfunction_seq object>

Stack arrays in sequence depth wise (along third axis). This is equivalent to concatenation along the third axis after 2-D arrays of shape (M,N) have been reshaped to (M,N,1) and 1-D arrays of shape (N,) have been reshaped to (1,N,1). Rebuilds arrays divided by dsplit. This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.  Parameters

tupsequence of arrays

The arrays must have the same shape along all but the third axis. 1-D or 2-D arrays must have the same shape.    Returns

stackedndarray

The array formed by stacking the given arrays, will be at least 3-D.      See also  concatenate

Join a sequence of arrays along an existing axis.  stack

Join a sequence of arrays along a new axis.  block

Assemble an nd-array from nested lists of blocks.  vstack

Stack arrays in sequence vertically (row wise).  hstack

Stack arrays in sequence horizontally (column wise).  column_stack

Stack 1-D arrays as columns into a 2-D array.  dsplit

Split array along third axis.    Notes The function is applied to both the _data and the _mask, if any. Examples >>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.dstack((a,b))
array([[[1, 2],
        [2, 3],
        [3, 4]]])
 >>> a = np.array([[1],[2],[3]])
>>> b = np.array([[2],[3],[4]])
>>> np.dstack((a,b))
array([[[1, 2]],
       [[2, 3]],
       [[3, 4]]])


numpy.ma.ediff1d   ma.ediff1d(arr, to_end=None, to_begin=None)[source]

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.


numpy.ma.empty   ma.empty(shape, dtype=float, order='C', *, like=None) = <numpy.ma.core._convert2ma object>

Return a new array of given shape and type, without initializing entries.  Parameters

shapeint or tuple of int

Shape of the empty array, e.g., (2, 3) or 2.
dtypedata-type, optional

Desired output data-type for the array, e.g, numpy.int8. Default is numpy.float64.
order{‘C’, ‘F’}, optional, default: ‘C’

Whether to store multi-dimensional data in row-major (C-style) or column-major (Fortran-style) order in memory.
likearray_like

Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.  New in version 1.20.0.     Returns

outMaskedArray

Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.      See also  empty_like

Return an empty array with shape and type of input.  ones

Return a new array setting values to one.  zeros

Return a new array setting values to zero.  full

Return a new array of given shape filled with value.    Notes empty, unlike zeros, does not set the array values to zero, and may therefore be marginally faster. On the other hand, it requires the user to manually set all the values in the array, and should be used with caution. Examples >>> np.empty([2, 2])
array([[ -9.74499359e+001,   6.69583040e-309],
       [  2.13182611e-314,   3.06959433e-309]])         #uninitialized
 >>> np.empty([2, 2], dtype=int)
array([[-1073741821, -1067949133],
       [  496041986,    19249760]])                     #uninitialized


numpy.ma.empty_like   ma.empty_like(prototype, dtype=None, order='K', subok=True, shape=None) = <numpy.ma.core._convert2ma object>

Return a new array with the same shape and type as a given array.  Parameters

prototypearray_like

The shape and data-type of prototype define these same attributes of the returned array.
dtypedata-type, optional

Overrides the data type of the result.  New in version 1.6.0.
order{‘C’, ‘F’, ‘A’, or ‘K’}, optional

Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if prototype is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of prototype as closely as possible.  New in version 1.6.0.
subokbool, optional.

If True, then the newly created array will use the sub-class type of prototype, otherwise it will be a base-class array. Defaults to True.
shapeint or sequence of ints, optional.

Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.  New in version 1.17.0.     Returns

outMaskedArray

Array of uninitialized (arbitrary) data with the same shape and type as prototype.      See also  ones_like

Return an array of ones with shape and type of input.  zeros_like

Return an array of zeros with shape and type of input.  full_like

Return a new array with shape of input filled with value.  empty

Return a new uninitialized array.    Notes This function does not initialize the returned array; to do that use zeros_like or ones_like instead. It may be marginally faster than the functions that do set the array values. Examples >>> a = ([1,2,3], [4,5,6])                         # a is array-like
>>> np.empty_like(a)
array([[-1073741821, -1073741821,           3],    # uninitialized
       [          0,           0, -1073741821]])
>>> a = np.array([[1., 2., 3.],[4.,5.,6.]])
>>> np.empty_like(a)
array([[ -2.00000715e+000,   1.48219694e-323,  -2.00000572e+000], # uninitialized
       [  4.38791518e-305,  -2.00000715e+000,   4.17269252e-309]])


numpy.ma.expand_dims   ma.expand_dims(a, axis)[source]

Expand the shape of an array. Insert a new axis that will appear at the axis position in the expanded array shape.  Parameters

aarray_like

Input array.
axisint or tuple of ints

Position in the expanded axes where the new axis (or axes) is placed.  Deprecated since version 1.13.0: Passing an axis where axis > a.ndim will be treated as axis == a.ndim, and passing axis < -a.ndim - 1 will be treated as axis == 0. This behavior is deprecated.   Changed in version 1.18.0: A tuple of axes is now supported. Out of range axes as described above are now forbidden and raise an AxisError.     Returns

resultndarray

View of a with the number of dimensions increased.      See also  squeeze

The inverse operation, removing singleton dimensions  reshape

Insert, remove, and combine dimensions, and resize existing ones
doc.indexing, atleast_1d, atleast_2d, atleast_3d

  Examples >>> x = np.array([1, 2])
>>> x.shape
(2,)
 The following is equivalent to x[np.newaxis, :] or x[np.newaxis]: >>> y = np.expand_dims(x, axis=0)
>>> y
array([[1, 2]])
>>> y.shape
(1, 2)
 The following is equivalent to x[:, np.newaxis]: >>> y = np.expand_dims(x, axis=1)
>>> y
array([[1],
       [2]])
>>> y.shape
(2, 1)
 axis may also be a tuple: >>> y = np.expand_dims(x, axis=(0, 1))
>>> y
array([[[1, 2]]])
 >>> y = np.expand_dims(x, axis=(2, 0))
>>> y
array([[[1],
        [2]]])
 Note that some examples may use None instead of np.newaxis. These are the same objects: >>> np.newaxis is None
True


numpy.ma.filled   ma.filled(a, fill_value=None)[source]

Return input as an array with masked data replaced by a fill value. If a is not a MaskedArray, a itself is returned. If a is a MaskedArray and fill_value is None, fill_value is set to a.fill_value.  Parameters

aMaskedArray or array_like

An input object.
fill_valuearray_like, optional.

Can be scalar or non-scalar. If non-scalar, the resulting filled array should be broadcastable over input array. Default is None.    Returns

andarray

The filled array.      See also  compressed
  Examples >>> x = np.ma.array(np.arange(9).reshape(3, 3), mask=[[1, 0, 0],
...                                                   [1, 0, 0],
...                                                   [0, 0, 0]])
>>> x.filled()
array([[999999,      1,      2],
       [999999,      4,      5],
       [     6,      7,      8]])
>>> x.filled(fill_value=333)
array([[333,   1,   2],
       [333,   4,   5],
       [  6,   7,   8]])
>>> x.filled(fill_value=np.arange(3))
array([[0, 1, 2],
       [0, 4, 5],
       [6, 7, 8]])


numpy.ma.fix_invalid   ma.fix_invalid(a, mask=False, copy=True, fill_value=None)[source]

Return input with invalid data masked and replaced by a fill value. Invalid data means values of nan, inf, etc.  Parameters

aarray_like

Input array, a (subclass of) ndarray.
masksequence, optional

Mask. Must be convertible to an array of booleans with the same shape as data. True indicates a masked (i.e. invalid) data.
copybool, optional

Whether to use a copy of a (True) or to fix a in place (False). Default is True.
fill_valuescalar, optional

Value used for fixing invalid data. Default is None, in which case the a.fill_value is used.    Returns

bMaskedArray

The input array with invalid entries fixed.     Notes A copy is performed by default. Examples >>> x = np.ma.array([1., -1, np.nan, np.inf], mask=[1] + [0]*3)
>>> x
masked_array(data=[--, -1.0, nan, inf],
             mask=[ True, False, False, False],
       fill_value=1e+20)
>>> np.ma.fix_invalid(x)
masked_array(data=[--, -1.0, --, --],
             mask=[ True, False,  True,  True],
       fill_value=1e+20)
 >>> fixed = np.ma.fix_invalid(x)
>>> fixed.data
array([ 1.e+00, -1.e+00,  1.e+20,  1.e+20])
>>> x.data
array([ 1., -1., nan, inf])


numpy.ma.flatnotmasked_contiguous   ma.flatnotmasked_contiguous(a)[source]

Find contiguous unmasked data in a masked array along the given axis.  Parameters

anarray

The input array.    Returns

slice_listlist

A sorted sequence of slice objects (start index, end index).  Changed in version 1.15.0: Now returns an empty list instead of None for a fully masked array       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
>>> np.ma.flatnotmasked_contiguous(a)
[]


numpy.ma.flatnotmasked_edges   ma.flatnotmasked_edges(a)[source]

Find the indices of the first and last unmasked values. Expects a 1-D MaskedArray, returns None if all values are masked.  Parameters

aarray_like

Input 1-D MaskedArray    Returns

edgesndarray 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)
>>> np.ma.flatnotmasked_edges(a)
array([0, 9])
 >>> 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_edges(a)
array([3, 8])
 >>> a[:] = np.ma.masked
>>> print(np.ma.flatnotmasked_edges(a))
None


numpy.ma.frombuffer   ma.frombuffer(buffer, dtype=float, count=- 1, offset=0, *, like=None) = <numpy.ma.core._convert2ma object>

Interpret a buffer as a 1-dimensional array.  Parameters

bufferbuffer_like

An object that exposes the buffer interface.
dtypedata-type, optional

Data-type of the returned array; default: float.
countint, optional

Number of items to read. -1 means all data in the buffer.
offsetint, optional

Start reading the buffer from this offset (in bytes); default: 0.
likearray_like

Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.  New in version 1.20.0.     Returns
 out: MaskedArray
   Notes If the buffer has data that is not in machine byte-order, this should be specified as part of the data-type, e.g.: >>> dt = np.dtype(int)
>>> dt = dt.newbyteorder('>')
>>> np.frombuffer(buf, dtype=dt)
 The data of the resulting array will not be byteswapped, but will be interpreted correctly. Examples >>> s = b'hello world'
>>> np.frombuffer(s, dtype='S1', count=5, offset=6)
array([b'w', b'o', b'r', b'l', b'd'], dtype='|S1')
 >>> np.frombuffer(b'\x01\x02', dtype=np.uint8)
array([1, 2], dtype=uint8)
>>> np.frombuffer(b'\x01\x02\x03\x04\x05', dtype=np.uint8, count=3)
array([1, 2, 3], dtype=uint8)


numpy.ma.fromfunction   ma.fromfunction(function, shape, **dtype) = <numpy.ma.core._convert2ma object>

Construct an array by executing a function over each coordinate. The resulting array therefore has a value fn(x, y, z) at coordinate (x, y, z).  Parameters

functioncallable

The function is called with N parameters, where N is the rank of shape. Each parameter represents the coordinates of the array varying along a specific axis. For example, if shape were (2, 2), then the parameters would be array([[0, 0], [1, 1]]) and array([[0, 1], [0, 1]])
shape(N,) tuple of ints

Shape of the output array, which also determines the shape of the coordinate arrays passed to function.
dtypedata-type, optional

Data-type of the coordinate arrays passed to function. By default, dtype is float.
likearray_like

Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.  New in version 1.20.0.     Returns
 fromfunction: MaskedArray

The result of the call to function is passed back directly. Therefore the shape of fromfunction is completely determined by function. If function returns a scalar value, the shape of fromfunction would not match the shape parameter.      See also
indices, meshgrid

  Notes Keywords other than dtype are passed to function. Examples >>> np.fromfunction(lambda i, j: i == j, (3, 3), dtype=int)
array([[ True, False, False],
       [False,  True, False],
       [False, False,  True]])
 >>> np.fromfunction(lambda i, j: i + j, (3, 3), dtype=int)
array([[0, 1, 2],
       [1, 2, 3],
       [2, 3, 4]])


numpy.ma.getdata   ma.getdata(a, subok=True)[source]

Return the data of a masked array as an ndarray. Return the data of a (if any) as an ndarray if a is a MaskedArray, else return a as a ndarray or subclass (depending on subok) if not.  Parameters

aarray_like

Input MaskedArray, alternatively a ndarray or a subclass thereof.
subokbool

Whether to force the output to be a pure ndarray (False) or to return a subclass of ndarray if appropriate (True, default).      See also  getmask

Return the mask of a masked array, or nomask.  getmaskarray

Return the mask of a masked array, or full array of False.    Examples >>> import numpy.ma as ma
>>> a = ma.masked_equal([[1,2],[3,4]], 2)
>>> a
masked_array(
  data=[[1, --],
        [3, 4]],
  mask=[[False,  True],
        [False, False]],
  fill_value=2)
>>> ma.getdata(a)
array([[1, 2],
       [3, 4]])
 Equivalently use the MaskedArray data attribute. >>> a.data
array([[1, 2],
       [3, 4]])


numpy.ma.getmask   ma.getmask(a)[source]

Return the mask of a masked array, or nomask. Return the mask of a as an ndarray if a is a MaskedArray and the mask is not nomask, else return nomask. To guarantee a full array of booleans of the same shape as a, use getmaskarray.  Parameters

aarray_like

Input MaskedArray for which the mask is required.      See also  getdata

Return the data of a masked array as an ndarray.  getmaskarray

Return the mask of a masked array, or full array of False.    Examples >>> import numpy.ma as ma
>>> a = ma.masked_equal([[1,2],[3,4]], 2)
>>> a
masked_array(
  data=[[1, --],
        [3, 4]],
  mask=[[False,  True],
        [False, False]],
  fill_value=2)
>>> ma.getmask(a)
array([[False,  True],
       [False, False]])
 Equivalently use the MaskedArray mask attribute. >>> a.mask
array([[False,  True],
       [False, False]])
 Result when mask == nomask >>> b = ma.masked_array([[1,2],[3,4]])
>>> b
masked_array(
  data=[[1, 2],
        [3, 4]],
  mask=False,
  fill_value=999999)
>>> ma.nomask
False
>>> ma.getmask(b) == ma.nomask
True
>>> b.mask == ma.nomask
True


numpy.ma.getmaskarray   ma.getmaskarray(arr)[source]

Return the mask of a masked array, or full boolean array of False. Return the mask of arr as an ndarray if arr is a MaskedArray and the mask is not nomask, else return a full boolean array of False of the same shape as arr.  Parameters

arrarray_like

Input MaskedArray for which the mask is required.      See also  getmask

Return the mask of a masked array, or nomask.  getdata

Return the data of a masked array as an ndarray.    Examples >>> import numpy.ma as ma
>>> a = ma.masked_equal([[1,2],[3,4]], 2)
>>> a
masked_array(
  data=[[1, --],
        [3, 4]],
  mask=[[False,  True],
        [False, False]],
  fill_value=2)
>>> ma.getmaskarray(a)
array([[False,  True],
       [False, False]])
 Result when mask == nomask >>> b = ma.masked_array([[1,2],[3,4]])
>>> b
masked_array(
  data=[[1, 2],
        [3, 4]],
  mask=False,
  fill_value=999999)
>>> ma.getmaskarray(b)
array([[False, False],
       [False, False]])


numpy.ma.harden_mask   ma.harden_mask(self) = <numpy.ma.core._frommethod object>

Force the mask to hard. Whether the mask of a masked array is hard or soft is determined by its hardmask property. harden_mask sets hardmask to True.  See also  ma.MaskedArray.hardmask


numpy.ma.hsplit   ma.hsplit(*args, **kwargs) = <numpy.ma.extras._fromnxfunction_single object>

Split an array into multiple sub-arrays horizontally (column-wise). Please refer to the split documentation. hsplit is equivalent to split with axis=1, the array is always split along the second axis regardless of the array dimension.  See also  split

Split an array into multiple sub-arrays of equal size.    Notes The function is applied to both the _data and the _mask, if any. Examples >>> x = np.arange(16.0).reshape(4, 4)
>>> x
array([[ 0.,   1.,   2.,   3.],
       [ 4.,   5.,   6.,   7.],
       [ 8.,   9.,  10.,  11.],
       [12.,  13.,  14.,  15.]])
>>> np.hsplit(x, 2)
[array([[  0.,   1.],
       [  4.,   5.],
       [  8.,   9.],
       [12.,  13.]]),
 array([[  2.,   3.],
       [  6.,   7.],
       [10.,  11.],
       [14.,  15.]])]
>>> np.hsplit(x, np.array([3, 6]))
[array([[ 0.,   1.,   2.],
       [ 4.,   5.,   6.],
       [ 8.,   9.,  10.],
       [12.,  13.,  14.]]),
 array([[ 3.],
       [ 7.],
       [11.],
       [15.]]),
 array([], shape=(4, 0), dtype=float64)]
 With a higher dimensional array the split is still along the second axis. >>> x = np.arange(8.0).reshape(2, 2, 2)
>>> x
array([[[0.,  1.],
        [2.,  3.]],
       [[4.,  5.],
        [6.,  7.]]])
>>> np.hsplit(x, 2)
[array([[[0.,  1.]],
       [[4.,  5.]]]),
 array([[[2.,  3.]],
       [[6.,  7.]]])]


numpy.ma.hstack   ma.hstack(*args, **kwargs) = <numpy.ma.extras._fromnxfunction_seq object>

Stack arrays in sequence horizontally (column wise). This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis. Rebuilds arrays divided by hsplit. This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.  Parameters

tupsequence of ndarrays

The arrays must have the same shape along all but the second axis, except 1-D arrays which can be any length.    Returns

stackedndarray

The array formed by stacking the given arrays.      See also  concatenate

Join a sequence of arrays along an existing axis.  stack

Join a sequence of arrays along a new axis.  block

Assemble an nd-array from nested lists of blocks.  vstack

Stack arrays in sequence vertically (row wise).  dstack

Stack arrays in sequence depth wise (along third axis).  column_stack

Stack 1-D arrays as columns into a 2-D array.  hsplit

Split an array into multiple sub-arrays horizontally (column-wise).    Notes The function is applied to both the _data and the _mask, if any. Examples >>> a = np.array((1,2,3))
>>> b = np.array((4,5,6))
>>> np.hstack((a,b))
array([1, 2, 3, 4, 5, 6])
>>> a = np.array([[1],[2],[3]])
>>> b = np.array([[4],[5],[6]])
>>> np.hstack((a,b))
array([[1, 4],
       [2, 5],
       [3, 6]])


numpy.ma.identity   ma.identity(n, dtype=None) = <numpy.ma.core._convert2ma object>

Return the identity array. The identity array is a square array with ones on the main diagonal.  Parameters

nint

Number of rows (and columns) in n x n output.
dtypedata-type, optional

Data-type of the output. Defaults to float.
likearray_like

Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.  New in version 1.20.0.     Returns

outMaskedArray

n x n array with its main diagonal set to one, and all other elements 0.     Examples >>> np.identity(3)
array([[1.,  0.,  0.],
       [0.,  1.,  0.],
       [0.,  0.,  1.]])


numpy.ma.indices   ma.indices(dimensions, dtype=<class 'int'>, sparse=False) = <numpy.ma.core._convert2ma object>

Return an array representing the indices of a grid. Compute an array where the subarrays contain index values 0, 1, … varying only along the corresponding axis.  Parameters

dimensionssequence of ints

The shape of the grid.
dtypedtype, optional

Data type of the result.
sparseboolean, optional

Return a sparse representation of the grid instead of a dense representation. Default is False.  New in version 1.17.     Returns

gridone MaskedArray or tuple of MaskedArrays

 If sparse is False:

Returns one array of grid indices, grid.shape = (len(dimensions),) + tuple(dimensions).  If sparse is True:

Returns a tuple of arrays, with grid[i].shape = (1, ..., 1, dimensions[i], 1, ..., 1) with dimensions[i] in the ith place        See also
mgrid, ogrid, meshgrid

  Notes The output shape in the dense case is obtained by prepending the number of dimensions in front of the tuple of dimensions, i.e. if dimensions is a tuple (r0, ..., rN-1) of length N, the output shape is (N, r0, ..., rN-1). The subarrays grid[k] contains the N-D array of indices along the k-th axis. Explicitly: grid[k, i0, i1, ..., iN-1] = ik
 Examples >>> grid = np.indices((2, 3))
>>> grid.shape
(2, 2, 3)
>>> grid[0]        # row indices
array([[0, 0, 0],
       [1, 1, 1]])
>>> grid[1]        # column indices
array([[0, 1, 2],
       [0, 1, 2]])
 The indices can be used as an index into an array. >>> x = np.arange(20).reshape(5, 4)
>>> row, col = np.indices((2, 3))
>>> x[row, col]
array([[0, 1, 2],
       [4, 5, 6]])
 Note that it would be more straightforward in the above example to extract the required elements directly with x[:2, :3]. If sparse is set to true, the grid will be returned in a sparse representation. >>> i, j = np.indices((2, 3), sparse=True)
>>> i.shape
(2, 1)
>>> j.shape
(1, 3)
>>> i        # row indices
array([[0],
       [1]])
>>> j        # column indices
array([[0, 1, 2]])


numpy.ma.inner   ma.inner(a, b, /)[source]

Inner product of two arrays. Ordinary inner product of vectors for 1-D arrays (without complex conjugation), in higher dimensions a sum product over the last axes.  Parameters

a, barray_like

If a and b are nonscalar, their last dimensions must match.    Returns

outndarray

If a and b are both scalars or both 1-D arrays then a scalar is returned; otherwise an array is returned. out.shape = (*a.shape[:-1], *b.shape[:-1])    Raises
 ValueError

If both a and b are nonscalar and their last dimensions have different sizes.      See also  tensordot

Sum products over arbitrary axes.  dot

Generalised matrix product, using second last dimension of b.  einsum

Einstein summation convention.    Notes Masked values are replaced by 0. For vectors (1-D arrays) it computes the ordinary inner-product: np.inner(a, b) = sum(a[:]*b[:])
 More generally, if ndim(a) = r > 0 and ndim(b) = s > 0: np.inner(a, b) = np.tensordot(a, b, axes=(-1,-1))
 or explicitly: np.inner(a, b)[i0,...,ir-2,j0,...,js-2]
     = sum(a[i0,...,ir-2,:]*b[j0,...,js-2,:])
 In addition a or b may be scalars, in which case: np.inner(a,b) = a*b
 Examples Ordinary inner product for vectors: >>> a = np.array([1,2,3])
>>> b = np.array([0,1,0])
>>> np.inner(a, b)
2
 Some multidimensional examples: >>> a = np.arange(24).reshape((2,3,4))
>>> b = np.arange(4)
>>> c = np.inner(a, b)
>>> c.shape
(2, 3)
>>> c
array([[ 14,  38,  62],
       [ 86, 110, 134]])
 >>> a = np.arange(2).reshape((1,1,2))
>>> b = np.arange(6).reshape((3,2))
>>> c = np.inner(a, b)
>>> c.shape
(1, 1, 3)
>>> c
array([[[1, 3, 5]]])
 An example where b is a scalar: >>> np.inner(np.eye(2), 7)
array([[7., 0.],
       [0., 7.]])


numpy.ma.innerproduct   ma.innerproduct(a, b, /)[source]

Inner product of two arrays. Ordinary inner product of vectors for 1-D arrays (without complex conjugation), in higher dimensions a sum product over the last axes.  Parameters

a, barray_like

If a and b are nonscalar, their last dimensions must match.    Returns

outndarray

If a and b are both scalars or both 1-D arrays then a scalar is returned; otherwise an array is returned. out.shape = (*a.shape[:-1], *b.shape[:-1])    Raises
 ValueError

If both a and b are nonscalar and their last dimensions have different sizes.      See also  tensordot

Sum products over arbitrary axes.  dot

Generalised matrix product, using second last dimension of b.  einsum

Einstein summation convention.    Notes Masked values are replaced by 0. For vectors (1-D arrays) it computes the ordinary inner-product: np.inner(a, b) = sum(a[:]*b[:])
 More generally, if ndim(a) = r > 0 and ndim(b) = s > 0: np.inner(a, b) = np.tensordot(a, b, axes=(-1,-1))
 or explicitly: np.inner(a, b)[i0,...,ir-2,j0,...,js-2]
     = sum(a[i0,...,ir-2,:]*b[j0,...,js-2,:])
 In addition a or b may be scalars, in which case: np.inner(a,b) = a*b
 Examples Ordinary inner product for vectors: >>> a = np.array([1,2,3])
>>> b = np.array([0,1,0])
>>> np.inner(a, b)
2
 Some multidimensional examples: >>> a = np.arange(24).reshape((2,3,4))
>>> b = np.arange(4)
>>> c = np.inner(a, b)
>>> c.shape
(2, 3)
>>> c
array([[ 14,  38,  62],
       [ 86, 110, 134]])
 >>> a = np.arange(2).reshape((1,1,2))
>>> b = np.arange(6).reshape((3,2))
>>> c = np.inner(a, b)
>>> c.shape
(1, 1, 3)
>>> c
array([[[1, 3, 5]]])
 An example where b is a scalar: >>> np.inner(np.eye(2), 7)
array([[7., 0.],
       [0., 7.]])


numpy.ma.is_mask   ma.is_mask(m)[source]

Return True if m is a valid, standard mask. This function does not check the contents of the input, only that the type is MaskType. In particular, this function returns False if the mask has a flexible dtype.  Parameters

marray_like

Array to test.    Returns

resultbool

True if m.dtype.type is MaskType, False otherwise.      See also  ma.isMaskedArray

Test whether input is an instance of MaskedArray.    Examples >>> import numpy.ma as ma
>>> m = ma.masked_equal([0, 1, 0, 2, 3], 0)
>>> m
masked_array(data=[--, 1, --, 2, 3],
             mask=[ True, False,  True, False, False],
       fill_value=0)
>>> ma.is_mask(m)
False
>>> ma.is_mask(m.mask)
True
 Input must be an ndarray (or have similar attributes) for it to be considered a valid mask. >>> m = [False, True, False]
>>> ma.is_mask(m)
False
>>> m = np.array([False, True, False])
>>> m
array([False,  True, False])
>>> ma.is_mask(m)
True
 Arrays with complex dtypes don’t return True. >>> dtype = np.dtype({'names':['monty', 'pithon'],
...                   'formats':[bool, bool]})
>>> dtype
dtype([('monty', '|b1'), ('pithon', '|b1')])
>>> m = np.array([(True, False), (False, True), (True, False)],
...              dtype=dtype)
>>> m
array([( True, False), (False,  True), ( True, False)],
      dtype=[('monty', '?'), ('pithon', '?')])
>>> ma.is_mask(m)
False


numpy.ma.is_masked   ma.is_masked(x)[source]

Determine whether input has masked values. Accepts any object as input, but always returns False unless the input is a MaskedArray containing masked values.  Parameters

xarray_like

Array to check for masked values.    Returns

resultbool

True if x is a MaskedArray with masked values, False otherwise.     Examples >>> import numpy.ma as ma
>>> x = ma.masked_equal([0, 1, 0, 2, 3], 0)
>>> x
masked_array(data=[--, 1, --, 2, 3],
             mask=[ True, False,  True, False, False],
       fill_value=0)
>>> ma.is_masked(x)
True
>>> x = ma.masked_equal([0, 1, 0, 2, 3], 42)
>>> x
masked_array(data=[0, 1, 0, 2, 3],
             mask=False,
       fill_value=42)
>>> ma.is_masked(x)
False
 Always returns False if x isn’t a MaskedArray. >>> x = [False, True, False]
>>> ma.is_masked(x)
False
>>> x = 'a string'
>>> ma.is_masked(x)
False


numpy.ma.isarray   ma.isarray(x)[source]

Test whether input is an instance of MaskedArray. This function returns True if x is an instance of MaskedArray and returns False otherwise. Any object is accepted as input.  Parameters

xobject

Object to test.    Returns

resultbool

True if x is a MaskedArray.      See also  isMA

Alias to isMaskedArray.  isarray

Alias to isMaskedArray.    Examples >>> import numpy.ma as ma
>>> a = np.eye(3, 3)
>>> a
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.]])
>>> m = ma.masked_values(a, 0)
>>> m
masked_array(
  data=[[1.0, --, --],
        [--, 1.0, --],
        [--, --, 1.0]],
  mask=[[False,  True,  True],
        [ True, False,  True],
        [ True,  True, False]],
  fill_value=0.0)
>>> ma.isMaskedArray(a)
False
>>> ma.isMaskedArray(m)
True
>>> ma.isMaskedArray([0, 1, 2])
False


numpy.ma.isMA   ma.isMA(x)[source]

Test whether input is an instance of MaskedArray. This function returns True if x is an instance of MaskedArray and returns False otherwise. Any object is accepted as input.  Parameters

xobject

Object to test.    Returns

resultbool

True if x is a MaskedArray.      See also  isMA

Alias to isMaskedArray.  isarray

Alias to isMaskedArray.    Examples >>> import numpy.ma as ma
>>> a = np.eye(3, 3)
>>> a
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.]])
>>> m = ma.masked_values(a, 0)
>>> m
masked_array(
  data=[[1.0, --, --],
        [--, 1.0, --],
        [--, --, 1.0]],
  mask=[[False,  True,  True],
        [ True, False,  True],
        [ True,  True, False]],
  fill_value=0.0)
>>> ma.isMaskedArray(a)
False
>>> ma.isMaskedArray(m)
True
>>> ma.isMaskedArray([0, 1, 2])
False


numpy.ma.isMaskedArray   ma.isMaskedArray(x)[source]

Test whether input is an instance of MaskedArray. This function returns True if x is an instance of MaskedArray and returns False otherwise. Any object is accepted as input.  Parameters

xobject

Object to test.    Returns

resultbool

True if x is a MaskedArray.      See also  isMA

Alias to isMaskedArray.  isarray

Alias to isMaskedArray.    Examples >>> import numpy.ma as ma
>>> a = np.eye(3, 3)
>>> a
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.]])
>>> m = ma.masked_values(a, 0)
>>> m
masked_array(
  data=[[1.0, --, --],
        [--, 1.0, --],
        [--, --, 1.0]],
  mask=[[False,  True,  True],
        [ True, False,  True],
        [ True,  True, False]],
  fill_value=0.0)
>>> ma.isMaskedArray(a)
False
>>> ma.isMaskedArray(m)
True
>>> ma.isMaskedArray([0, 1, 2])
False


numpy.ma.make_mask   ma.make_mask(m, copy=False, shrink=True, dtype=<class 'numpy.bool_'>)[source]

Create a boolean mask from an array. Return m as a boolean mask, creating a copy if necessary or requested. The function can accept any sequence that is convertible to integers, or nomask. Does not require that contents must be 0s and 1s, values of 0 are interpreted as False, everything else as True.  Parameters

marray_like

Potential mask.
copybool, optional

Whether to return a copy of m (True) or m itself (False).
shrinkbool, optional

Whether to shrink m to nomask if all its values are False.
dtypedtype, optional

Data-type of the output mask. By default, the output mask has a dtype of MaskType (bool). If the dtype is flexible, each field has a boolean dtype. This is ignored when m is nomask, in which case nomask is always returned.    Returns

resultndarray

A boolean mask derived from m.     Examples >>> import numpy.ma as ma
>>> m = [True, False, True, True]
>>> ma.make_mask(m)
array([ True, False,  True,  True])
>>> m = [1, 0, 1, 1]
>>> ma.make_mask(m)
array([ True, False,  True,  True])
>>> m = [1, 0, 2, -3]
>>> ma.make_mask(m)
array([ True, False,  True,  True])
 Effect of the shrink parameter. >>> m = np.zeros(4)
>>> m
array([0., 0., 0., 0.])
>>> ma.make_mask(m)
False
>>> ma.make_mask(m, shrink=False)
array([False, False, False, False])
 Using a flexible dtype. >>> m = [1, 0, 1, 1]
>>> n = [0, 1, 0, 0]
>>> arr = []
>>> for man, mouse in zip(m, n):
...     arr.append((man, mouse))
>>> arr
[(1, 0), (0, 1), (1, 0), (1, 0)]
>>> dtype = np.dtype({'names':['man', 'mouse'],
...                   'formats':[np.int64, np.int64]})
>>> arr = np.array(arr, dtype=dtype)
>>> arr
array([(1, 0), (0, 1), (1, 0), (1, 0)],
      dtype=[('man', '<i8'), ('mouse', '<i8')])
>>> ma.make_mask(arr, dtype=dtype)
array([(True, False), (False, True), (True, False), (True, False)],
      dtype=[('man', '|b1'), ('mouse', '|b1')])


numpy.ma.make_mask_descr   ma.make_mask_descr(ndtype)[source]

Construct a dtype description list from a given dtype. Returns a new dtype object, with the type of all fields in ndtype to a boolean type. Field names are not altered.  Parameters

ndtypedtype

The dtype to convert.    Returns

resultdtype

A dtype that looks like ndtype, the type of all fields is boolean.     Examples >>> import numpy.ma as ma
>>> dtype = np.dtype({'names':['foo', 'bar'],
...                   'formats':[np.float32, np.int64]})
>>> dtype
dtype([('foo', '<f4'), ('bar', '<i8')])
>>> ma.make_mask_descr(dtype)
dtype([('foo', '|b1'), ('bar', '|b1')])
>>> ma.make_mask_descr(np.float32)
dtype('bool')


numpy.ma.make_mask_none   ma.make_mask_none(newshape, dtype=None)[source]

Return a boolean mask of the given shape, filled with False. This function returns a boolean ndarray with all entries False, that can be used in common mask manipulations. If a complex dtype is specified, the type of each field is converted to a boolean type.  Parameters

newshapetuple

A tuple indicating the shape of the mask.
dtype{None, dtype}, optional

If None, use a MaskType instance. Otherwise, use a new datatype with the same fields as dtype, converted to boolean types.    Returns

resultndarray

An ndarray of appropriate shape and dtype, filled with False.      See also  make_mask

Create a boolean mask from an array.  make_mask_descr

Construct a dtype description list from a given dtype.    Examples >>> import numpy.ma as ma
>>> ma.make_mask_none((3,))
array([False, False, False])
 Defining a more complex dtype. >>> dtype = np.dtype({'names':['foo', 'bar'],
...                   'formats':[np.float32, np.int64]})
>>> dtype
dtype([('foo', '<f4'), ('bar', '<i8')])
>>> ma.make_mask_none((3,), dtype=dtype)
array([(False, False), (False, False), (False, False)],
      dtype=[('foo', '|b1'), ('bar', '|b1')])


numpy.ma.mask_cols   ma.mask_cols(a, axis=<no value>)[source]

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=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=1)
>>> 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=1)


numpy.ma.mask_or   ma.mask_or(m1, m2, copy=False, shrink=True)[source]

Combine two masks with the logical_or operator. The result may be a view on m1 or m2 if the other is nomask (i.e. False).  Parameters

m1, m2array_like

Input masks.
copybool, optional

If copy is False and one of the inputs is nomask, return a view of the other input mask. Defaults to False.
shrinkbool, optional

Whether to shrink the output to nomask if all its values are False. Defaults to True.    Returns

maskoutput mask

The result masks values that are masked in either m1 or m2.    Raises
 ValueError

If m1 and m2 have different flexible dtypes.     Examples >>> m1 = np.ma.make_mask([0, 1, 1, 0])
>>> m2 = np.ma.make_mask([1, 0, 0, 0])
>>> np.ma.mask_or(m1, m2)
array([ True,  True,  True, False])


numpy.ma.mask_rowcols   ma.mask_rowcols(a, axis=None)[source]

Mask rows and/or columns of a 2D array that contain masked values. Mask whole rows and/or columns of a 2D array that contain masked values. The masking behavior is selected using the axis parameter.  If axis is None, rows and columns are masked. If axis is 0, only rows are masked. If axis is 1 or -1, only columns are masked.   Parameters

aarray_like, MaskedArray

The array to mask. If not a MaskedArray instance (or if no array elements are masked). The result is a MaskedArray with mask set to nomask (False). Must be a 2D array.
axisint, optional

Axis along which to perform the operation. If None, applies to a flattened version of the array.    Returns

aMaskedArray

A modified version of the input array, masked depending on the value of the axis parameter.    Raises
 NotImplementedError

If input array a is not 2D.      See also  mask_rows

Mask rows of a 2D array that contain masked values.  mask_cols

Mask cols of a 2D array that contain masked values.  masked_where

Mask where a condition is met.    Notes The input array’s mask is modified by this function. Examples >>> import numpy.ma as ma
>>> a = np.zeros((3, 3), dtype=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=1)
>>> ma.mask_rowcols(a)
masked_array(
  data=[[0, --, 0],
        [--, --, --],
        [0, --, 0]],
  mask=[[False,  True, False],
        [ True,  True,  True],
        [False,  True, False]],
  fill_value=1)


numpy.ma.mask_rows   ma.mask_rows(a, axis=<no value>)[source]

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=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=1)
 >>> 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=1)


numpy.ma.masked_all   ma.masked_all(shape, dtype=<class 'float'>)[source]

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

shapetuple

Shape of the required MaskedArray.
dtypedtype, optional

Data type of the output.    Returns

aMaskedArray

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')


numpy.ma.masked_all_like   ma.masked_all_like(arr)[source]

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

arrndarray

An array describing the shape and dtype of the required MaskedArray.    Returns

aMaskedArray

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,
  dtype=float32)
 The dtype of the masked array matches the dtype of arr. >>> arr.dtype
dtype('float32')
>>> ma.masked_all_like(arr).dtype
dtype('float32')


numpy.ma.masked_equal   ma.masked_equal(x, value, copy=True)[source]

Mask an array where equal to a given value. This function is a shortcut to masked_where, with condition = (x == value). For floating point arrays, consider using masked_values(x, value).  See also  masked_where

Mask where a condition is met.  masked_values

Mask using floating point equality.    Examples >>> import numpy.ma as ma
>>> a = np.arange(4)
>>> a
array([0, 1, 2, 3])
>>> ma.masked_equal(a, 2)
masked_array(data=[0, 1, --, 3],
             mask=[False, False,  True, False],
       fill_value=2)


numpy.ma.masked_greater   ma.masked_greater(x, value, copy=True)[source]

Mask an array where greater than a given value. This function is a shortcut to masked_where, with condition = (x > value).  See also  masked_where

Mask where a condition is met.    Examples >>> import numpy.ma as ma
>>> a = np.arange(4)
>>> a
array([0, 1, 2, 3])
>>> ma.masked_greater(a, 2)
masked_array(data=[0, 1, 2, --],
             mask=[False, False, False,  True],
       fill_value=999999)


numpy.ma.masked_greater_equal   ma.masked_greater_equal(x, value, copy=True)[source]

Mask an array where greater than or equal to a given value. This function is a shortcut to masked_where, with condition = (x >= value).  See also  masked_where

Mask where a condition is met.    Examples >>> import numpy.ma as ma
>>> a = np.arange(4)
>>> a
array([0, 1, 2, 3])
>>> ma.masked_greater_equal(a, 2)
masked_array(data=[0, 1, --, --],
             mask=[False, False,  True,  True],
       fill_value=999999)


numpy.ma.masked_inside   ma.masked_inside(x, v1, v2, copy=True)[source]

Mask an array inside a given interval. Shortcut to masked_where, where condition is True for x inside the interval [v1,v2] (v1 <= x <= v2). The boundaries v1 and v2 can be given in either order.  See also  masked_where

Mask where a condition is met.    Notes The array x is prefilled with its filling value. Examples >>> import numpy.ma as ma
>>> x = [0.31, 1.2, 0.01, 0.2, -0.4, -1.1]
>>> ma.masked_inside(x, -0.3, 0.3)
masked_array(data=[0.31, 1.2, --, --, -0.4, -1.1],
             mask=[False, False,  True,  True, False, False],
       fill_value=1e+20)
 The order of v1 and v2 doesn’t matter. >>> ma.masked_inside(x, 0.3, -0.3)
masked_array(data=[0.31, 1.2, --, --, -0.4, -1.1],
             mask=[False, False,  True,  True, False, False],
       fill_value=1e+20)


numpy.ma.masked_invalid   ma.masked_invalid(a, copy=True)[source]

Mask an array where invalid values occur (NaNs or infs). This function is a shortcut to masked_where, with condition = ~(np.isfinite(a)). Any pre-existing mask is conserved. Only applies to arrays with a dtype where NaNs or infs make sense (i.e. floating point types), but accepts any array_like object.  See also  masked_where

Mask where a condition is met.    Examples >>> import numpy.ma as ma
>>> a = np.arange(5, dtype=float)
>>> a[2] = np.NaN
>>> a[3] = np.PINF
>>> a
array([ 0.,  1., nan, inf,  4.])
>>> ma.masked_invalid(a)
masked_array(data=[0.0, 1.0, --, --, 4.0],
             mask=[False, False,  True,  True, False],
       fill_value=1e+20)


numpy.ma.masked_less   ma.masked_less(x, value, copy=True)[source]

Mask an array where less than a given value. This function is a shortcut to masked_where, with condition = (x < value).  See also  masked_where

Mask where a condition is met.    Examples >>> import numpy.ma as ma
>>> a = np.arange(4)
>>> a
array([0, 1, 2, 3])
>>> ma.masked_less(a, 2)
masked_array(data=[--, --, 2, 3],
             mask=[ True,  True, False, False],
       fill_value=999999)


numpy.ma.masked_less_equal   ma.masked_less_equal(x, value, copy=True)[source]

Mask an array where less than or equal to a given value. This function is a shortcut to masked_where, with condition = (x <= value).  See also  masked_where

Mask where a condition is met.    Examples >>> import numpy.ma as ma
>>> a = np.arange(4)
>>> a
array([0, 1, 2, 3])
>>> ma.masked_less_equal(a, 2)
masked_array(data=[--, --, --, 3],
             mask=[ True,  True,  True, False],
       fill_value=999999)


numpy.ma.masked_not_equal   ma.masked_not_equal(x, value, copy=True)[source]

Mask an array where not equal to a given value. This function is a shortcut to masked_where, with condition = (x != value).  See also  masked_where

Mask where a condition is met.    Examples >>> import numpy.ma as ma
>>> a = np.arange(4)
>>> a
array([0, 1, 2, 3])
>>> ma.masked_not_equal(a, 2)
masked_array(data=[--, --, 2, --],
             mask=[ True,  True, False,  True],
       fill_value=999999)


numpy.ma.masked_object   ma.masked_object(x, value, copy=True, shrink=True)[source]

Mask the array x where the data are exactly equal to value. This function is similar to masked_values, but only suitable for object arrays: for floating point, use masked_values instead.  Parameters

xarray_like

Array to mask
valueobject

Comparison value
copy{True, False}, optional

Whether to return a copy of x.
shrink{True, False}, optional

Whether to collapse a mask full of False to nomask    Returns

resultMaskedArray

The result of masking x where equal to value.      See also  masked_where

Mask where a condition is met.  masked_equal

Mask where equal to a given value (integers).  masked_values

Mask using floating point equality.    Examples >>> import numpy.ma as ma
>>> food = np.array(['green_eggs', 'ham'], dtype=object)
>>> # don't eat spoiled food
>>> eat = ma.masked_object(food, 'green_eggs')
>>> eat
masked_array(data=[--, 'ham'],
             mask=[ True, False],
       fill_value='green_eggs',
            dtype=object)
>>> # plain ol` ham is boring
>>> fresh_food = np.array(['cheese', 'ham', 'pineapple'], dtype=object)
>>> eat = ma.masked_object(fresh_food, 'green_eggs')
>>> eat
masked_array(data=['cheese', 'ham', 'pineapple'],
             mask=False,
       fill_value='green_eggs',
            dtype=object)
 Note that mask is set to nomask if possible. >>> eat
masked_array(data=['cheese', 'ham', 'pineapple'],
             mask=False,
       fill_value='green_eggs',
            dtype=object)


numpy.ma.masked_outside   ma.masked_outside(x, v1, v2, copy=True)[source]

Mask an array outside a given interval. Shortcut to masked_where, where condition is True for x outside the interval [v1,v2] (x < v1)|(x > v2). The boundaries v1 and v2 can be given in either order.  See also  masked_where

Mask where a condition is met.    Notes The array x is prefilled with its filling value. Examples >>> import numpy.ma as ma
>>> x = [0.31, 1.2, 0.01, 0.2, -0.4, -1.1]
>>> ma.masked_outside(x, -0.3, 0.3)
masked_array(data=[--, --, 0.01, 0.2, --, --],
             mask=[ True,  True, False, False,  True,  True],
       fill_value=1e+20)
 The order of v1 and v2 doesn’t matter. >>> ma.masked_outside(x, 0.3, -0.3)
masked_array(data=[--, --, 0.01, 0.2, --, --],
             mask=[ True,  True, False, False,  True,  True],
       fill_value=1e+20)


numpy.ma.masked_values   ma.masked_values(x, value, rtol=1e-05, atol=1e-08, copy=True, shrink=True)[source]

Mask using floating point equality. Return a MaskedArray, masked where the data in array x are approximately equal to value, determined using isclose. The default tolerances for masked_values are the same as those for isclose. For integer types, exact equality is used, in the same way as masked_equal. The fill_value is set to value and the mask is set to nomask if possible.  Parameters

xarray_like

Array to mask.
valuefloat

Masking value.
rtol, atolfloat, optional

Tolerance parameters passed on to isclose
copybool, optional

Whether to return a copy of x.
shrinkbool, optional

Whether to collapse a mask full of False to nomask.    Returns

resultMaskedArray

The result of masking x where approximately equal to value.      See also  masked_where

Mask where a condition is met.  masked_equal

Mask where equal to a given value (integers).    Examples >>> import numpy.ma as ma
>>> x = np.array([1, 1.1, 2, 1.1, 3])
>>> ma.masked_values(x, 1.1)
masked_array(data=[1.0, --, 2.0, --, 3.0],
             mask=[False,  True, False,  True, False],
       fill_value=1.1)
 Note that mask is set to nomask if possible. >>> ma.masked_values(x, 1.5)
masked_array(data=[1. , 1.1, 2. , 1.1, 3. ],
             mask=False,
       fill_value=1.5)
 For integers, the fill value will be different in general to the result of masked_equal. >>> x = np.arange(5)
>>> x
array([0, 1, 2, 3, 4])
>>> ma.masked_values(x, 2)
masked_array(data=[0, 1, --, 3, 4],
             mask=[False, False,  True, False, False],
       fill_value=2)
>>> ma.masked_equal(x, 2)
masked_array(data=[0, 1, --, 3, 4],
             mask=[False, False,  True, False, False],
       fill_value=2)


numpy.ma.masked_where   ma.masked_where(condition, a, copy=True)[source]

Mask an array where a condition is met. Return a as an array masked where condition is True. Any masked values of a or condition are also masked in the output.  Parameters

conditionarray_like

Masking condition. When condition tests floating point values for equality, consider using masked_values instead.
aarray_like

Array to mask.
copybool

If True (default) make a copy of a in the result. If False modify a in place and return a view.    Returns

resultMaskedArray

The result of masking a where condition is True.      See also  masked_values

Mask using floating point equality.  masked_equal

Mask where equal to a given value.  masked_not_equal

Mask where not equal to a given value.  masked_less_equal

Mask where less than or equal to a given value.  masked_greater_equal

Mask where greater than or equal to a given value.  masked_less

Mask where less than a given value.  masked_greater

Mask where greater than a given value.  masked_inside

Mask inside a given interval.  masked_outside

Mask outside a given interval.  masked_invalid

Mask invalid values (NaNs or infs).    Examples >>> import numpy.ma as ma
>>> a = np.arange(4)
>>> a
array([0, 1, 2, 3])
>>> ma.masked_where(a <= 2, a)
masked_array(data=[--, --, --, 3],
             mask=[ True,  True,  True, False],
       fill_value=999999)
 Mask array b conditional on a. >>> b = ['a', 'b', 'c', 'd']
>>> ma.masked_where(a == 2, b)
masked_array(data=['a', 'b', --, 'd'],
             mask=[False, False,  True, False],
       fill_value='N/A',
            dtype='<U1')
 Effect of the copy argument. >>> c = ma.masked_where(a <= 2, a)
>>> c
masked_array(data=[--, --, --, 3],
             mask=[ True,  True,  True, False],
       fill_value=999999)
>>> c[0] = 99
>>> c
masked_array(data=[99, --, --, 3],
             mask=[False,  True,  True, False],
       fill_value=999999)
>>> a
array([0, 1, 2, 3])
>>> c = ma.masked_where(a <= 2, a, copy=False)
>>> c[0] = 99
>>> c
masked_array(data=[99, --, --, 3],
             mask=[False,  True,  True, False],
       fill_value=999999)
>>> a
array([99,  1,  2,  3])
 When condition or a contain masked values. >>> a = np.arange(4)
>>> a = ma.masked_where(a == 2, a)
>>> a
masked_array(data=[0, 1, --, 3],
             mask=[False, False,  True, False],
       fill_value=999999)
>>> b = np.arange(4)
>>> b = ma.masked_where(b == 0, b)
>>> b
masked_array(data=[--, 1, 2, 3],
             mask=[ True, False, False, False],
       fill_value=999999)
>>> ma.masked_where(a == 3, b)
masked_array(data=[--, 1, --, --],
             mask=[ True, False,  True,  True],
       fill_value=999999)


numpy.ma.MaskedArray.__abs__ method   ma.MaskedArray.__abs__(self)


numpy.ma.MaskedArray.__add__ method   ma.MaskedArray.__add__(other)[source]

Add self to other, and return a new masked array.


numpy.ma.MaskedArray.__and__ method   ma.MaskedArray.__and__(value, /)

Return self&value.


numpy.ma.MaskedArray.__array__ method   ma.MaskedArray.__array__([dtype, ]/) → reference if type unchanged, copy otherwise.

Returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the array.


numpy.ma.MaskedArray.__array_priority__ attribute   ma.MaskedArray.__array_priority__ = 15


numpy.ma.MaskedArray.__array_wrap__ method   ma.MaskedArray.__array_wrap__(obj, context=None)[source]

Special hook for ufuncs. Wraps the numpy array and sets the mask according to context.


numpy.ma.MaskedArray.__bool__ method   ma.MaskedArray.__bool__(/)

self != 0


numpy.ma.MaskedArray.__contains__ method   ma.MaskedArray.__contains__(key, /)

Return key in self.


numpy.ma.MaskedArray.__copy__ method   ma.MaskedArray.__copy__()

Used if copy.copy is called on an array. Returns a copy of the array. Equivalent to a.copy(order='K').


numpy.ma.MaskedArray.__deepcopy__ method   ma.MaskedArray.__deepcopy__(memo, /) → Deep copy of array.[source]

Used if copy.deepcopy is called on an array.


numpy.ma.MaskedArray.__delitem__ method   ma.MaskedArray.__delitem__(key, /)

Delete self[key].


numpy.ma.MaskedArray.__div__ method   ma.MaskedArray.__div__(other)[source]

Divide other into self, and return a new masked array.


numpy.ma.MaskedArray.__divmod__ method   ma.MaskedArray.__divmod__(value, /)

Return divmod(self, value).


numpy.ma.MaskedArray.__eq__ method   ma.MaskedArray.__eq__(other)[source]

Check whether other equals self elementwise. When either of the elements is masked, the result is masked as well, but the underlying boolean data are still set, with self and other considered equal if both are masked, and unequal otherwise. For structured arrays, all fields are combined, with masked values ignored. The result is masked if all fields were masked, with self and other considered equal only if both were fully masked.


numpy.ma.MaskedArray.__float__ method   ma.MaskedArray.__float__()[source]

Convert to float.


numpy.ma.MaskedArray.__floordiv__ method   ma.MaskedArray.__floordiv__(other)[source]

Divide other into self, and return a new masked array.


numpy.ma.MaskedArray.__ge__ method   ma.MaskedArray.__ge__(value, /)

Return self>=value.


numpy.ma.MaskedArray.__getitem__ method   ma.MaskedArray.__getitem__(indx)[source]

x.__getitem__(y) <==> x[y] Return the item described by i, as a masked array.


numpy.ma.MaskedArray.__getstate__ method   ma.MaskedArray.__getstate__()[source]

Return the internal state of the masked array, for pickling purposes.


numpy.ma.MaskedArray.__gt__ method   ma.MaskedArray.__gt__(value, /)

Return self>value.


numpy.ma.MaskedArray.__iadd__ method   ma.MaskedArray.__iadd__(other)[source]

Add other to self in-place.


numpy.ma.MaskedArray.__iand__ method   ma.MaskedArray.__iand__(value, /)

Return self&=value.


numpy.ma.MaskedArray.__idiv__ method   ma.MaskedArray.__idiv__(other)[source]

Divide self by other in-place.


numpy.ma.MaskedArray.__ifloordiv__ method   ma.MaskedArray.__ifloordiv__(other)[source]

Floor divide self by other in-place.


numpy.ma.MaskedArray.__ilshift__ method   ma.MaskedArray.__ilshift__(value, /)

Return self<<=value.


numpy.ma.MaskedArray.__imod__ method   ma.MaskedArray.__imod__(value, /)

Return self%=value.


numpy.ma.MaskedArray.__imul__ method   ma.MaskedArray.__imul__(other)[source]

Multiply self by other in-place.


numpy.ma.MaskedArray.__int__ method   ma.MaskedArray.__int__()[source]

Convert to int.


numpy.ma.MaskedArray.__ior__ method   ma.MaskedArray.__ior__(value, /)

Return self|=value.


numpy.ma.MaskedArray.__ipow__ method   ma.MaskedArray.__ipow__(other)[source]

Raise self to the power other, in place.


numpy.ma.MaskedArray.__irshift__ method   ma.MaskedArray.__irshift__(value, /)

Return self>>=value.


numpy.ma.MaskedArray.__isub__ method   ma.MaskedArray.__isub__(other)[source]

Subtract other from self in-place.


numpy.ma.MaskedArray.__itruediv__ method   ma.MaskedArray.__itruediv__(other)[source]

True divide self by other in-place.


numpy.ma.MaskedArray.__ixor__ method   ma.MaskedArray.__ixor__(value, /)

Return self^=value.


numpy.ma.MaskedArray.__le__ method   ma.MaskedArray.__le__(value, /)

Return self<=value.


numpy.ma.MaskedArray.__len__ method   ma.MaskedArray.__len__(/)

Return len(self).


numpy.ma.MaskedArray.__lshift__ method   ma.MaskedArray.__lshift__(value, /)

Return self<<value.


numpy.ma.MaskedArray.__lt__ method   ma.MaskedArray.__lt__(value, /)

Return self<value.


numpy.ma.MaskedArray.__mod__ method   ma.MaskedArray.__mod__(value, /)

Return self%value.


numpy.ma.MaskedArray.__mul__ method   ma.MaskedArray.__mul__(other)[source]

Multiply self by other, and return a new masked array.


numpy.ma.MaskedArray.__ne__ method   ma.MaskedArray.__ne__(other)[source]

Check whether other does not equal self elementwise. When either of the elements is masked, the result is masked as well, but the underlying boolean data are still set, with self and other considered equal if both are masked, and unequal otherwise. For structured arrays, all fields are combined, with masked values ignored. The result is masked if all fields were masked, with self and other considered equal only if both were fully masked.


numpy.ma.MaskedArray.__or__ method   ma.MaskedArray.__or__(value, /)

Return self|value.


numpy.ma.MaskedArray.__pow__ method   ma.MaskedArray.__pow__(other)[source]

Raise self to the power other, masking the potential NaNs/Infs


numpy.ma.MaskedArray.__radd__ method   ma.MaskedArray.__radd__(other)[source]

Add other to self, and return a new masked array.


numpy.ma.MaskedArray.__rand__ method   ma.MaskedArray.__rand__(value, /)

Return value&self.


numpy.ma.MaskedArray.__rdivmod__ method   ma.MaskedArray.__rdivmod__(value, /)

Return divmod(value, self).


numpy.ma.MaskedArray.__reduce__ method   ma.MaskedArray.__reduce__()[source]

Return a 3-tuple for pickling a MaskedArray.


numpy.ma.MaskedArray.__repr__ method   ma.MaskedArray.__repr__()[source]

Literal string representation.


numpy.ma.MaskedArray.__rfloordiv__ method   ma.MaskedArray.__rfloordiv__(other)[source]

Divide self into other, and return a new masked array.


numpy.ma.MaskedArray.__rlshift__ method   ma.MaskedArray.__rlshift__(value, /)

Return value<<self.


numpy.ma.MaskedArray.__rmod__ method   ma.MaskedArray.__rmod__(value, /)

Return value%self.


numpy.ma.MaskedArray.__rmul__ method   ma.MaskedArray.__rmul__(other)[source]

Multiply other by self, and return a new masked array.


numpy.ma.MaskedArray.__ror__ method   ma.MaskedArray.__ror__(value, /)

Return value|self.


numpy.ma.MaskedArray.__rpow__ method   ma.MaskedArray.__rpow__(other)[source]

Raise other to the power self, masking the potential NaNs/Infs


numpy.ma.MaskedArray.__rrshift__ method   ma.MaskedArray.__rrshift__(value, /)

Return value>>self.


numpy.ma.MaskedArray.__rshift__ method   ma.MaskedArray.__rshift__(value, /)

Return self>>value.


numpy.ma.MaskedArray.__rsub__ method   ma.MaskedArray.__rsub__(other)[source]

Subtract self from other, and return a new masked array.


numpy.ma.MaskedArray.__rtruediv__ method   ma.MaskedArray.__rtruediv__(other)[source]

Divide self into other, and return a new masked array.


numpy.ma.MaskedArray.__rxor__ method   ma.MaskedArray.__rxor__(value, /)

Return value^self.


numpy.ma.MaskedArray.__setitem__ method   ma.MaskedArray.__setitem__(indx, value)[source]

x.__setitem__(i, y) <==> x[i]=y Set item described by index. If value is masked, masks those locations.


numpy.ma.MaskedArray.__setmask__ method   ma.MaskedArray.__setmask__(mask, copy=False)[source]

Set the mask.


numpy.ma.MaskedArray.__setstate__ method   ma.MaskedArray.__setstate__(state)[source]

Restore the internal state of the masked array, for pickling purposes. state is typically the output of the __getstate__ output, and is a 5-tuple:  class name a tuple giving the shape of the data a typecode for the data a binary string for the data a binary string for the mask.


numpy.ma.MaskedArray.__str__ method   ma.MaskedArray.__str__()[source]

Return str(self).


numpy.ma.MaskedArray.__sub__ method   ma.MaskedArray.__sub__(other)[source]

Subtract other from self, and return a new masked array.


numpy.ma.MaskedArray.__truediv__ method   ma.MaskedArray.__truediv__(other)[source]

Divide other into self, and return a new masked array.


numpy.ma.MaskedArray.__xor__ method   ma.MaskedArray.__xor__(value, /)

Return self^value.


numpy.ma.MaskedArray.all method   ma.MaskedArray.all(axis=None, out=None, keepdims=<no value>)[source]

Returns True if all elements evaluate to True. The output array is masked where all the values along the given axis are masked: if the output would have been a scalar and that all the values are masked, then the output is masked. Refer to numpy.all for full documentation.  See also  numpy.ndarray.all

corresponding function for ndarrays  numpy.all

equivalent function    Examples >>> np.ma.array([1,2,3]).all()
True
>>> a = np.ma.array([1,2,3], mask=True)
>>> (a.all() is np.ma.masked)
True


numpy.ma.MaskedArray.anom method   ma.MaskedArray.anom(axis=None, dtype=None)[source]

Compute the anomalies (deviations from the arithmetic mean) along the given axis. Returns an array of anomalies, with the same shape as the input and where the arithmetic mean is computed along the given axis.  Parameters

axisint, optional

Axis over which the anomalies are taken. The default is to use the mean of the flattened array as reference.
dtypedtype, optional

 Type to use in computing the variance. For arrays of integer type

the default is float32; for arrays of float types it is the same as the array type.        See also  mean

Compute the mean of the array.    Examples >>> a = np.ma.array([1,2,3])
>>> a.anom()
masked_array(data=[-1.,  0.,  1.],
             mask=False,
       fill_value=1e+20)


numpy.ma.MaskedArray.any method   ma.MaskedArray.any(axis=None, out=None, keepdims=<no value>)[source]

Returns True if any of the elements of a evaluate to True. Masked values are considered as False during computation. Refer to numpy.any for full documentation.  See also  numpy.ndarray.any

corresponding function for ndarrays  numpy.any

equivalent function


numpy.ma.MaskedArray.argmax method   ma.MaskedArray.argmax(axis=None, fill_value=None, out=None, *, keepdims=<no value>)[source]

Returns array of indices of the maximum values along the given axis. Masked values are treated as if they had the value fill_value.  Parameters

axis{None, integer}

If None, the index is into the flattened array, otherwise along the specified axis
fill_valuescalar or None, optional

Value used to fill in the masked values. If None, the output of maximum_fill_value(self._data) is used instead.
out{None, array}, optional

Array into which the result can be placed. Its type is preserved and it must be of the right shape to hold the output.    Returns

index_array{integer_array}

   Examples >>> a = np.arange(6).reshape(2,3)
>>> a.argmax()
5
>>> a.argmax(0)
array([1, 1, 1])
>>> a.argmax(1)
array([2, 2])


numpy.ma.MaskedArray.argmin method   ma.MaskedArray.argmin(axis=None, fill_value=None, out=None, *, keepdims=<no value>)[source]

Return array of indices to the minimum values along the given axis.  Parameters

axis{None, integer}

If None, the index is into the flattened array, otherwise along the specified axis
fill_valuescalar or None, optional

Value used to fill in the masked values. If None, the output of minimum_fill_value(self._data) is used instead.
out{None, array}, optional

Array into which the result can be placed. Its type is preserved and it must be of the right shape to hold the output.    Returns
 ndarray or scalar

If multi-dimension input, returns a new ndarray of indices to the minimum values along the given axis. Otherwise, returns a scalar of index to the minimum values along the given axis.     Examples >>> x = np.ma.array(np.arange(4), mask=[1,1,0,0])
>>> x.shape = (2,2)
>>> x
masked_array(
  data=[[--, --],
        [2, 3]],
  mask=[[ True,  True],
        [False, False]],
  fill_value=999999)
>>> x.argmin(axis=0, fill_value=-1)
array([0, 0])
>>> x.argmin(axis=0, fill_value=9)
array([1, 1])


numpy.ma.MaskedArray.argsort method   ma.MaskedArray.argsort(axis=<no value>, kind=None, order=None, endwith=True, fill_value=None)[source]

Return an ndarray of indices that sort the array along the specified axis. Masked values are filled beforehand to fill_value.  Parameters

axisint, optional

Axis along which to sort. If None, the default, the flattened array is used.  Changed in version 1.13.0: Previously, the default was documented to be -1, but that was in error. At some future date, the default will change to -1, as originally intended. Until then, the axis should be given explicitly when arr.ndim > 1, to avoid a FutureWarning.
kind{‘quicksort’, ‘mergesort’, ‘heapsort’, ‘stable’}, optional

The sorting algorithm used.
orderlist, optional

When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. Not all fields need be specified.
endwith{True, False}, optional

Whether missing values (if any) should be treated as the largest values (True) or the smallest values (False) When the array contains unmasked values at the same extremes of the datatype, the ordering of these values and the masked values is undefined.
fill_valuescalar or None, optional

Value used internally for the masked values. If fill_value is not None, it supersedes endwith.    Returns

index_arrayndarray, int

Array of indices that sort a along the specified axis. In other words, a[index_array] yields a sorted a.      See also  ma.MaskedArray.sort

Describes sorting algorithms used.  lexsort

Indirect stable sort with multiple keys.  numpy.ndarray.sort

Inplace sort.    Notes See sort for notes on the different sorting algorithms. Examples >>> a = np.ma.array([3,2,1], mask=[False, False, True])
>>> a
masked_array(data=[3, 2, --],
             mask=[False, False,  True],
       fill_value=999999)
>>> a.argsort()
array([1, 0, 2])


numpy.ma.MaskedArray.astype method   ma.MaskedArray.astype(dtype, order='K', casting='unsafe', subok=True, copy=True)

Copy of the array, cast to a specified type.  Parameters

dtypestr or dtype

Typecode or data-type to which the array is cast.
order{‘C’, ‘F’, ‘A’, ‘K’}, optional

Controls the memory layout order of the result. ‘C’ means C order, ‘F’ means Fortran order, ‘A’ means ‘F’ order if all the arrays are Fortran contiguous, ‘C’ order otherwise, and ‘K’ means as close to the order the array elements appear in memory as possible. Default is ‘K’.
casting{‘no’, ‘equiv’, ‘safe’, ‘same_kind’, ‘unsafe’}, optional

Controls what kind of data casting may occur. Defaults to ‘unsafe’ for backwards compatibility.  ‘no’ means the data types should not be cast at all. ‘equiv’ means only byte-order changes are allowed. ‘safe’ means only casts which can preserve values are allowed. ‘same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed. ‘unsafe’ means any data conversions may be done.
subokbool, optional

If True, then sub-classes will be passed-through (default), otherwise the returned array will be forced to be a base-class array.
copybool, optional

By default, astype always returns a newly allocated array. If this is set to false, and the dtype, order, and subok requirements are satisfied, the input array is returned instead of a copy.    Returns

arr_tndarray

Unless copy is False and the other conditions for returning the input array are satisfied (see description for copy input parameter), arr_t is a new array of the same shape as the input array, with dtype, order given by dtype, order.    Raises
 ComplexWarning

When casting from complex to float or int. To avoid this, one should use a.real.astype(t).     Notes  Changed in version 1.17.0: Casting between a simple data type and a structured one is possible only for “unsafe” casting. Casting to multiple fields is allowed, but casting from multiple fields is not.   Changed in version 1.9.0: Casting from numeric to string types in ‘safe’ casting mode requires that the string dtype length is long enough to store the max integer/float value converted.  Examples >>> x = np.array([1, 2, 2.5])
>>> x
array([1. ,  2. ,  2.5])
 >>> x.astype(int)
array([1, 2, 2])


numpy.ma.MaskedArray.base attribute   ma.MaskedArray.base

Base object if memory is from some other object. Examples The base of an array that owns its memory is None: >>> x = np.array([1,2,3,4])
>>> x.base is None
True
 Slicing creates a view, whose memory is shared with x: >>> y = x[2:]
>>> y.base is x
True


numpy.ma.MaskedArray.byteswap method   ma.MaskedArray.byteswap(inplace=False)

Swap the bytes of the array elements Toggle between low-endian and big-endian data representation by returning a byteswapped array, optionally swapped in-place. Arrays of byte-strings are not swapped. The real and imaginary parts of a complex number are swapped individually.  Parameters

inplacebool, optional

If True, swap bytes in-place, default is False.    Returns

outndarray

The byteswapped array. If inplace is True, this is a view to self.     Examples >>> A = np.array([1, 256, 8755], dtype=np.int16)
>>> list(map(hex, A))
['0x1', '0x100', '0x2233']
>>> A.byteswap(inplace=True)
array([  256,     1, 13090], dtype=int16)
>>> list(map(hex, A))
['0x100', '0x1', '0x3322']
 Arrays of byte-strings are not swapped >>> A = np.array([b'ceg', b'fac'])
>>> A.byteswap()
array([b'ceg', b'fac'], dtype='|S3')

A.newbyteorder().byteswap() produces an array with the same values

but different representation in memory   >>> A = np.array([1, 2, 3])
>>> A.view(np.uint8)
array([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
       0, 0], dtype=uint8)
>>> A.newbyteorder().byteswap(inplace=True)
array([1, 2, 3])
>>> A.view(np.uint8)
array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
       0, 3], dtype=uint8)


numpy.ma.MaskedArray.choose method   ma.MaskedArray.choose(choices, out=None, mode='raise')

Use an index array to construct a new array from a set of choices. Refer to numpy.choose for full documentation.  See also  numpy.choose

equivalent function


numpy.ma.MaskedArray.clip method   ma.MaskedArray.clip(min=None, max=None, out=None, **kwargs)

Return an array whose values are limited to [min, max]. One of max or min must be given. Refer to numpy.clip for full documentation.  See also  numpy.clip

equivalent function


numpy.ma.MaskedArray.compress method   ma.MaskedArray.compress(condition, axis=None, out=None)[source]

Return a where condition is True. If condition is a MaskedArray, missing values are considered as False.  Parameters

conditionvar

Boolean 1-d array selecting which entries to return. If len(condition) is less than the size of a along the axis, then output is truncated to length of condition array.
axis{None, int}, optional

Axis along which the operation must be performed.
out{None, ndarray}, optional

Alternative output array in which to place the result. It must have the same shape as the expected output but the type will be cast if necessary.    Returns

resultMaskedArray

A MaskedArray object.     Notes Please note the difference with compressed ! The output of compress has a mask, the output of compressed does not. Examples >>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4)
>>> x
masked_array(
  data=[[1, --, 3],
        [--, 5, --],
        [7, --, 9]],
  mask=[[False,  True, False],
        [ True, False,  True],
        [False,  True, False]],
  fill_value=999999)
>>> x.compress([1, 0, 1])
masked_array(data=[1, 3],
             mask=[False, False],
       fill_value=999999)
 >>> x.compress([1, 0, 1], axis=1)
masked_array(
  data=[[1, 3],
        [--, --],
        [7, 9]],
  mask=[[False, False],
        [ True,  True],
        [False, False]],
  fill_value=999999)


numpy.ma.MaskedArray.compressed method   ma.MaskedArray.compressed()[source]

Return all the non-masked data as a 1-D array.  Returns

datandarray

A new ndarray holding the non-masked data is returned.     Notes The result is not a MaskedArray! Examples >>> x = np.ma.array(np.arange(5), mask=[0]*2 + [1]*3)
>>> x.compressed()
array([0, 1])
>>> type(x.compressed())
<class 'numpy.ndarray'>


numpy.ma.MaskedArray.conj method   ma.MaskedArray.conj()

Complex-conjugate all elements. Refer to numpy.conjugate for full documentation.  See also  numpy.conjugate

equivalent function


numpy.ma.MaskedArray.conjugate method   ma.MaskedArray.conjugate()

Return the complex conjugate, element-wise. Refer to numpy.conjugate for full documentation.  See also  numpy.conjugate

equivalent function


numpy.ma.MaskedArray.copy method   ma.MaskedArray.copy(order='C')[source]

Return a copy of the array.  Parameters

order{‘C’, ‘F’, ‘A’, ‘K’}, optional

Controls the memory layout of the copy. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible. (Note that this function and numpy.copy are very similar but have different default values for their order= arguments, and this function always passes sub-classes through.)      See also  numpy.copy

Similar function with different default behavior  numpy.copyto
  Notes This function is the preferred method for creating an array copy. The function numpy.copy is similar, but it defaults to using order ‘K’, and will not pass sub-classes through by default. Examples >>> x = np.array([[1,2,3],[4,5,6]], order='F')
 >>> y = x.copy()
 >>> x.fill(0)
 >>> x
array([[0, 0, 0],
       [0, 0, 0]])
 >>> y
array([[1, 2, 3],
       [4, 5, 6]])
 >>> y.flags['C_CONTIGUOUS']
True


numpy.ma.MaskedArray.count method   ma.MaskedArray.count(axis=None, keepdims=<no value>)[source]

Count the non-masked elements of the array along the given axis.  Parameters

axisNone or int or tuple of ints, optional

Axis or axes along which the count is performed. The default, None, performs the count over all the dimensions of the input array. axis may be negative, in which case it counts from the last to the first axis.  New in version 1.10.0.  If this is a tuple of ints, the count is performed on multiple axes, instead of a single axis or all the axes as before.
keepdimsbool, 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 array.    Returns

resultndarray or scalar

An array with the same shape as the input array, with the specified axis removed. If the array is a 0-d array, or if axis is None, a scalar is returned.      See also  ma.count_masked

Count masked elements in array or along a given axis.    Examples >>> import numpy.ma as ma
>>> a = ma.arange(6).reshape((2, 3))
>>> a[1, :] = ma.masked
>>> a
masked_array(
  data=[[0, 1, 2],
        [--, --, --]],
  mask=[[False, False, False],
        [ True,  True,  True]],
  fill_value=999999)
>>> a.count()
3
 When the axis keyword is specified an array of appropriate size is returned. >>> a.count(axis=0)
array([1, 1, 1])
>>> a.count(axis=1)
array([3, 0])