Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Provide Variable initialization from np.full for Datasets #9976

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

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.

# for free to join this conversation on GitHub. Already have an account? # 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