-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
featureNew feature or requestNew feature or request
Description
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.
avivajpeyi
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request