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

Method view

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

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