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

Method __getitem__

numpy/core/tests/test_arrayprint.py:103–107  ·  view source on GitHub ↗
(self, item)

Source from the content-addressed store, hash-verified

101 # gh-10663
102 class DuckCounter(np.ndarray):
103 def __getitem__(self, item):
104 result = super().__getitem__(item)
105 if not isinstance(result, DuckCounter):
106 result = result[...].view(DuckCounter)
107 return result
108
109 def to_string(self):
110 return {0: 'zero', 1: 'one', 2: 'two'}.get(self.item(), 'many')

Callers

nothing calls this directly

Calls 2

__getitem__Method · 0.45
viewMethod · 0.45

Tested by

no test coverage detected