MCPcopy Index your code
hub / github.com/pydata/xarray / __getitem__

Method __getitem__

xarray/core/extension_array.py:274–284  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

272 return ufunc(*inputs, **kwargs)
273
274 def __getitem__(self, key) -> PandasExtensionArray[T_ExtensionArray]:
275 if (
276 isinstance(key, tuple) and len(key) == 1
277 ): # pyarrow type arrays can't handle single-length tuples
278 (key,) = key
279 item = self.array[key]
280 if is_allowed_extension_array(item):
281 return PandasExtensionArray(item)
282 if is_scalar(item) or isinstance(key, int):
283 return PandasExtensionArray(type(self.array)._from_sequence([item])) # type: ignore[call-arg,attr-defined,unused-ignore]
284 return PandasExtensionArray(item)
285
286 def __setitem__(self, key, val):
287 self.array[key] = val

Callers

nothing calls this directly

Calls 4

typeFunction · 0.85
is_scalarFunction · 0.70

Tested by

no test coverage detected