MCPcopy Index your code
hub / github.com/numpy/numpy / __getitem__

Method __getitem__

numpy/ma/mrecords.py:283–313  ·  view source on GitHub ↗

Returns all the fields sharing the same fieldname base. The fieldname base is either `_data` or `_mask`.

(self, indx)

Source from the content-addressed store, hash-verified

281 return obj
282
283 def __getitem__(self, indx):
284 """
285 Returns all the fields sharing the same fieldname base.
286
287 The fieldname base is either `_data` or `_mask`.
288
289 """
290 _localdict = self.__dict__
291 _mask = np.ndarray.__getattribute__(self, '_mask')
292 _data = np.ndarray.view(self, _localdict['_baseclass'])
293 # We want a field
294 if isinstance(indx, str):
295 # Make sure _sharedmask is True to propagate back to _fieldmask
296 # Don't use _set_mask, there are some copies being made that
297 # break propagation Don't force the mask to nomask, that wreaks
298 # easy masking
299 obj = _data[indx].view(ma.MaskedArray)
300 obj._mask = _mask[indx]
301 obj._sharedmask = True
302 fval = _localdict['_fill_value']
303 if fval is not None:
304 obj._fill_value = fval[indx]
305 # Force to masked if the mask is True
306 if not obj.ndim and obj._mask:
307 return ma.masked
308 return obj
309 # We want some elements.
310 # First, the data.
311 obj = np.asarray(_data[indx]).view(mrecarray)
312 obj._mask = np.asarray(_mask[indx]).view(np.recarray)
313 return obj
314
315 def __setitem__(self, indx, value):
316 """

Callers

nothing calls this directly

Calls 2

__getattribute__Method · 0.45
viewMethod · 0.45

Tested by

no test coverage detected