An array class with possibly masked values. Masked values of True exclude the corresponding element from any computation. Construction:: x = MaskedArray(data, mask=nomask, dtype=None, copy=False, subok=True, ndmin=0, fill_value=None, keep_mask=True, ha
| 2768 | |
| 2769 | @set_module("numpy.ma") |
| 2770 | class MaskedArray(ndarray): |
| 2771 | """ |
| 2772 | An array class with possibly masked values. |
| 2773 | |
| 2774 | Masked values of True exclude the corresponding element from any |
| 2775 | computation. |
| 2776 | |
| 2777 | Construction:: |
| 2778 | |
| 2779 | x = MaskedArray(data, mask=nomask, dtype=None, copy=False, subok=True, |
| 2780 | ndmin=0, fill_value=None, keep_mask=True, hard_mask=None, |
| 2781 | shrink=True, order=None) |
| 2782 | |
| 2783 | Parameters |
| 2784 | ---------- |
| 2785 | data : array_like |
| 2786 | Input data. |
| 2787 | mask : sequence, optional |
| 2788 | Mask. Must be convertible to an array of booleans with the same |
| 2789 | shape as `data`. True indicates a masked (i.e. invalid) data. |
| 2790 | dtype : dtype, optional |
| 2791 | Data type of the output. |
| 2792 | If `dtype` is None, the type of the data argument (``data.dtype``) |
| 2793 | is used. If `dtype` is not None and different from ``data.dtype``, |
| 2794 | a copy is performed. |
| 2795 | copy : bool, optional |
| 2796 | Whether to copy the input data (True), or to use a reference instead. |
| 2797 | Default is False. |
| 2798 | subok : bool, optional |
| 2799 | Whether to return a subclass of `MaskedArray` if possible (True) or a |
| 2800 | plain `MaskedArray`. Default is True. |
| 2801 | ndmin : int, optional |
| 2802 | Minimum number of dimensions. Default is 0. |
| 2803 | fill_value : scalar, optional |
| 2804 | Value used to fill in the masked values when necessary. |
| 2805 | If None, a default based on the data-type is used. |
| 2806 | keep_mask : bool, optional |
| 2807 | Whether to combine `mask` with the mask of the input data, if any |
| 2808 | (True), or to use only `mask` for the output (False). Default is True. |
| 2809 | hard_mask : bool, optional |
| 2810 | Whether to use a hard mask or not. With a hard mask, masked values |
| 2811 | cannot be unmasked. Default is False. |
| 2812 | shrink : bool, optional |
| 2813 | Whether to force compression of an empty mask. Default is True. |
| 2814 | order : {'C', 'F', 'A'}, optional |
| 2815 | Specify the order of the array. If order is 'C', then the array |
| 2816 | will be in C-contiguous order (last-index varies the fastest). |
| 2817 | If order is 'F', then the returned array will be in |
| 2818 | Fortran-contiguous order (first-index varies the fastest). |
| 2819 | If order is 'A' (default), then the returned array may be |
| 2820 | in any order (either C-, Fortran-contiguous, or even discontiguous), |
| 2821 | unless a copy is required, in which case it will be C-contiguous. |
| 2822 | |
| 2823 | Examples |
| 2824 | -------- |
| 2825 | >>> import numpy as np |
| 2826 | |
| 2827 | The ``mask`` can be initialized with an array of boolean values |
searching dependent graphs…