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

Function _floatize_x

xarray/core/missing.py:597–613  ·  view source on GitHub ↗

Make x and new_x float. This is particularly useful for datetime dtype.

(
    x: list[Variable], new_x: list[Variable]
)

Source from the content-addressed store, hash-verified

595
596
597def _floatize_x(
598 x: list[Variable], new_x: list[Variable]
599) -> tuple[list[Variable], list[Variable]]:
600 """Make x and new_x float.
601 This is particularly useful for datetime dtype.
602 """
603 for i in range(len(x)):
604 if _contains_datetime_like_objects(x[i]):
605 # Scipy casts coordinates to np.float64, which is not accurate
606 # enough for datetime64 (uses 64bit integer).
607 # We assume that the most of the bits are used to represent the
608 # offset (min(x)) and the variation (x - min(x)) can be
609 # represented by float.
610 xmin = x[i].values.min()
611 x[i] = x[i]._to_numeric(offset=xmin, dtype=np.float64)
612 new_x[i] = new_x[i]._to_numeric(offset=xmin, dtype=np.float64)
613 return x, new_x
614
615
616def interp(

Callers 1

_interpndFunction · 0.85

Calls 3

_to_numericMethod · 0.80
minMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…