home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 224878728

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
224878728 MDU6SXNzdWUyMjQ4Nzg3Mjg= 1388 argmin / argmax behavior doesn't match documentation 23484003 closed 0     11 2017-04-27T18:50:36Z 2020-07-09T21:32:52Z 2020-07-09T21:32:52Z NONE      

The documentation reads

Returns:
reduced : DataArray New DataArray object with argmin applied to its data and the indicated dimension(s) removed.

However, what happens is that the numpy argmin output (single index into the flattened array at which the maximum/minimum is found) is wrapped in a dummy DataArray (similar behavior for Datasets also):

[In1]: x = np.linspace(0,1,5)

[In2]: y = np.linspace(0,1,6)

[In3]: z = np.random.randn(5,6)

[In4]: example = xr.DataArray(z, {'x':x,'y':y},('x','y'))

[In5]: print(example.argmin())

[Out5]: <xarray.DataArray ()>

        array(10)

[In6]: example_ds = xr.Dataset(data_vars={'ex':example})

[In7]: print(example_ds.argmin())

[Out7]: <xarray.Dataset>

        Dimensions:  ()

        Data variables:

        ex       int64 10

I realize that maybe for compatibility reasons it is necessary to make Datasets/DataArrays do this, but it seems like the documented behavior would be nicer. At any rate, the documentation should match the behavior.

Specs: python 2.7 xarray 0.9.1 numpy 1.11.3

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1388/reactions",
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 11 rows from issue in issue_comments
Powered by Datasette · Queries took 78.358ms · About: xarray-datasette