Skip to content

Fix duplicate switch value making Paz-Soldan scaling unselectable - #4529

Open
dallonby wants to merge 2 commits into
ukaea:mainfrom
dallonby:fix/paz-soldan-switch-value
Open

Fix duplicate switch value making Paz-Soldan scaling unselectable#4529
dallonby wants to merge 2 commits into
ukaea:mainfrom
dallonby:fix/paz-soldan-switch-value

Conversation

@dallonby

Copy link
Copy Markdown

Closes #4528

Overview

ConfinementTimeModel.PAZ_SOLDAN_NT shared switch value 51 with NCST, making it a silent Python enum alias: i_confinement_time = 51 dispatched to the NCST scaling, the Paz-Soldan branch in calculate_confinement_time was unreachable, and the documented value 52 was rejected as invalid input.

Changes

  • process/data_structure/physics_variables.py: assign 52 to PAZ_SOLDAN_NT (matching the existing documentation in plasma_confinement.md) and decorate ConfinementTimeModel with enum.unique so any future duplicate value fails at import instead of silently aliasing.
  • tests/unit/models/physics/test_confinement_time.py: add a uniqueness test over all switch values and an explicit test that 51 → NCST and 52 → PAZ_SOLDAN_NT are distinct members.

Notes for reviewers

  • N_CONFINEMENT_SCALINGS (= len(ConfinementTimeModel)) goes 52 → 53. I checked the three usages: the hfac array grows by one element, input validation now accepts 0–52, and the OUT.DAT confinement-comparison table gains one (OCMMNT text) row — no MFILE variables are added, so regression MFILE comparisons should be unaffected.
  • Full unit suite passes locally (844 passed / 4 skipped, Python 3.12).

Found during an independent audit of v3.4.2.

🤖 Generated with Claude Code

ConfinementTimeModel.PAZ_SOLDAN_NT was assigned 51, the same value as
NCST, making it a silent alias: i_confinement_time=51 dispatched to the
NCST scaling and the Paz-Soldan branch in
PlasmaConfinementTime.calculate_confinement_time was unreachable.

Assign 52, matching the documented switch value in
documentation/source/physics-models/plasma_confinement.md, and add
enum.unique so a duplicate value can never silently alias again.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dallonby
dallonby requested a review from a team as a code owner August 15, 2026 13:42
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.32%. Comparing base (c0ae5b2) to head (2a5da86).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4529   +/-   ##
=======================================
  Coverage   49.32%   49.32%           
=======================================
  Files         150      150           
  Lines       29802    29803    +1     
=======================================
+ Hits        14700    14701    +1     
  Misses      15102    15102           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@je-cook je-cook left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this. Just the one fix please

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These are overkill just the unique decorator will raise a ValueError on initialisation of the enum, please remove them

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — both tests removed in b80cf4b; the branch is now just the value change plus @unique. Thanks for the review.

@je-cook je-cook self-assigned this Aug 17, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Paz-Soldan NT confinement scaling is unselectable: duplicate switch value 51 aliases it to NCST

3 participants