MCPcopy
hub / github.com/pydata/xarray / _is_time_like

Function _is_time_like

xarray/coding/variables.py:137–164  ·  view source on GitHub ↗
(units)

Source from the content-addressed store, hash-verified

135
136
137def _is_time_like(units):
138 # test for time-like
139 # return "datetime" for datetime-like
140 # return "timedelta" for timedelta-like
141 if units is None:
142 return False
143 time_strings = [
144 "days",
145 "hours",
146 "minutes",
147 "seconds",
148 "milliseconds",
149 "microseconds",
150 "nanoseconds",
151 ]
152 units = str(units)
153 # to prevent detecting units like `days accumulated` as time-like
154 # special casing for datetime-units and timedelta-units (GH-8269)
155 if "since" in units:
156 from xarray.coding.times import _unpack_netcdf_time_units
157
158 try:
159 _unpack_netcdf_time_units(units)
160 except ValueError:
161 return False
162 return "datetime"
163 else:
164 return "timedelta" if any(tstr == units for tstr in time_strings) else False
165
166
167def _check_fill_values(attrs, name, dtype):

Callers 3

encodeMethod · 0.85
decodeMethod · 0.85
decodeMethod · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…