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

No type hints for dimensions #212

Open
krokosik opened this issue Aug 11, 2023 · 0 comments
Open

No type hints for dimensions #212

krokosik opened this issue Aug 11, 2023 · 0 comments
Assignees
Labels
feature New feature or request

Comments

@krokosik
Copy link

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.

@astropenguin astropenguin self-assigned this Aug 23, 2023
@astropenguin astropenguin added the feature New feature or request label Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants