File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 67
67
"indices" ,
68
68
"ix_" ,
69
69
"mask_indices" ,
70
+ "ndindex" ,
70
71
"nonzero" ,
71
72
"place" ,
72
73
"put" ,
@@ -1059,6 +1060,57 @@ def mask_indices(
1059
1060
return nonzero (a != 0 )
1060
1061
1061
1062
1063
+ # pylint: disable=invalid-name
1064
+ ndindex = numpy .ndindex
1065
+ ndindex .__doc__ = """
1066
+ An N-dimensional iterator object to index arrays.
1067
+
1068
+ Given the shape of an array, an `ndindex` instance iterates over the
1069
+ N-dimensional index of the array. At each iteration a tuple of indices is
1070
+ returned, the last dimension is iterated over first.
1071
+
1072
+ For full documentation refer to :obj:`numpy.ndindex`.
1073
+
1074
+ Parameters
1075
+ ----------
1076
+ shape : ints, or a single tuple of ints
1077
+ The size of each dimension of the array can be passed as individual
1078
+ parameters or as the elements of a tuple.
1079
+
1080
+ See Also
1081
+ --------
1082
+ :obj:`dpnp.ndenumerate` : Multidimensional index iterator.
1083
+ :obj:`dpnp.flatiter` : Flat iterator object to iterate over arrays.
1084
+
1085
+ Examples
1086
+ --------
1087
+ >>> import dpnp as np
1088
+
1089
+ Dimensions as individual arguments
1090
+
1091
+ >>> for index in np.ndindex(3, 2, 1):
1092
+ ... print(index)
1093
+ (0, 0, 0)
1094
+ (0, 1, 0)
1095
+ (1, 0, 0)
1096
+ (1, 1, 0)
1097
+ (2, 0, 0)
1098
+ (2, 1, 0)
1099
+
1100
+ Same dimensions - but in a tuple ``(3, 2, 1)``
1101
+
1102
+ >>> for index in np.ndindex((3, 2, 1)):
1103
+ ... print(index)
1104
+ (0, 0, 0)
1105
+ (0, 1, 0)
1106
+ (1, 0, 0)
1107
+ (1, 1, 0)
1108
+ (2, 0, 0)
1109
+ (2, 1, 0)
1110
+
1111
+ """
1112
+
1113
+
1062
1114
def nonzero (a ):
1063
1115
"""
1064
1116
Return the indices of the elements that are non-zero.
You can’t perform that action at this time.
0 commit comments