Skip to content

Add DataTree.prune() method … #10598

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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

aladinor
Copy link
Contributor

@aladinor aladinor commented Aug 1, 2025

  • Add is_data_empty property to check if node contains data variables with actual data
  • Add prune() method to remove empty nodes while preserving tree structure
  • Include comprehensive tests covering basic pruning, intermediate nodes, and filtering scenarios
  • Useful for cleaning up DataTree after time-based filtering operations
  • Closes Add .prune() method to remove empty nodes from DataTree after filtering operations #10590
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst

│                                                                                                                                                                                                                           │
│   - Add is_data_empty property to check if node contains data variables with actual data                                                                                                                                  │
│   - Add prune() method to remove empty nodes while preserving tree structure                                                                                                                                              │
│   - Include comprehensive tests covering basic pruning, intermediate nodes, and filtering scenarios                                                                                                                       │
│   - Useful for cleaning up DataTree after time-based filtering operations
@github-actions github-actions bot added the topic-DataTree Related to the implementation of a DataTree class label Aug 1, 2025
@aladinor aladinor changed the title Add DataTree.is_data_empty property and .prune() method … Add DataTree.prune() method … Aug 5, 2025
@aladinor aladinor requested a review from TomNicholas August 6, 2025 11:39
Copy link
Member

@TomNicholas TomNicholas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a sentence to the end of this section of the documentation just saying something like "If you want to filter out empty nodes you can use .prune()", with a link to the API docs.

@aladinor aladinor requested a review from TomNicholas August 6, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-DataTree Related to the implementation of a DataTree class
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add .prune() method to remove empty nodes from DataTree after filtering operations
2 participants