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

Method __mul__

xarray/coding/cftime_offsets.py:217–230  ·  view source on GitHub ↗
(self, other: int | float)

Source from the content-addressed store, hash-verified

215 raise ValueError("Could not convert to integer offset at any resolution")
216
217 def __mul__(self, other: int | float) -> Tick:
218 if not isinstance(other, int | float):
219 return NotImplemented
220 if isinstance(other, float):
221 n = other * self.n
222 # If the new `n` is an integer, we can represent it using the
223 # same BaseCFTimeOffset subclass as self, otherwise we need to move up
224 # to a higher-resolution subclass
225 if np.isclose(n % 1, 0):
226 return type(self)(int(n))
227
228 new_self = self._next_higher_resolution()
229 return new_self * other
230 return type(self)(n=other * self.n)
231
232 def as_timedelta(self) -> timedelta:
233 """All Tick subclasses must implement an as_timedelta method."""

Callers

nothing calls this directly

Calls 2

typeFunction · 0.85

Tested by

no test coverage detected