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

Method __getitem__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

isscalarFunction · 0.90

Tested by

no test coverage detected