Raise on duplicate material names in convert_to_multigroup - #108
Open
jon-proximafusion wants to merge 2 commits into
Open
Raise on duplicate material names in convert_to_multigroup#108jon-proximafusion wants to merge 2 commits into
jon-proximafusion wants to merge 2 commits into
Conversation
jon-proximafusion
force-pushed
the
fix-convert-mgxs-duplicate-material-names
branch
from
June 25, 2026 13:58
30b2ad2 to
0afedb4
Compare
jon-proximafusion
force-pushed
the
fix-convert-mgxs-duplicate-material-names
branch
from
June 25, 2026 14:17
0afedb4 to
d5b560a
Compare
jon-proximafusion
force-pushed
the
fix-convert-mgxs-duplicate-material-names
branch
2 times, most recently
from
June 25, 2026 14:30
a3fb34d to
5c29764
Compare
jon-proximafusion
force-pushed
the
fix-convert-mgxs-duplicate-material-names
branch
from
June 25, 2026 14:32
5c29764 to
abb819a
Compare
convert_to_multigroup generates one MGXS per material, keyed by material name. Two distinct materials that share a name (for example the same-named clones from Model.differentiate_mats(), since Material.clone() preserves the name) cannot be written as separate cross sections -- one would silently overwrite the other, dropping a material's data. Names are also sanitised to alphanumeric plus underscore, which can make otherwise distinct names collide. Raise a ValueError instead of silently producing an incorrect library, leaving user-assigned names unchanged.
jon-proximafusion
force-pushed
the
fix-convert-mgxs-duplicate-material-names
branch
from
June 25, 2026 14:34
abb819a to
5a5f365
Compare
This was referenced Jun 25, 2026
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.
Summary
Model.convert_to_multigroup()generates one MGXS per material, keyed by material name. Two distinct materials that share a name would be silently written as a single cross section — one material's data overwrites the other's, dropping a material. This is easy to hit becauseMaterial.clone()(used byModel.differentiate_mats()) preserves the original name, and because names are sanitised to alphanumeric + underscore, which can make otherwise-distinct names collide.Conversion now raises a
ValueErrorinstead of silently producing an incorrect library; material names are left unchanged. The per-material granularity is also noted in theconvert_to_multigroupdocstring.Tests
Added a unit test asserting that two distinct materials sharing a name raise
ValueError.