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

Method isel

xarray/core/variable.py:1108–1141  ·  view source on GitHub ↗

Return a new array indexed along the specified dimension(s). Parameters ---------- **indexers : {dim: indexer, ...} Keyword arguments with names matching dimensions and values given by integers, slice objects or arrays. missing_dims : {"raise"

(
        self,
        indexers: Mapping[Any, Any] | None = None,
        missing_dims: ErrorOptionsWithWarn = "raise",
        **indexers_kwargs: Any,
    )

Source from the content-addressed store, hash-verified

1106 return self.isel({dim: np.concatenate(indices)})
1107
1108 def isel(
1109 self,
1110 indexers: Mapping[Any, Any] | None = None,
1111 missing_dims: ErrorOptionsWithWarn = "raise",
1112 **indexers_kwargs: Any,
1113 ) -> Self:
1114 """Return a new array indexed along the specified dimension(s).
1115
1116 Parameters
1117 ----------
1118 **indexers : {dim: indexer, ...}
1119 Keyword arguments with names matching dimensions and values given
1120 by integers, slice objects or arrays.
1121 missing_dims : {"raise", "warn", "ignore"}, default: "raise"
1122 What to do if dimensions that should be selected from are not present in the
1123 DataArray:
1124 - "raise": raise an exception
1125 - "warn": raise a warning, and ignore the missing dimensions
1126 - "ignore": ignore the missing dimensions
1127
1128 Returns
1129 -------
1130 obj : Array object
1131 A new Array with the selected data and dimensions. In general,
1132 the new variable's data will be a view of this variable's data,
1133 unless numpy fancy indexing was triggered by using an array
1134 indexer, in which case the data will be a copy.
1135 """
1136 indexers = either_dict_or_kwargs(indexers, indexers_kwargs, "isel")
1137
1138 indexers = drop_dims_from_indexers(indexers, self.dims, missing_dims)
1139
1140 key = tuple(indexers.get(dim, slice(None)) for dim in self.dims)
1141 return self[key]
1142
1143 def squeeze(self, dim=None):
1144 """Return a new object with squeezed data.

Callers 5

_shuffleMethod · 0.95
squeezeMethod · 0.95
test_iselMethod · 0.95
test_iselMethod · 0.95
coarsen_reshapeMethod · 0.45

Calls 3

either_dict_or_kwargsFunction · 0.90
drop_dims_from_indexersFunction · 0.90
getMethod · 0.45

Tested by 2

test_iselMethod · 0.76
test_iselMethod · 0.76