@@ -1059,54 +1059,72 @@ def mask_indices(
10591059
10601060
10611061# pylint: disable=invalid-name
1062- ndindex = numpy .ndindex
1063- ndindex .__doc__ = """
1064- An N-dimensional iterator object to index arrays.
1065-
1066- Given the shape of an array, an `ndindex` instance iterates over the
1067- N-dimensional index of the array. At each iteration a tuple of indices is
1068- returned, the last dimension is iterated over first.
1069-
1070- For full documentation refer to :obj:`numpy.ndindex`.
1071-
1072- Parameters
1073- ----------
1074- shape : ints, or a single tuple of ints
1075- The size of each dimension of the array can be passed as individual
1076- parameters or as the elements of a tuple.
1077-
1078- See Also
1079- --------
1080- :obj:`dpnp.ndenumerate` : Multidimensional index iterator.
1081- :obj:`dpnp.flatiter` : Flat iterator object to iterate over arrays.
1082-
1083- Examples
1084- --------
1085- >>> import dpnp as np
1086-
1087- Dimensions as individual arguments
1088-
1089- >>> for index in np.ndindex(3, 2, 1):
1090- ... print(index)
1091- (0, 0, 0)
1092- (0, 1, 0)
1093- (1, 0, 0)
1094- (1, 1, 0)
1095- (2, 0, 0)
1096- (2, 1, 0)
1097-
1098- Same dimensions - but in a tuple ``(3, 2, 1)``
1099-
1100- >>> for index in np.ndindex((3, 2, 1)):
1101- ... print(index)
1102- (0, 0, 0)
1103- (0, 1, 0)
1104- (1, 0, 0)
1105- (1, 1, 0)
1106- (2, 0, 0)
1107- (2, 1, 0)
1062+ # pylint: disable=too-few-public-methods
1063+ class ndindex (numpy .ndindex ):
1064+ """
1065+ An N-dimensional iterator object to index arrays.
11081066
1109- """
1067+ Given the shape of an array, an :obj:`dpnp.ndindex` instance iterates over
1068+ the N-dimensional index of the array. At each iteration a tuple of indices
1069+ is returned, the last dimension is iterated over first.
1070+
1071+ For full documentation refer to :obj:`numpy.ndindex`.
1072+
1073+ Parameters
1074+ ----------
1075+ shape : ints, or a single tuple of ints
1076+ The size of each dimension of the array can be passed as individual
1077+ parameters or as the elements of a tuple.
1078+
1079+ See Also
1080+ --------
1081+ :obj:`dpnp.ndenumerate` : Multidimensional index iterator.
1082+ :obj:`dpnp.flatiter` : Flat iterator object to iterate over arrays.
1083+
1084+ Examples
1085+ --------
1086+ >>> import dpnp as np
1087+
1088+ Dimensions as individual arguments
1089+
1090+ >>> for index in np.ndindex(3, 2, 1):
1091+ ... print(index)
1092+ (0, 0, 0)
1093+ (0, 1, 0)
1094+ (1, 0, 0)
1095+ (1, 1, 0)
1096+ (2, 0, 0)
1097+ (2, 1, 0)
1098+
1099+ Same dimensions - but in a tuple ``(3, 2, 1)``
1100+
1101+ >>> for index in np.ndindex((3, 2, 1)):
1102+ ... print(index)
1103+ (0, 0, 0)
1104+ (0, 1, 0)
1105+ (1, 0, 0)
1106+ (1, 1, 0)
1107+ (2, 0, 0)
1108+ (2, 1, 0)
1109+
1110+ """
1111+
1112+ def __init__ (self , * shape ):
1113+ super ().__init__ (shape )
1114+
1115+ def __next__ (self ):
1116+ """
1117+ Standard iterator method, updates the index and returns the index tuple.
1118+
1119+ Returns
1120+ -------
1121+ val : tuple of ints
1122+ Returns a tuple containing the indices of the current iteration.
1123+
1124+ """
1125+
1126+ # pylint: disable=useless-parent-delegation
1127+ return super ().__next__ ()
11101128
11111129
11121130def nonzero (a ):
0 commit comments