MCPcopy Create free account
hub / github.com/numpy/numpy / __getitem__

Method __getitem__

numpy/ma/mrecords.py:294–324  ·  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

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

Callers

nothing calls this directly

Calls 2

__getattribute__Method · 0.45
viewMethod · 0.45

Tested by

no test coverage detected