@@ -6202,7 +6202,72 @@ def argpartition(self, *args, **kwargs):
6202
6202
6203
6203
def take (self , indices , axis = None , out = None , mode = 'raise' ):
6204
6204
"""
6205
- """
6205
+ Take elements from a masked array along an axis.
6206
+
6207
+ This function does the same thing as "fancy" indexing (indexing arrays
6208
+ using arrays) for masked arrays. It can be easier to use if you need
6209
+ elements along a given axis.
6210
+
6211
+ Parameters
6212
+ ----------
6213
+ a : masked_array
6214
+ The source masked array.
6215
+ indices : array_like
6216
+ The indices of the values to extract. Also allow scalars for indices.
6217
+ axis : int, optional
6218
+ The axis over which to select values. By default, the flattened
6219
+ input array is used.
6220
+ out : MaskedArray, optional
6221
+ If provided, the result will be placed in this array. It should
6222
+ be of the appropriate shape and dtype. Note that `out` is always
6223
+ buffered if `mode='raise'`; use other modes for better performance.
6224
+ mode : {'raise', 'wrap', 'clip'}, optional
6225
+ Specifies how out-of-bounds indices will behave.
6226
+
6227
+ * 'raise' -- raise an error (default)
6228
+ * 'wrap' -- wrap around
6229
+ * 'clip' -- clip to the range
6230
+
6231
+ 'clip' mode means that all indices that are too large are replaced
6232
+ by the index that addresses the last element along that axis. Note
6233
+ that this disables indexing with negative numbers.
6234
+
6235
+ Returns
6236
+ -------
6237
+ out : MaskedArray
6238
+ The returned array has the same type as `a`.
6239
+
6240
+ See Also
6241
+ --------
6242
+ numpy.take : Equivalent function for ndarrays.
6243
+ compress : Take elements using a boolean mask.
6244
+ take_along_axis : Take elements by matching the array and the index arrays.
6245
+
6246
+ Notes
6247
+ -----
6248
+ This function behaves similarly to `numpy.take`, but it handles masked
6249
+ values. The mask is retained in the output array, and masked values
6250
+ in the input array remain masked in the output.
6251
+
6252
+ Examples
6253
+ --------
6254
+ >>> import numpy as np
6255
+ >>> a = np.ma.array([4, 3, 5, 7, 6, 8], mask=[0, 0, 1, 0, 1, 0])
6256
+ >>> indices = [0, 1, 4]
6257
+ >>> np.ma.take(a, indices)
6258
+ masked_array(data=[4, 3, --],
6259
+ mask=[False, False, True],
6260
+ fill_value=999999)
6261
+
6262
+ When `indices` is not one-dimensional, the output also has these dimensions:
6263
+
6264
+ >>> np.ma.take(a, [[0, 1], [2, 3]])
6265
+ masked_array(data=[[4, 3],
6266
+ [--, 7]],
6267
+ mask=[[False, False],
6268
+ [ True, False]],
6269
+ fill_value=999999)
6270
+ """
6206
6271
(_data , _mask ) = (self ._data , self ._mask )
6207
6272
cls = type (self )
6208
6273
# Make sure the indices are not masked
@@ -7086,6 +7151,7 @@ def __call__(self, a, *args, **params):
7086
7151
7087
7152
def take (a , indices , axis = None , out = None , mode = 'raise' ):
7088
7153
"""
7154
+
7089
7155
"""
7090
7156
a = masked_array (a )
7091
7157
return a .take (indices , axis = axis , out = out , mode = mode )
0 commit comments