-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Is your feature request related to a problem?
Initializing a DataArray from a scalar along with non-scalar coords and dims, which was implemented in #3159, does not extend to Datasets. Initializing multiple DataArrays with shared dimensions, as a Dataset, is not similarly possible.
Describe the solution you'd like
Dataset creation and assignment could handle scalar values in the same way as DataArray creation.
For example
Dataset({"y": ("x", None)}, coords={"x": [0, 1, 2]})
could yield the same thing as
Dataset({"y": xr.DataArray(None, coords={"x": [0, 1, 2]}, dims="x")})
Only the first case easily extends to multiple variables sharing x.
Describe alternatives you've considered
Defining Coordinates in advance is the currently working alternative, but it's not as elegant and is a rare case of needing to explicitly define a Coordinates instance.
Additional context
If this enhancement is supported, I would attempt a PR.