home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1123693473

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/6589#issuecomment-1123693473 https://api.github.com/repos/pydata/xarray/issues/6589 1123693473 IC_kwDOAMm_X85C-jOh 6628425 2022-05-11T12:28:02Z 2022-05-11T12:28:02Z MEMBER

Thanks @sappjw -- this is a distillation of the bug derived from your example:

```

import numpy as np import xarray as xr xr.coding.times.decode_cf_datetime(np.uint32(50), "seconds since 2018-08-22T03:23:03Z") array('2018-08-22T03:23:05.755359744', dtype='datetime64[ns]') ```

I believe the solution is to also cast all unsigned integer values -- anything with dtype.kind == "u" -- to np.int64 values here: https://github.com/pydata/xarray/blob/770e878663b03bd83d2c28af0643770bdd43c3da/xarray/coding/times.py#L220-L224 Ordinarily we might worry about overflow in this context -- i.e. some np.uint64 values cannot be represented by np.int64 values -- but I believe since we already verify that the minimum and maximum value of the input array can be represented by nanosecond-precision timedelta values, we can safely do this.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1231399637
Powered by Datasette · Queries took 0.76ms · About: xarray-datasette