{"database": "github", "table": "issues", "is_view": false, "human_description_en": "where state_reason = \"completed\", \"updated_at\" is on date 2018-10-08 and user = 35968931 sorted by updated_at descending", "rows": [[354923742, "MDU6SXNzdWUzNTQ5MjM3NDI=", 2388, "Test equality of DataArrays up to transposition", 35968931, "closed", 0, null, null, 2, "2018-08-28T22:13:01Z", "2018-10-08T12:25:46Z", "2018-10-08T12:25:46Z", "MEMBER", null, null, null, "While writing some unit tests to check I had wrapped `np.gradient` correctly with `xr.apply_ufunc`, I came unstuck because my results were equivalent except for transposed dimensions. It took me a while to realise that `xarray.testing.asset_equal` considers two DataArrays equal only if their dimensions are in the same order, because intuitively that shouldn't matter in the context of xarray's data model.\r\n\r\n\r\nA simple example to demonstrate what I mean:\r\n```python\r\n# Create two functionally-equivalent dataarrays\r\ndata = np.random.randn(4, 3)\r\nda1 = xr.DataArray(data, dims=('x', 'y'))\r\nda2 = xr.DataArray(data.T, dims=('y', 'x'))\r\n\r\n# This test will fail\r\nxarray.tests.assert_equal(da1, da2)\r\n```\r\nThis test fails, with output\r\n```\r\nE       AssertionError: <xarray.DataArray (x: 4, y: 3)>\r\nE       array([[ 0.761038,  0.121675,  0.443863],\r\nE              [ 0.333674,  1.494079, -0.205158],\r\nE              [ 0.313068, -0.854096, -2.55299 ],\r\nE              [ 0.653619,  0.864436, -0.742165]])\r\nE       Coordinates:\r\nE         * x        (x) int64 5 7 9 11\r\nE         * y        (y) int64 1 4 6\r\nE       <xarray.DataArray (y: 3, x: 4)>\r\nE       array([[ 0.761038,  0.333674,  0.313068,  0.653619],\r\nE              [ 0.121675,  1.494079, -0.854096,  0.864436],\r\nE              [ 0.443863, -0.205158, -2.55299 , -0.742165]])\r\nE       Coordinates:\r\nE         * x        (x) int64 5 7 9 11\r\nE         * y        (y) int64 1 4 6\r\n```\r\neven though these two DataArrays are functionally-equivalent for all xarray operations you could perform with them.\r\n\r\nIt would make certain types of unit tests simpler and clearer to have a function like\r\n```python\r\nxarray.tests.assert_equivalent(da1, da2)\r\n```\r\nwhich would return true if one DataArray can be formed from the other by transposition.\r\n\r\nI would have thought that a test that does this would just transpose one into the shape of the other before comparison?", "{\"url\": \"https://api.github.com/repos/pydata/xarray/issues/2388/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": "2018-10-08", "p2": "35968931"}}, "facet_results": {"state": {"name": "state", "type": "column", "hideable": false, "toggle_url": "/github/issues.json?state_reason=completed&updated_at__date=2018-10-08&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=2018-10-08&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=2018-10-08&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=2018-10-08&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=2018-10-08&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=2018-10-08&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=2018-10-08&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=2018-10-08&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=2018-10-08&user=35968931&_facet_date=closed_at"}], "next": null, "next_url": null, "private": false, "allow_execute_sql": true, "query_ms": 33.33798190578818}