home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 1000257950

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/5671#issuecomment-1000257950 https://api.github.com/repos/pydata/xarray/issues/5671 1000257950 IC_kwDOAMm_X847nrme 5088535 2021-12-23T12:03:09Z 2021-12-23T12:03:09Z NONE

I can confirm this issue when specifying dimensions with coordinates, as per this example:

``` import xarray as xr

z = -1 x = [1, 2, 3] y = [4, 5, 6] data = [0, 0, 0]

coords = {"z": z, "x": ("dim_0", x), "y": ("dim_0", y)}

xr.DataArray(data, coords=coords) ```

MyPy output:

error: Argument "coords" to "DataArray" has incompatible type "Dict[str, object]"; expected "Union[Sequence[Tuple[Any, ...]], Mapping[Hashable, Any], None]"

I can work around it by specifying the type of coords explicitly:

``` from typing import Any, Hashable, Mapping

import xarray as xr

z = -1 x = [1, 2, 3] y = [4, 5, 6] data = [0, 0, 0]

coords: Mapping[Hashable, Any] = {"z": z, "x": ("dim_0", x), "y": ("dim_0", y)}

xr.DataArray(data, coords=coords) ```

Success: no issues found in 1 source file

There is some discussion about str and Hashable in this issue, but type invariance is still a little over my head, TBH.

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