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

Method _maybe_cast_slice_bound

xarray/coding/cftimeindex.py:418–429  ·  view source on GitHub ↗

Adapted from pandas.tseries.index.DatetimeIndex._maybe_cast_slice_bound

(self, label, side)

Source from the content-addressed store, hash-verified

416 return super().get_loc(key)
417
418 def _maybe_cast_slice_bound(self, label, side):
419 """Adapted from
420 pandas.tseries.index.DatetimeIndex._maybe_cast_slice_bound
421 """
422 if not isinstance(label, str):
423 return label
424
425 parsed, resolution = _parse_iso8601(self.date_type, label)
426 start, end = _parsed_string_to_bounds(self.date_type, resolution, parsed)
427 if self.is_monotonic_decreasing and len(self) > 1:
428 return end if side == "left" else start
429 return start if side == "left" else end
430
431 # TODO: Add ability to use integer range outside of iloc?
432 # e.g. series[1:5].

Callers

nothing calls this directly

Calls 2

_parse_iso8601Function · 0.90
_parsed_string_to_boundsFunction · 0.85

Tested by

no test coverage detected