issue_comments: 275909069
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/1208#issuecomment-275909069 | https://api.github.com/repos/pydata/xarray/issues/1208 | 275909069 | MDEyOklzc3VlQ29tbWVudDI3NTkwOTA2OQ== | 10050469 | 2017-01-29T11:53:27Z | 2017-01-29T11:53:27Z | MEMBER | @shoyer there is something very weird going on. See the following example: ```python import numpy as np import bottleneck as bn import xarray as xr da = xr.DataArray(np.ones((10, 20)).astype(np.int), dims=['x', 'y'],
coords={'abc':('y', np.array(['a'] * 9 + ['c'] + ['b'] * 10))})
np.testing.assert_allclose(np.sum(da[:, 9:10]), bn.nansum(da[:, 9:10])) # this will allways work
np.testing.assert_allclose(da.groupby('abc').reduce(np.sum), da.groupby('abc').sum()) # this won't
```AssertionError Traceback (most recent call last) <ipython-input-95-d34b19396eb5> in <module>() 2 coords={'abc':('y', np.array(['a'] * 9 + ['c'] + ['b'] * 10))}) 3 np.testing.assert_allclose(np.sum(da[:, 9:10]), bn.nansum(da[:, 9:10])) ----> 4 np.testing.assert_allclose(da.groupby('abc').reduce(np.sum), da.groupby('abc').sum()) /home/mowglie/.pyvirtualenvs/py3/lib/python3.4/site-packages/numpy/testing/utils.py in assert_allclose(actual, desired, rtol, atol, equal_nan, err_msg, verbose) 1409 header = 'Not equal to tolerance rtol=%g, atol=%g' % (rtol, atol) 1410 assert_array_compare(compare, actual, desired, err_msg=str(err_msg), -> 1411 verbose=verbose, header=header, equal_nan=equal_nan) 1412 1413 /home/mowglie/.pyvirtualenvs/py3/lib/python3.4/site-packages/numpy/testing/utils.py in assert_array_compare(comparison, x, y, err_msg, verbose, header, precision, equal_nan) 794 names=('x', 'y'), precision=precision) 795 if not cond: --> 796 raise AssertionError(msg) 797 except ValueError: 798 import traceback AssertionError: Not equal to tolerance rtol=1e-07, atol=0 (mismatch 33.33333333333333%) x: array([ 90., 100., 10.]) y: array([ 90., 100., 1.]) ``` So the new operation is applied only to the first element of the grouped selection, and I didn't manage to us bottleneck only to replicate this (since the first assertion always passes). Before I dig into this I'd like to have your opinion on this: any idea on what could go wrong here? |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
200908727 |