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

Method _update_coords

xarray/core/coordinates.py:1035–1058  ·  view source on GitHub ↗
(
        self, coords: dict[Hashable, Variable], indexes: dict[Hashable, Index]
    )

Source from the content-addressed store, hash-verified

1033 return self._data.dataset._copy_listed(self._names)
1034
1035 def _update_coords(
1036 self, coords: dict[Hashable, Variable], indexes: dict[Hashable, Index]
1037 ) -> None:
1038 from xarray.core.datatree import check_alignment
1039
1040 # create updated node (`.to_dataset` makes a copy so this doesn't modify in-place)
1041 node_ds = self._data.to_dataset(inherit=False)
1042 node_ds.coords._update_coords(coords, indexes)
1043
1044 # check consistency *before* modifying anything in-place
1045 # TODO can we clean up the signature of check_alignment to make this less awkward?
1046 if self._data.parent is not None:
1047 parent_ds = self._data.parent._to_dataset_view(
1048 inherit=True, rebuild_dims=False
1049 )
1050 else:
1051 parent_ds = None
1052 check_alignment(self._data.path, node_ds, parent_ds, self._data.children)
1053
1054 # assign updated attributes
1055 coord_variables = dict(node_ds.coords.variables)
1056 self._data._node_coord_variables = coord_variables
1057 self._data._node_dims = node_ds._dims
1058 self._data._node_indexes = node_ds._indexes
1059
1060 def _drop_coords(self, coord_names):
1061 # should drop indexed coordinates only

Callers

nothing calls this directly

Calls 4

check_alignmentFunction · 0.90
_to_dataset_viewMethod · 0.80
to_datasetMethod · 0.45
_update_coordsMethod · 0.45

Tested by

no test coverage detected