home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 602053723

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/3751#issuecomment-602053723 https://api.github.com/repos/pydata/xarray/issues/3751 602053723 MDEyOklzc3VlQ29tbWVudDYwMjA1MzcyMw== 6628425 2020-03-21T14:35:11Z 2020-03-21T14:35:33Z MEMBER

Thanks @jbrockmendel; it's great to see that pandas-dev/pandas#32684 was merged.

Regarding #3764, I gave things a try with pandas master and removing our overrides to _get_nearest_indexer and _filter_indexer_tolerance. I got similar failures to what we were getting before.

Example failure

``` _______________________________ test_sel_date_scalar_nearest[proleptic_gregorian-sel_kwargs2] _______________________________ da = <xarray.DataArray (time: 4)> array([1, 2, 3, 4]) Coordinates: * time (time) object 0001-01-01 00:00:00 ... 0002-02-01 00:00:00 date_type = <class 'cftime._cftime.DatetimeProlepticGregorian'> index = CFTimeIndex([0001-01-01 00:00:00, 0001-02-01 00:00:00, 0002-01-01 00:00:00, 0002-02-01 00:00:00], dtype='object') sel_kwargs = {'method': 'nearest', 'tolerance': datetime.timedelta(days=1800000)} @requires_cftime @pytest.mark.parametrize( "sel_kwargs", [ {"method": "nearest"}, {"method": "nearest", "tolerance": timedelta(days=70)}, {"method": "nearest", "tolerance": timedelta(days=1800000)}, ], ) def test_sel_date_scalar_nearest(da, date_type, index, sel_kwargs): expected = xr.DataArray(2).assign_coords(time=index[1]) > result = da.sel(time=date_type(1, 4, 1), **sel_kwargs) test_cftimeindex.py:471: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../core/dataarray.py:1061: in sel **indexers_kwargs, ../core/dataset.py:2066: in sel self, indexers=indexers, method=method, tolerance=tolerance ../core/coordinates.py:392: in remap_label_indexers obj, v_indexers, method=method, tolerance=tolerance ../core/indexing.py:270: in remap_label_indexers idxr, new_idx = convert_label_indexer(index, label, dim, method, tolerance) ../core/indexing.py:190: in convert_label_indexer label.item(), method=method, tolerance=tolerance ../coding/cftimeindex.py:365: in get_loc return pd.Index.get_loc(self, key, method=method, tolerance=tolerance) ../../../pandas/pandas/core/indexes/base.py:2874: in get_loc indexer = self.get_indexer([key], method=method, tolerance=tolerance) ../../../pandas/pandas/core/indexes/base.py:2967: in get_indexer indexer = self._get_nearest_indexer(target, limit, tolerance) ../../../pandas/pandas/core/indexes/base.py:3062: in _get_nearest_indexer indexer = self._filter_indexer_tolerance(target, indexer, tolerance) ../../../pandas/pandas/core/indexes/base.py:3069: in _filter_indexer_tolerance indexer = np.where(distance <= tolerance, indexer, -1) ../../../pandas/pandas/core/indexes/extension.py:129: in wrapper return op(other) ../../../pandas/pandas/core/ops/common.py:63: in new_method return method(self, other) ../../../pandas/pandas/core/arrays/datetimelike.py:75: in wrapper other = self._scalar_type(other) pandas/_libs/tslibs/timedeltas.pyx:1233: in pandas._libs.tslibs.timedeltas.Timedelta.__new__ ??? pandas/_libs/tslibs/timedeltas.pyx:209: in pandas._libs.tslibs.timedeltas.convert_to_timedelta64 ??? _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > ??? E OverflowError: Python int too large to convert to C long pandas/_libs/tslibs/timedeltas.pyx:154: OverflowError ```

In my testing, I can only get things to work if the argument to abs (or np.abs) is a NumPy array (instead of an Index). An upstream change like this would work (it still maintains the behavior desired from pandas-dev/pandas#31511), but I'm not sure how palatable it would be.

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