Skip to content

Conversation

@krystophny
Copy link
Member

@krystophny krystophny commented Nov 25, 2025

User description

Summary

  • Remove incorrect validation that prevented using fast_class with positive tcut
  • Fix examples/classification/simple.in to use correct VMEC file matching Makefile
  • Add classifier_combined golden record test validating both classification methods work together

Root Cause

The error check added in commit d607ec1 ("feat: refresh python API classification #184") was incorrect:

if (fast_class .and. tcut > 0.0d0) then
  error stop 'fast_class and positive tcut are mutually exclusive'
endif

These are actually complementary classification methods:

  • fast_class=.True. enables J_parallel and ideal orbit classifiers (runs at banana tips)
  • tcut > 0 enables fractal dimension classification (runs at specified time cut)

The original working example at commit 3a771f2 used both together.

Test Plan

  • make test passes (100% of 23 tests)
  • Classification example examples/classification/ runs successfully
  • New golden record test classifier_combined validates both methods work together
  • Codex agent review approved

Related

Fixes regression where classification example would error stop with "fast_class and positive tcut are mutually exclusive"


PR Type

Bug fix, Tests


Description

  • Remove incorrect validation preventing fast_class and tcut from working together

  • These are complementary classification methods, not mutually exclusive

  • Fix example configuration to use correct VMEC file matching Makefile

  • Add classifier_combined golden record test validating both methods work together


Diagram Walkthrough

flowchart LR
  A["Remove incorrect validation"] --> B["fast_class and tcut now compatible"]
  C["Fix example VMEC file reference"] --> D["QA to QH file"]
  E["Add classifier_combined test"] --> F["Validate both methods work"]
  B --> G["Classification methods work together"]
  D --> G
  F --> G
Loading

File Walkthrough

Relevant files
Bug fix
params.f90
Remove mutually exclusive validation for fast_class and tcut

src/params.f90

  • Removed incorrect error check that prevented using fast_class with
    positive tcut
  • These are complementary classification methods: fast_class enables
    J_parallel and ideal orbit classifiers, while tcut enables fractal
    dimension classification
  • Validation now only checks for incompatibility with collisions
+0/-3     
simple.in
Fix VMEC file reference in classification example               

examples/classification/simple.in

  • Changed VMEC file from
    wout_LandremanPaul2021_QA_reactorScale_lowres_reference.nc to
    wout_LandremanPaul2021_QH_reactorScale_lowres_reference.nc
  • Corrects file reference to match the Makefile configuration
+1/-1     
Tests
simple.in
Add classifier_combined golden record test configuration 

test/golden_record/classifier_combined/simple.in

  • New test configuration file for classifier_combined golden record test
  • Validates that both fast_class=.True. and tcut=1d-2 work together
  • Uses 32 test particles with deterministic mode for reproducible
    results
  • Includes classification plot output configuration
+15/-0   

Remove incorrect validation that prevented using fast_class with
positive tcut. These are complementary classification methods:

- fast_class enables J_parallel and ideal orbit classifiers
- tcut enables fractal dimension classification

The original working code at 3a771f2 allowed using both together.
The check was incorrectly added in d607ec1 during Python API refresh.

Also fix examples/classification/simple.in to use the correct QH file
that matches the Makefile, and add classifier_combined golden record
test to verify both classification methods work together.

Fixes regression where classification example would error stop with
fast_class and positive tcut are mutually exclusive.
@qodo-code-review
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
No audit logs: The change alters validation behavior for classification without introducing any logging
of critical actions or outcomes, making it unclear if such actions are audited.

Referred Code
if (swcoll .and. (tcut > 0.0d0 .or. class_plot .or. fast_class)) then
  error stop 'Collisions are incompatible with classification'
endif

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Rigid error stop: The code uses a hard error stop for collision/classification incompatibility without
context (e.g., parameter values), which may hinder diagnostics and graceful handling.

Referred Code
if (swcoll .and. (tcut > 0.0d0 .or. class_plot .or. fast_class)) then
  error stop 'Collisions are incompatible with classification'
endif

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status:
No structured logs: No logging was added around classification configuration decisions, offering no structured
telemetry and making it unclear whether sensitive data could be inadvertently logged
elsewhere.

Referred Code
  call reset_seed_if_deterministic

  if (swcoll .and. (tcut > 0.0d0 .or. class_plot .or. fast_class)) then
    error stop 'Collisions are incompatible with classification'
  endif

end subroutine read_config

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
External file input: The configuration introduces or modifies external file references (VMEC netCDF) without
visible validation or sanitization in the shown diff to ensure safe handling.

Referred Code
netcdffile = 'wout_LandremanPaul2021_QH_reactorScale_lowres_reference.nc'   ! name of VMEC file in NETCDF format
isw_field_type = 2       ! -1: Testing, 0: Canonical, 1: VMEC, 2: Boozer

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Improve comment for clarity

Improve the comment for the fast_class parameter in
test/golden_record/classifier_combined/simple.in to be more descriptive and
consistent with other files.

test/golden_record/classifier_combined/simple.in [13]

-fast_class = .True.      ! if .True. quit immediately after fast classification
+fast_class = .True.      ! if .True. quit immediately after fast classification and don't trace orbits to the end
  • Apply / Chat
Suggestion importance[1-10]: 3

__

Why: The suggestion correctly points out an inconsistent and less descriptive comment for the fast_class parameter, and improving it enhances clarity and consistency across configuration files.

Low
  • More

@krystophny krystophny mentioned this pull request Dec 28, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants