MCPcopy
hub / github.com/dask/dask / view

Method view

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

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