Skip to content

Conversation

@itcarroll
Copy link
Contributor

@itcarroll itcarroll commented Jan 23, 2025

Adds logic to variable.as_variable that handles tuples like (["x", "y"], 0) and (["x", "y"],) which results in a Variable with the given dimensions and a constant value (using np.nan if not given). The as_variable function takes an new optional argument called sizes that calling functions (notably core.merge) can construct from existing mappings. The construction of sizes added to core.merge is a possible performance concern.

I also considered putting the logic "higher up" in dataset.merge_data_and_coords, but that required an additional loop through the data_vars mapping and ended up with duplicate case checking in as_variable anyways.

Starting as draft for feedback and before updating any documentation. I've also discovered that the analogous enhancement to DataArray doesn't work with non-dimensional coordinates, which I'd like to take a look at for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creation of empty DataArrays in a Dataset

1 participant