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

Method view

dask/array/core.py:2881–2922  ·  view source on GitHub ↗

Get a view of the array as a new data type Parameters ---------- dtype: The dtype by which to view the array. The default, None, results in the view having the same data-type as the original array. order: string 'C' or

(self, dtype=None, order="C")

Source from the content-addressed store, hash-verified

2879 return clip(self, min, max)
2880
2881 def view(self, dtype=None, order="C"):
2882 """Get a view of the array as a new data type
2883
2884 Parameters
2885 ----------
2886 dtype:
2887 The dtype by which to view the array.
2888 The default, None, results in the view having the same data-type
2889 as the original array.
2890 order: string
2891 'C' or 'F' (Fortran) ordering
2892
2893 This reinterprets the bytes of the array under a new dtype. If that
2894 dtype does not have the same size as the original array then the shape
2895 will change.
2896
2897 Beware that both numpy and dask.array can behave oddly when taking
2898 shape-changing views of arrays under Fortran ordering. Under some
2899 versions of NumPy this function will fail when taking shape-changing
2900 views of Fortran ordered arrays if the first dimension has chunks of
2901 size one.
2902 """
2903 if dtype is None:
2904 dtype = self.dtype
2905 else:
2906 dtype = np.dtype(dtype)
2907 mult = self.dtype.itemsize / dtype.itemsize
2908
2909 if order == "C":
2910 chunks = self.chunks[:-1] + (
2911 tuple(ensure_int(c * mult) for c in self.chunks[-1]),
2912 )
2913 elif order == "F":
2914 chunks = (
2915 tuple(ensure_int(c * mult) for c in self.chunks[0]),
2916 ) + self.chunks[1:]
2917 else:
2918 raise ValueError("Order must be one of 'C' or 'F'")
2919
2920 return self.map_blocks(
2921 chunk.view, dtype, order=order, dtype=dtype, chunks=chunks
2922 )
2923
2924 def swapaxes(self, axis1, axis2):
2925 """Return a view of the array with ``axis1`` and ``axis2`` interchanged.

Callers 10

normalize_arrayFunction · 0.80
explainFunction · 0.80
setitemFunction · 0.80
_percentileFunction · 0.80
viewFunction · 0.80
test_from_array_inlineFunction · 0.80
test_viewFunction · 0.80
test_view_fortranFunction · 0.80
test_viewFunction · 0.80
test_view_fortranFunction · 0.80

Calls 3

map_blocksMethod · 0.95
ensure_intFunction · 0.85
dtypeMethod · 0.45

Tested by 5

test_from_array_inlineFunction · 0.64
test_viewFunction · 0.64
test_view_fortranFunction · 0.64
test_viewFunction · 0.64
test_view_fortranFunction · 0.64