MCPcopy Create free account
hub / github.com/numpy/numpy / dsplit

Function dsplit

numpy/lib/shape_base.py:993–1034  ·  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

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

Callers 2

test_2D_arrayMethod · 0.90
test_3D_arrayMethod · 0.90

Calls 2

ndimMethod · 0.80
splitFunction · 0.70

Tested by 2

test_2D_arrayMethod · 0.72
test_3D_arrayMethod · 0.72