home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 527236743

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/3238#issuecomment-527236743 https://api.github.com/repos/pydata/xarray/issues/3238 527236743 MDEyOklzc3VlQ29tbWVudDUyNzIzNjc0Mw== 14808389 2019-09-02T20:17:36Z 2019-09-02T21:05:13Z MEMBER

np.prod: seems fair, and I don't especially need that function as I have been copying its use from test_sparse.py (though I realize now that there only the method is used). However, using array.prod() works on quantities, so I would expect np.prod to delegate to it. Same with any() and all().

np.median: this also happens in my environment, so you can rule out the environment. Calling it on quantities instead of data arrays works, so the issue is within xarray. Interestingly, outside of pytest: ```python

xr.DataArray(data=np.arange(10).astype(int) * ureg.m).median() <xarray.DataArray ()> <Quantity(4.5, 'meter')> xr.DataArray(data=np.arange(10).astype(int) * ureg.m).median() <xarray.DataArray ()> array(4.5) ``` which seems to be a manifestation of #3241 (which is the reason I now always try different dtypes). I guess that one is not really fixed? Also, would it be better to have a test to check the methods in addition to the numpy functions?

Indexing: when I wrote "indexing works" I meant that my tests for sel(), isel() and loc mostly pass (except from the "calling int / float on scalar results" issue). So when calling sel() and loc with either no units, dimensionless or incompatible units (but existing magnitudes), a KeyError is raised. In the case of both compatible units and existing magnitudes the results are also correct, but scalars trigger the error above. Edit: I have been checking the indexing outside of pytest and there the units are not respected. I have no idea why, but I suspect it is at least related to the problem with np.median. Anyway, what is tested is: ```python

array = np.linspace(5, 10, 20).astype(dtype) * ureg.m x = np.arange(len(array)) * ureg.s data_array = xr.DataArray(data=array, coords={"x": x}, dims=["x"]) with pytest.raises(KeyError): ... data_array.sel(x=[10, 5, 13]) with pytest.raises(KeyError): ... data_array.sel(x=[10, 5, 13] * ureg.dimensionless) with pytest.raises(KeyError): ... data_array.sel(x=[10, 5, 13] * ureg.m)

repr of DataArray fails with DimensionalityError

data_array.sel(x=[10, 5, 13] * ureg.s).data <Quantity([7.63157895 6.31578947 8.42105263], 'meter')> ```

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