Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing issue: Pylance complains with DataTree inequalities #323

Open
louisletoumelin opened this issue Mar 14, 2024 · 1 comment
Open

Typing issue: Pylance complains with DataTree inequalities #323

louisletoumelin opened this issue Mar 14, 2024 · 1 comment

Comments

@louisletoumelin
Copy link

Hello,

I encountered the following typing issue: inequality between a datatree instance and a float raises a Pylance issue.

datatree version: 0.0.14

Reproducing the warning

I use the datatree example from the Quick Overview section in the doc (https://xarray-datatree.readthedocs.io/en/latest/quick-overview.html)

from datatree import DataTree

data = xr.DataArray(np.random.randn(2, 3), dims=("x", "y"), coords={"x": [10, 20]})
ds = xr.Dataset(dict(foo=data, bar=("x", [1, 2]), baz=np.pi))
ds2 = ds.interp(coords={"x": [10, 12, 14, 16, 18, 20]})
ds3 = xr.Dataset(
    dict(people=["alice", "bob"], heights=("people", [1.57, 1.82])),
    coords={"species": "human"},
)
dt = DataTree.from_dict({"simulation/coarse": ds, "simulation/fine": ds2, "/": ds3})

Then,

dt > 3.0  # works but Pylance complains: Operator ">" not supported for types "DataTree[Unknown]" and "float" PylancereportOperatorIssue
dt < 3.0 # works but Pylance complains: Operator "<" not supported for types "DataTree[Unknown]" and "float" PylancereportOperatorIssue
dt <= 3.0 # works but Pylance complains: Operator "<=" not supported for types "DataTree[Unknown]" and "float" PylancereportOperatorIssue
dt >= 3.0 # works but Pylance complains: Operator ">=" not supported for types "DataTree[Unknown]" and "float" PylancereportOperatorIssue
dt == 3  # Works fine. No Pylance issue.
@eschalkargans
Copy link

maybe related to #313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants