Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a typed IntEnum (PlasmaProfileShapeType) to represent the i_plasma_pedestal profile shape switch, and updates several call sites to use enum comparisons instead of raw integers.
Changes:
- Add
PlasmaProfileShapeTypeenum for plasma profile shape selection (PARABOLIC_PROFILE/PEDESTAL_PROFILE). - Replace
i_plasma_pedestal == 0/1(and one>= 1) checks with enum-based comparisons in profile-related logic.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| process/models/physics/plasma_profiles.py | Adds the new PlasmaProfileShapeType enum and uses it in profile parameterisation logic. |
| process/models/physics/profiles.py | Updates density/temperature profile logic to use PlasmaProfileShapeType comparisons. |
| process/models/physics/physics.py | Uses PlasmaProfileShapeType when deciding when to apply pedestal-related density initialisation and output checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class PlasmaProfileShapeType(IntEnum): | ||
| """Enum for i_plasma_pedestal method types""" | ||
|
|
||
| PARABOLIC_PROFILE = 0 | ||
| PEDESTAL_PROFILE = 1 | ||
|
|
There was a problem hiding this comment.
This change introduces a circular import: plasma_profiles.py imports process.models.physics.profiles at module import time, while profiles.py now imports PlasmaProfileShapeType from plasma_profiles.py. This will fail during import in normal runs/tests. Break the cycle by moving PlasmaProfileShapeType to a small standalone module (preferred), or by deferring/moving the import process.models.physics.profiles as profiles so it happens after the enum is defined (or inside PlasmaProfile.__init__).
process/models/physics/profiles.py
Outdated
| from process.models.physics.plasma_profiles import PlasmaProfileShapeType | ||
|
|
There was a problem hiding this comment.
Importing PlasmaProfileShapeType from process.models.physics.plasma_profiles creates a circular import because plasma_profiles.py also imports this profiles module at import time. Consider importing the enum from a dedicated module (or otherwise refactoring import order) to avoid an ImportError from partially-initialized modules.
| from process.models.physics.plasma_profiles import PlasmaProfileShapeType | |
| class _LazyPlasmaProfileShapeType: | |
| """Lazily resolve PlasmaProfileShapeType to avoid import-time circular imports.""" | |
| def __getattr__(self, name): | |
| from process.models.physics.plasma_profiles import PlasmaProfileShapeType as _PlasmaProfileShapeType | |
| return getattr(_PlasmaProfileShapeType, name) | |
| PlasmaProfileShapeType = _LazyPlasmaProfileShapeType() |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4180 +/- ##
==========================================
+ Coverage 49.55% 49.56% +0.01%
==========================================
Files 148 148
Lines 29734 29740 +6
==========================================
+ Hits 14734 14740 +6
Misses 15000 15000 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
Checklist
I confirm that I have completed the following checks: