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

Method __getitem__

numpy/core/records.py:508–523  ·  view source on GitHub ↗
(self, indx)

Source from the content-addressed store, hash-verified

506 return self.setfield(val, *res)
507
508 def __getitem__(self, indx):
509 obj = super().__getitem__(indx)
510
511 # copy behavior of getattr, except that here
512 # we might also be returning a single element
513 if isinstance(obj, ndarray):
514 if obj.dtype.names is not None:
515 obj = obj.view(type(self))
516 if issubclass(obj.dtype.type, nt.void):
517 return obj.view(dtype=(self.dtype.type, obj.dtype))
518 return obj
519 else:
520 return obj.view(type=ndarray)
521 else:
522 # return a single element
523 return obj
524
525 def __repr__(self):
526

Callers

nothing calls this directly

Calls 2

__getitem__Method · 0.45
viewMethod · 0.45

Tested by

no test coverage detected