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

Method view

dask/array/core.py:2870–2911  ·  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

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