Return a view of the MaskedArray data. Parameters ---------- dtype : data-type or ndarray sub-class, optional Data-type descriptor of the returned view, e.g., float32 or int16. The default, None, results in the view having the same data-type
(self, dtype=None, type=None, fill_value=None)
| 3201 | return result |
| 3202 | |
| 3203 | def view(self, dtype=None, type=None, fill_value=None): |
| 3204 | """ |
| 3205 | Return a view of the MaskedArray data. |
| 3206 | |
| 3207 | Parameters |
| 3208 | ---------- |
| 3209 | dtype : data-type or ndarray sub-class, optional |
| 3210 | Data-type descriptor of the returned view, e.g., float32 or int16. |
| 3211 | The default, None, results in the view having the same data-type |
| 3212 | as `a`. As with ``ndarray.view``, dtype can also be specified as |
| 3213 | an ndarray sub-class, which then specifies the type of the |
| 3214 | returned object (this is equivalent to setting the ``type`` |
| 3215 | parameter). |
| 3216 | type : Python type, optional |
| 3217 | Type of the returned view, either ndarray or a subclass. The |
| 3218 | default None results in type preservation. |
| 3219 | fill_value : scalar, optional |
| 3220 | The value to use for invalid entries (None by default). |
| 3221 | If None, then this argument is inferred from the passed `dtype`, or |
| 3222 | in its absence the original array, as discussed in the notes below. |
| 3223 | |
| 3224 | See Also |
| 3225 | -------- |
| 3226 | numpy.ndarray.view : Equivalent method on ndarray object. |
| 3227 | |
| 3228 | Notes |
| 3229 | ----- |
| 3230 | |
| 3231 | ``a.view()`` is used two different ways: |
| 3232 | |
| 3233 | ``a.view(some_dtype)`` or ``a.view(dtype=some_dtype)`` constructs a view |
| 3234 | of the array's memory with a different data-type. This can cause a |
| 3235 | reinterpretation of the bytes of memory. |
| 3236 | |
| 3237 | ``a.view(ndarray_subclass)`` or ``a.view(type=ndarray_subclass)`` just |
| 3238 | returns an instance of `ndarray_subclass` that looks at the same array |
| 3239 | (same shape, dtype, etc.) This does not cause a reinterpretation of the |
| 3240 | memory. |
| 3241 | |
| 3242 | If `fill_value` is not specified, but `dtype` is specified (and is not |
| 3243 | an ndarray sub-class), the `fill_value` of the MaskedArray will be |
| 3244 | reset. If neither `fill_value` nor `dtype` are specified (or if |
| 3245 | `dtype` is an ndarray sub-class), then the fill value is preserved. |
| 3246 | Finally, if `fill_value` is specified, but `dtype` is not, the fill |
| 3247 | value is set to the specified value. |
| 3248 | |
| 3249 | For ``a.view(some_dtype)``, if ``some_dtype`` has a different number of |
| 3250 | bytes per entry than the previous dtype (for example, converting a |
| 3251 | regular array to a structured array), then the behavior of the view |
| 3252 | cannot be predicted just from the superficial appearance of ``a`` (shown |
| 3253 | by ``print(a)``). It also depends on exactly how ``a`` is stored in |
| 3254 | memory. Therefore if ``a`` is C-ordered versus fortran-ordered, versus |
| 3255 | defined as a slice or transpose, etc., the view may give different |
| 3256 | results. |
| 3257 | """ |
| 3258 | |
| 3259 | if type is None and (isinstance(dtype, builtins.type) |
| 3260 | and issubclass(dtype, ndarray)): |
no outgoing calls