Would it be possible for a dataclass AsDataArray to deduce the shape of the Data from the coordinates, ie:
@dataclass
class Image(AsDataArray):
"""2D image as DataArray."""
x: Coord[X, int]
y: Coord[Y, int]
data: Data[tuple[X, Y], float]
In this case, the coordinates are not optional.
To do that, the classmethod shaped should allow shape to be optional, and use the shape from the kwargs.
(Could extends the case where shape is a dict and fallback to the value specified in the dict)
if isinstance(shape, None):
shape = tuple(kwargs[dim].size for dim in entry.dims)
Happy to open a PR, if you want.
Would it be possible for a dataclass
AsDataArrayto deduce the shape of the Data from the coordinates, ie:In this case, the coordinates are not optional.
To do that, the classmethod
shapedshould allowshapeto be optional, and use the shape from the kwargs.(Could extends the case where
shapeis a dict and fallback to the value specified in the dict)Happy to open a PR, if you want.