MCPcopy Create free account
hub / github.com/pydata/xarray / _safe_setitem

Method _safe_setitem

xarray/core/indexing.py:1718–1729  ·  view source on GitHub ↗
(self, array, key: tuple[Any, ...], value: Any)

Source from the content-addressed store, hash-verified

1716 return array[key]
1717
1718 def _safe_setitem(self, array, key: tuple[Any, ...], value: Any) -> None:
1719 try:
1720 array[key] = value
1721 except ValueError as exc:
1722 # More informative exception if read-only view
1723 if not array.flags.writeable and not array.flags.owndata:
1724 raise ValueError(
1725 "Assignment destination is a view. "
1726 "Do you want to .copy() array first?"
1727 ) from exc
1728 else:
1729 raise exc
1730
1731 def _oindex_set(self, indexer: OuterIndexer, value: Any) -> None:
1732 key = _outer_to_numpy_indexer(indexer, self.array.shape)

Callers 3

_oindex_setMethod · 0.95
_vindex_setMethod · 0.95
__setitem__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected