Repository navigation
pygen: use add_METADATA and keep parameter units - #3129
Merged
Merged
Conversation
Instance METADATA was written as append_METADATA, which McStasScript does not have; use add_METADATA(name, type, value). Pass the unit of name/"unit"=default parameters to add_parameter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Free-form text area
Two fixes to
mcstas-pygen/mcxtrace-pygen(mccode/src/pygen.c.in):METADATAwas written asappend_METADATA(...), which McStasScript has never had, so the generatedmake()stopped with anAttributeError. It is now written asadd_METADATA(name=..., type=..., value=...)(McStasScript >= 0.0.93).name/"unit"=default) lost it. The unit is now passed toadd_parameter(..., unit='...'). Parameters without a unit are written as before.No grammar change. ADR:
docs/GRAMMAR/ADR-records/ADR_20261118_PYGEN_METADATA_UNITS.md.Found with the ESS BIFROST model (from niess), which has METADATA blocks and parameter units: it failed the model checks of
mcstas-ess-instr-citool, which run pygen.Declaration of use of AI-tools
mcstas-ess-instr-citool, and wrote the fix, the ADR and the tests below, reviewed by the author.Development OS / boundary conditions
macOS arm64, McStas built from this branch, McStasScript 0.0.96.
mcstas-ess-instr-citool -a runcipasses with the newmcstas-pygen(model checks and two%Exampletests). With the old one, the model checks fail onappend_METADATA.lmin/"angstrom"=0.75givesadd_parameter('double', 'lmin', value=0.75, unit='angstrom', ...).mcxtrace-pygenbuilt with-Wall -Wextra, no warnings on the changed lines. Not run.PR Checklist for contributing to McStas/McXtrace
My work touches the code-generator in mccode/src
🤖 Generated with Claude Code