You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The regular dataclass provides suggestions for the added properties, while the one created with this package does not. In Xarray, we can access the dimensions by simply using their names as properties, but there are no type suggestions for this:
from dataclasses import dataclass
from typing import Literal
from xarray_dataclasses import AsDataArray, Coord, Data
X = Literal["x"]
Y = Literal["y"]
@dataclass
class Image(AsDataArray):
"""2D image as DataArray."""
data: Data[tuple[X, Y], float]
x: Coord[X, int] = 0
y: Coord[Y, int] = 0
image = Image.new([[2.0, 2.0], [2.0, 2.0]], x=[0, 1], y=[0, 1])
image.x # no editor suggestion
@dataclass
class Image:
"""2D image as DataArray."""
data: Data[tuple[X, Y], float]
x: Coord[X, int] = 0
y: Coord[Y, int] = 0
image = Image([[2.0, 2.0], [2.0, 2.0]], x=[0, 1], y=[0, 1])
image.x # editor suggestion present
I would very much like to have this feature and would like to help in implementing it, but I'm not that familiar with typing and find the module structure here hard to follow.
The text was updated successfully, but these errors were encountered:
The regular
dataclass
provides suggestions for the added properties, while the one created with this package does not. In Xarray, we can access the dimensions by simply using their names as properties, but there are no type suggestions for this:I would very much like to have this feature and would like to help in implementing it, but I'm not that familiar with
typing
and find the module structure here hard to follow.The text was updated successfully, but these errors were encountered: