home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 455584540

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/pull/2593#issuecomment-455584540 https://api.github.com/repos/pydata/xarray/issues/2593 455584540 MDEyOklzc3VlQ29tbWVudDQ1NTU4NDU0MA== 8708062 2019-01-18T15:28:36Z 2019-01-18T15:28:36Z CONTRIBUTOR

Your impressions are correct, sorry if my earlier comments confused you. I was just guessing that imprecise first and last values might be the cause for extra bins; I haven't actually tested if it was actually true.

The first and last values are returned by _adjust_bin_anchored when isinstance(offset, CFTIME_TICKS). Since date subtraction happens within _adjust_bin_anchored, some test cases have imprecise first and last values.

I'll provide examples of extra bins later in the day.

For now, here's an example of the datetime imprecision in _adjust_bin_anchored:

python import xarray as xr import numpy as np from xarray.coding.cftime_offsets import normalize_date, to_offset from xarray.core.utils import safe_cast_to_index freq = '600003T' closed = 'right' label = 'left' base = 12 time_range_kwargs = dict(start='2004-01-01T12:07:01', periods=37, freq='A') cftime_index = xr.cftime_range(**time_range_kwargs) da_cftime = xr.DataArray(np.arange(100., 100. + cftime_index.size), [('time', cftime_index)]) group = da_cftime['time'] index = safe_cast_to_index(group) offset = to_offset(freq) first = index.min() last = index.max() base = base % offset.n start_day = normalize_date(first) base_td = type(offset)(n=base).as_timedelta() start_day += base_td foffset = (first - start_day) % offset.as_timedelta() loffset = (last - start_day) % offset.as_timedelta() print(first, '\n', start_day, '\n', base_td, '\n', foffset, '\n', loffset, '\n', first - start_day, '\n', last - start_day)

which gave me

2004-12-31 12:07:01 2004-12-31 00:12:00 0:12:00 11:55:01.000008 232 days, 18:22:01.000008 11:55:01.000008 13149 days, 11:55:01.000008

The extra 8 microseconds shouldn't be there.

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