Skip to content

Handle optional NXDL dimensions during validation - #269

Merged
rayosborn merged 1 commit into
nexpy:mainfrom
CAOShurong:codex/248-optional-dimensions
Oct 2, 2026
Merged

rayosborn merged 1 commit into
nexpy:mainfrom
CAOShurong:codex/248-optional-dimensions

Conversation

@CAOShurong

Copy link
Copy Markdown
Contributor

Summary

  • preserve each NXDL dimension's explicit required attribute when converting XML definitions
  • skip a missing trailing dimension when the definition marks it optional (false or 0)
  • keep the existing validation behavior for dimensions whose required attribute is omitted or true

Closes #248.

Verification

  • pytest tests/test_validate.py -vv (6 passed)
  • pytest --basetemp <E: scratch directory> (113 passed)
  • ruff check src/nexusformat/nexus/utils.py src/nexusformat/nexus/validate.py tests/test_validate.py
  • changed-file pre-commit hooks
  • sdist and wheel build
  • clean-wheel probe confirming an NXDL optional fourth dimension is accepted for a three-dimensional field
  • installed nxcheck --help entry point

Disclosure: This change was developed with assistance from OpenAI Codex and reviewed and verified by CAOShurong.

@rayosborn

Copy link
Copy Markdown
Contributor

Thank you for the PR, which is very timely, since I want to raise the variable dimensions issues at the NIAC meeting next week. It looks fine, but I need to run a couple of tests before approving.

@rayosborn

Copy link
Copy Markdown
Contributor

I have made a number of other changes to the validation tools, including the addition of two new scripts, nxvalidate, which is equivalent to nxcheck -a, and nxlint to check for XML errors in NXDl files. This PR doesn't conflict with those changes and looks to fix an important shortcoming, so thanks for submitting it.

You might also be interested in changes I have proposed to the NeXus definitions (nexusformat/definitions#1664), which I believe clean up some of the issues surrounding dimension symbols in NXDL files. This has been discussed at the NIAC, but not approved yet.

@rayosborn
rayosborn merged commit e7e8952 into nexpy:main Oct 2, 2026
16 checks passed
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.

Validation doesn't know about non-required dimensions

2 participants