MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _dt64_to_ordinalf

Function _dt64_to_ordinalf

lib/matplotlib/dates.py:310–329  ·  view source on GitHub ↗

Convert a `numpy.ndarray` of np.datetime64 to Gregorian date as UTC float relative to the epoch (see `.get_epoch`). Roundoff is float64 precision. Practically: microseconds for dates between 290301 BC, 294241 AD, milliseconds for larger dates (see `numpy.datetime64`).

(d)

Source from the content-addressed store, hash-verified

308
309
310def _dt64_to_ordinalf(d):
311 """
312 Convert a `numpy.ndarray` of np.datetime64 to
313 Gregorian date as UTC float relative to the epoch (see `.get_epoch`).
314 Roundoff is float64 precision. Practically: microseconds for dates
315 between 290301 BC, 294241 AD, milliseconds for larger dates
316 (see `numpy.datetime64`).
317 """
318
319 # the "extra" ensures that we at least allow the dynamic range out to
320 # seconds. That should get out to +/-2e11 years.
321 dseconds = d.astype('datetime64[s]')
322 extra = (d - dseconds).astype('timedelta64[ns]')
323 t0 = np.datetime64(get_epoch(), 's')
324 dt = (dseconds - t0).astype(np.float64)
325 dt += extra.astype(np.float64) / 1.0e9
326 dt = dt / SEC_PER_DAY
327
328 dt[np.isnat(d)] = np.nan
329 return dt
330
331
332def _from_ordinalf(x, tz=None):

Callers 1

date2numFunction · 0.85

Calls 1

get_epochFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…