You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GuidingCenter en_fB sums over holes and ghosts; test_scalars en_fB tests fail on devel #727
Two tests in src/struphy/models/tests/test_scalars.py fail on devel (25688c5):
FAILED src/struphy/models/tests/test_scalars.py::test_en_fB_ignores_ghost_markers
AssertionError: GuidingCenter: en_fB = 8.75 with ghosts, 2.0 without
FAILED src/struphy/models/tests/test_scalars.py::test_guiding_center_en_fB_does_not_divide_by_Np
AttributeError: '_GuidingCenterMarkers' object has no attribute 'save_magnetic_background_energy'
The failures were first seen while testing #724, but they also happen on unchanged devel (checked locally in a clean worktree of origin/devel, macOS, python -m pytest src/struphy/models/tests/test_scalars.py: 2 failed, 4 passed). CI does not flag them.
1. GuidingCenter._compute_en_fB uses an inverted mask (a real bug).src/struphy/models/guiding_center.py:120-121:
~valid_mks selects the holes and ghost markers instead of the valid markers, so en_fB of GuidingCenter sums over the wrong rows. #631 (fix for #563) meant to change ~particles.holes to particles.valid_mks. It did so in LinearMHDDriftkineticCC._compute_en_fB (linear_mhd_driftkinetic_cc.py:211-212), but in guiding_center.py it wrote ~particles.valid_mks. test_en_fB_ignores_ghost_markers catches this.
2. The mock in test_guiding_center_en_fB_does_not_divide_by_Np is outdated._GuidingCenterMarkers (test_scalars.py:169, added in #477) has no save_magnetic_background_energy() and no valid_mks, which GuidingCenter._compute_en_fB uses.
Suggested fix:
guiding_center.py: index with particles.valid_mks (without ~).
test_scalars.py: give _GuidingCenterMarkers a no-op save_magnetic_background_energy() and a valid_mks attribute (~self.holes).
Check why CI did not run these tests. The unit-test job uses --testmon, so it may have skipped them.
Activity