{"database": "github", "table": "issues", "is_view": false, "human_description_en": "where state_reason = \"completed\", \"updated_at\" is on date 2021-09-29 and user = 35968931 sorted by updated_at descending", "rows": [[935062144, "MDU6SXNzdWU5MzUwNjIxNDQ=", 5559, "UserWarning when wrapping pint & dask arrays together", 35968931, "closed", 0, null, null, 4, "2021-07-01T17:25:03Z", "2021-09-29T17:48:39Z", "2021-09-29T17:48:39Z", "MEMBER", null, null, null, "With `pint-xarray` you can create a chunked, unit-aware xarray object, but calling a calculation method and then computing doesn't appear to behave as hoped.\r\n\r\n```python\r\nda = xr.DataArray([1,2,3], attrs={'units': 'metres'})\r\n\r\nchunked = da.chunk(1).pint.quantify()\r\n```\r\n\r\n```python\r\nprint(chunked.compute())\r\n```\r\n```\r\n<xarray.DataArray (dim_0: 3)>\r\n<Quantity([1 2 3], 'meter')>\r\nDimensions without coordinates: dim_0\r\n```\r\nSo far this is fine, but if we try to take a mean before computing we get\r\n\r\n```python\r\nprint(chunked.mean().compute())\r\n```\r\n```\r\n<xarray.DataArray ()>\r\n<Quantity(dask.array<true_divide, shape=(), dtype=float64, chunksize=(), chunktype=numpy.ndarray>, 'meter')>\r\n/home/tegn500/miniconda3/envs/py38-mamba/lib/python3.8/site-packages/dask/array/core.py:3139: UserWarning: Passing an object to dask.array.from_array which is already a Dask collection. This can lead to unexpected behavior.\r\n  warnings.warn(\r\n```\r\nThis is not correct: as well as the UserWarning, the return value of compute is a dask array, meaning we need to compute a second time to actually get the answer:\r\n```python\r\nprint(chunked.mean().compute().compute())\r\n```\r\n```\r\n<xarray.DataArray ()>\r\n<Quantity(2.0, 'meter')>\r\n/home/tegn500/miniconda3/envs/py38-mamba/lib/python3.8/site-packages/dask/array/core.py:3139: UserWarning: Passing an object to dask.array.from_array which is already a Dask collection. This can lead to unexpected behavior.\r\n  warnings.warn(\r\n```\r\n\r\nIf we try chunking the other way (`chunked = da.pint.quantify().pint.chunk(1)`) then we get all the same results.\r\n\r\nxref https://github.com/xarray-contrib/pint-xarray/issues/116 and https://github.com/pydata/xarray/pull/4972 @keewis \r\n\r\n\r\n", "{\"url\": \"https://api.github.com/repos/pydata/xarray/issues/5559/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", null, "completed", 13221727, "issue"]], "truncated": false, "filtered_table_rows_count": 1, "expanded_columns": [], "expandable_columns": [[{"column": "repo", "other_table": "repos", "other_column": "id"}, "name"], [{"column": "milestone", "other_table": "milestones", "other_column": "id"}, "title"], [{"column": "assignee", "other_table": "users", "other_column": "id"}, "login"], [{"column": "user", "other_table": "users", "other_column": "id"}, "login"]], "columns": ["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"], "primary_keys": ["id"], "units": {}, "query": {"sql": "select 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 from issues where \"state_reason\" = :p0 and date(\"updated_at\") = :p1 and \"user\" = :p2 order by updated_at desc limit 101", "params": {"p0": "completed", "p1": "2021-09-29", "p2": "35968931"}}, "facet_results": {"state": {"name": "state", "type": "column", "hideable": false, "toggle_url": "/github/issues.json?state_reason=completed&updated_at__date=2021-09-29&user=35968931", "results": [{"value": "closed", "label": "closed", "count": 1, "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?state_reason=completed&updated_at__date=2021-09-29&user=35968931&state=closed", "selected": false}], "truncated": false}, "repo": {"name": "repo", "type": "column", "hideable": false, "toggle_url": "/github/issues.json?state_reason=completed&updated_at__date=2021-09-29&user=35968931", "results": [{"value": 13221727, "label": "xarray", "count": 1, "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?state_reason=completed&updated_at__date=2021-09-29&user=35968931&repo=13221727", "selected": false}], "truncated": false}, "type": {"name": "type", "type": "column", "hideable": false, "toggle_url": "/github/issues.json?state_reason=completed&updated_at__date=2021-09-29&user=35968931", "results": [{"value": "issue", "label": "issue", "count": 1, "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?state_reason=completed&updated_at__date=2021-09-29&user=35968931&type=issue", "selected": false}], "truncated": false}}, "suggested_facets": [{"name": "created_at", "type": "date", "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?state_reason=completed&updated_at__date=2021-09-29&user=35968931&_facet_date=created_at"}, {"name": "updated_at", "type": "date", "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?state_reason=completed&updated_at__date=2021-09-29&user=35968931&_facet_date=updated_at"}, {"name": "closed_at", "type": "date", "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?state_reason=completed&updated_at__date=2021-09-29&user=35968931&_facet_date=closed_at"}], "next": null, "next_url": null, "private": false, "allow_execute_sql": true, "query_ms": 326.04974415153265}