MCPcopy Create free account
hub / github.com/numpy/numpy / view

Method view

numpy/ma/core.py:3127–3215  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

3125 return result
3126
3127 def view(self, dtype=None, type=None, fill_value=None):
3128 """
3129 Return a view of the MaskedArray data.
3130
3131 Parameters
3132 ----------
3133 dtype : data-type or ndarray sub-class, optional
3134 Data-type descriptor of the returned view, e.g., float32 or int16.
3135 The default, None, results in the view having the same data-type
3136 as `a`. As with ``ndarray.view``, dtype can also be specified as
3137 an ndarray sub-class, which then specifies the type of the
3138 returned object (this is equivalent to setting the ``type``
3139 parameter).
3140 type : Python type, optional
3141 Type of the returned view, either ndarray or a subclass. The
3142 default None results in type preservation.
3143 fill_value : scalar, optional
3144 The value to use for invalid entries (None by default).
3145 If None, then this argument is inferred from the passed `dtype`, or
3146 in its absence the original array, as discussed in the notes below.
3147
3148 See Also
3149 --------
3150 numpy.ndarray.view : Equivalent method on ndarray object.
3151
3152 Notes
3153 -----
3154
3155 ``a.view()`` is used two different ways:
3156
3157 ``a.view(some_dtype)`` or ``a.view(dtype=some_dtype)`` constructs a view
3158 of the array's memory with a different data-type. This can cause a
3159 reinterpretation of the bytes of memory.
3160
3161 ``a.view(ndarray_subclass)`` or ``a.view(type=ndarray_subclass)`` just
3162 returns an instance of `ndarray_subclass` that looks at the same array
3163 (same shape, dtype, etc.) This does not cause a reinterpretation of the
3164 memory.
3165
3166 If `fill_value` is not specified, but `dtype` is specified (and is not
3167 an ndarray sub-class), the `fill_value` of the MaskedArray will be
3168 reset. If neither `fill_value` nor `dtype` are specified (or if
3169 `dtype` is an ndarray sub-class), then the fill value is preserved.
3170 Finally, if `fill_value` is specified, but `dtype` is not, the fill
3171 value is set to the specified value.
3172
3173 For ``a.view(some_dtype)``, if ``some_dtype`` has a different number of
3174 bytes per entry than the previous dtype (for example, converting a
3175 regular array to a structured array), then the behavior of the view
3176 cannot be predicted just from the superficial appearance of ``a`` (shown
3177 by ``print(a)``). It also depends on exactly how ``a`` is stored in
3178 memory. Therefore if ``a`` is C-ordered versus fortran-ordered, versus
3179 defined as a slice or transpose, etc., the view may give different
3180 results.
3181 """
3182
3183 if dtype is None:
3184 if type is None:

Callers 15

uniform_from_dsfmtFunction · 0.45
test_repeatabilityMethod · 0.45
test_shuffleMethod · 0.45
test_integer_repeatFunction · 0.45
test_repeatabilityMethod · 0.45
test_shuffleMethod · 0.45

Calls 1

getmaskFunction · 0.85

Tested by 15

uniform_from_dsfmtFunction · 0.36
test_repeatabilityMethod · 0.36
test_shuffleMethod · 0.36
test_integer_repeatFunction · 0.36
test_repeatabilityMethod · 0.36
test_shuffleMethod · 0.36