Skip to content

Allow filtering PyMJCF find_all results by default class - #568

Open
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:feat/482-find-all-filter-default-class-20261011
Open

sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:feat/482-find-all-filter-default-class-20261011

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Addresses #482.

Changes

Add an optional dclass string argument to PyMJCF Element.find_all. It filters the found sites (or other namespace elements) by their explicit default-class name without requiring callers to handle missing class references or traverse element.dclass.dclass manually.

  • Resolve the class name from PyMJCF's default-class element reference, handling absent references.
  • Apply the filter recursively, including nested bodies.
  • Preserve all existing find_all behavior when dclass is omitted.
  • Add regression tests for matching, nonmatching, missing-class, recursive and immediate-children cases.

Validation

dm_control/mjcf/element_test.py: 47 passed and 2 subtests passed. Python compilation and git diff --check passed. Generated binding files were used only in the local test environment and are not included in this PR.

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.

1 participant