>>> np.arange(12)
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
>>> np.arange(12).reshape(3,4)
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> a = np.arange(12).reshape(3,4)
>>> a[slice(None, 3, None)]
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> a[:3]
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> b = np.arange(24).reshape(3,4,2)
>>> b
array([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7]],
[[ 8, 9],
[10, 11],
[12, 13],
[14, 15]],
[[16, 17],
[18, 19],
[20, 21],
[22, 23]]])
>>> b[2:]
array([[[16, 17],
[18, 19],
[20, 21],
[22, 23]]])
>>> b[slice(2, None, None)]
array([[[16, 17],
[18, 19],
[20, 21],
[22, 23]]])
>>> b[2:,3]
array([[22, 23]])
>>> b[2:,1:]
array([[[18, 19],
[20, 21],
[22, 23]]])
>>> b[2:,:1]
array([[[16, 17]]])
>>> b[slice(2, None, None), slice(None, 1, None)]
array([[[16, 17]]])
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
>>> np.arange(12).reshape(3,4)
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> a = np.arange(12).reshape(3,4)
>>> a[slice(None, 3, None)]
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> a[:3]
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> b = np.arange(24).reshape(3,4,2)
>>> b
array([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7]],
[[ 8, 9],
[10, 11],
[12, 13],
[14, 15]],
[[16, 17],
[18, 19],
[20, 21],
[22, 23]]])
>>> b[2:]
array([[[16, 17],
[18, 19],
[20, 21],
[22, 23]]])
>>> b[slice(2, None, None)]
array([[[16, 17],
[18, 19],
[20, 21],
[22, 23]]])
>>> b[2:,3]
array([[22, 23]])
>>> b[2:,1:]
array([[[18, 19],
[20, 21],
[22, 23]]])
>>> b[2:,:1]
array([[[16, 17]]])
>>> b[slice(2, None, None), slice(None, 1, None)]
array([[[16, 17]]])