MCPcopy Index your code
hub / github.com/numpy/numpy / dsplit

Function dsplit

numpy/lib/_shape_base_impl.py:989–1031  ·  view source on GitHub ↗

Split array into multiple sub-arrays along the 3rd axis (depth). Please refer to the `split` documentation. `dsplit` is equivalent to `split` with ``axis=2``, the array is always split along the third axis provided the array dimension is greater than or equal to 3. See Also

(ary, indices_or_sections)

Source from the content-addressed store, hash-verified

987
988@array_function_dispatch(_hvdsplit_dispatcher)
989def dsplit(ary, indices_or_sections):
990 """
991 Split array into multiple sub-arrays along the 3rd axis (depth).
992
993 Please refer to the `split` documentation. `dsplit` is equivalent
994 to `split` with ``axis=2``, the array is always split along the third
995 axis provided the array dimension is greater than or equal to 3.
996
997 See Also
998 --------
999 split : Split an array into multiple sub-arrays of equal size.
1000
1001 Examples
1002 --------
1003 >>> import numpy as np
1004 >>> x = np.arange(16.0).reshape(2, 2, 4)
1005 >>> x
1006 array([[[ 0., 1., 2., 3.],
1007 [ 4., 5., 6., 7.]],
1008 [[ 8., 9., 10., 11.],
1009 [12., 13., 14., 15.]]])
1010 >>> np.dsplit(x, 2)
1011 [array([[[ 0., 1.],
1012 [ 4., 5.]],
1013 [[ 8., 9.],
1014 [12., 13.]]]), array([[[ 2., 3.],
1015 [ 6., 7.]],
1016 [[10., 11.],
1017 [14., 15.]]])]
1018 >>> np.dsplit(x, np.array([3, 6]))
1019 [array([[[ 0., 1., 2.],
1020 [ 4., 5., 6.]],
1021 [[ 8., 9., 10.],
1022 [12., 13., 14.]]]),
1023 array([[[ 3.],
1024 [ 7.]],
1025 [[11.],
1026 [15.]]]),
1027 array([], shape=(2, 2, 0), dtype=float64)]
1028 """
1029 if _nx.ndim(ary) < 3:
1030 raise ValueError('dsplit only works on arrays of 3 or more dimensions')
1031 return split(ary, indices_or_sections, 2)
1032
1033
1034def _kron_dispatcher(a, b):

Callers 2

test_2D_arrayMethod · 0.90
test_3D_arrayMethod · 0.90

Calls 1

splitFunction · 0.85

Tested by 2

test_2D_arrayMethod · 0.72
test_3D_arrayMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…