Skip to content

Add enum for profile shape#4180

Merged
je-cook merged 3 commits intomainfrom
add_enum_for_profile_shape
Apr 13, 2026
Merged

Add enum for profile shape#4180
je-cook merged 3 commits intomainfrom
add_enum_for_profile_shape

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

Description

Checklist

I confirm that I have completed the following checks:

  • My changes follow the PROCESS style guide
  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

@chris-ashe chris-ashe requested a review from a team as a code owner April 13, 2026 12:08
Copilot AI review requested due to automatic review settings April 13, 2026 12:08
@chris-ashe chris-ashe added Profiles Relating to the plasma profiles Refactor labels Apr 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 PlasmaProfileShapeType enum 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.

Comment on lines +15 to +20
class PlasmaProfileShapeType(IntEnum):
"""Enum for i_plasma_pedestal method types"""

PARABOLIC_PROFILE = 0
PEDESTAL_PROFILE = 1

Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

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__).

Copilot uses AI. Check for mistakes.
Comment on lines 8 to 9
from process.models.physics.plasma_profiles import PlasmaProfileShapeType

Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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()

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.56%. Comparing base (85ded89) to head (a584d54).

Files with missing lines Patch % Lines
process/models/physics/physics.py 25.00% 3 Missing ⚠️
process/models/physics/plasma_profiles.py 66.66% 1 Missing ⚠️
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.
📢 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 self-assigned this Apr 13, 2026
@je-cook je-cook merged commit 2fadac8 into main Apr 13, 2026
10 checks passed
@je-cook je-cook deleted the add_enum_for_profile_shape branch April 13, 2026 12:32
grmtrkngtn pushed a commit that referenced this pull request Apr 13, 2026
* Add enum for plasma profile shape types and update condition checks

* Refactor plasma profile handling to utilize PlasmaProfileShapeType for condition checks

* Move PlasmaProfileShapeType enum to profiles.py and update imports
grmtrkngtn pushed a commit that referenced this pull request Apr 13, 2026
* Add enum for plasma profile shape types and update condition checks

* Refactor plasma profile handling to utilize PlasmaProfileShapeType for condition checks

* Move PlasmaProfileShapeType enum to profiles.py and update imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Profiles Relating to the plasma profiles Refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants