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

Method __getitem__

numpy/matrixlib/defmatrix.py:195–219  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

193 return
194
195 def __getitem__(self, index):
196 self._getitem = True
197
198 try:
199 out = N.ndarray.__getitem__(self, index)
200 finally:
201 self._getitem = False
202
203 if not isinstance(out, N.ndarray):
204 return out
205
206 if out.ndim == 0:
207 return out[()]
208 if out.ndim == 1:
209 sh = out.shape[0]
210 # Determine when we should have a column array
211 try:
212 n = len(index)
213 except Exception:
214 n = 0
215 if n > 1 and isscalar(index[1]):
216 out = out.reshape((sh, 1))
217 else:
218 out = out.reshape((1, sh))
219 return out
220
221 def __mul__(self, other):
222 if isinstance(other, (N.ndarray, list, tuple)):

Callers

nothing calls this directly

Calls 2

isscalarFunction · 0.90
reshapeMethod · 0.80

Tested by

no test coverage detected