Skip to content

Commit d5da669

Browse files
authored
Test shared profile geometry
1 parent 15bd7e1 commit d5da669

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

freegsnke/tests/test_jtor_update.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,29 @@ def test_profiles_BetapIp(create_machine):
7676
and hasattr(profiles, "opt")
7777
and hasattr(profiles, "jtor")
7878
), "The profiles object does not have the xpt, opt and jtor attributes"
79+
80+
81+
def test_profile_geometry_is_shared_and_fallback_indices_are_lazy(create_machine):
82+
eq, _ = create_machine
83+
profiles = jtor.ConstrainPaxisIp(eq, 8.1e3, 6.2e5, 0.5)
84+
profiles.inputs = []
85+
copied_profiles = jtor.Jtor_universal.copy(profiles)
86+
handler = eq.limiter_handler
87+
88+
for name in (
89+
"dR_dZ",
90+
"R0Z0",
91+
"eqRidx",
92+
"eqZidx",
93+
"mask_inside_limiter",
94+
"mask_outside_limiter",
95+
"limiter_mask_out",
96+
):
97+
assert getattr(profiles, name) is getattr(handler, name)
98+
assert getattr(copied_profiles, name) is getattr(handler, name)
99+
100+
assert handler._idx_grid_points is None
101+
assert handler.idx_grid_points.shape == (eq.nx * eq.ny, 2)
102+
expected_indices = np.indices((eq.nx, eq.ny)).reshape(2, -1).T
103+
assert np.array_equal(handler.idx_grid_points, expected_indices)
104+
assert handler.idx_grid_points is handler._idx_grid_points

0 commit comments

Comments
 (0)