From 56004f44826f3a2cf8ff5a25365a60ac2f547928 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 13:51:12 +0000 Subject: [PATCH] test: update stale fixtures for current sources (no src change) - test_channel_root: owner is uint64; int() before -1 so the probe slot stays an integer under NumPy 1 value-based promotion. - test_shifted_storage: build FP32 fixtures with FP32 NaN; np.where with a Python NaN promoted to FP64 under NumPy 1, so the shifted FP32 contract rejected the fixture before the intended checks. - test_block_stepper: fake backend sets _ddf_shifting (unshifted). - test_fine_surface_gpu: set _boundary_hosts/_level_jets; fine_boundary is now a read-only view over the level lists. - test_refinement_followup: set _layouts (fine_layout is a read-only view); a pair tau that disagrees with its level config is now rejected by hierarchy._check_chain before the per-level omega/tau check. Co-Authored-By: Claude Opus 5.5 --- tests/unit/test_channel_root.py | 2 +- tests/unit/test_shifted_storage.py | 6 ++++-- tests/validation/multigrid/test_block_stepper.py | 1 + tests/validation/multigrid/test_fine_surface_gpu.py | 3 ++- tests/validation/multigrid/test_refinement_followup.py | 6 ++++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/unit/test_channel_root.py b/tests/unit/test_channel_root.py index 49a9e1f..771ffde 100644 --- a/tests/unit/test_channel_root.py +++ b/tests/unit/test_channel_root.py @@ -50,7 +50,7 @@ def test_masks_and_minimal_footprint(): def test_actual_closure_read_conflicts(): pair, layout, targets = transfer((6, 6, 18, 14)) validate_channel_transfers(pair, layout, targets) - for target in (layout.slot(layout.owner[5, -1]-1, 2), + for target in (layout.slot(int(layout.owner[5, -1]) - 1, 2), layout.slot(layout.owner[1, 4], 4), layout.slot(layout.owner[-2, 4], 3)): with pytest.raises(ValueError, match="immutable"): diff --git a/tests/unit/test_shifted_storage.py b/tests/unit/test_shifted_storage.py index bcca95b..352ae02 100644 --- a/tests/unit/test_shifted_storage.py +++ b/tests/unit/test_shifted_storage.py @@ -78,13 +78,15 @@ class ShiftedStorage(unittest.TestCase): def test_shifted_density_and_tag_validation(self): old,new = topology(A),topology(B) - a = tuple(np.where(m[None], np.float32(-.001), np.nan).repeat(9,axis=0) for m in old.leaf_masks) + a = tuple(np.where(m[None], np.float32(-.001), np.float32(np.nan)).repeat(9,axis=0) + for m in old.leaf_masks) # FP32 under numpy 1 and 2 promotion rules remap(old,new,a) with self.assertRaisesRegex(ValueError,'representation'): remap(old,new,a,False) with self.assertRaisesRegex(ValueError,'FP32'): remap(old,new,tuple(x.astype(np.float64) for x in a)) a[0][:,old.leaf_masks[0]] = -1 with self.assertRaisesRegex(ValueError,'positive density'): remap(old,new,a) - rest = tuple(np.where(m[None],np.float32(0),np.nan).repeat(9,axis=0) for m in old.leaf_masks) + rest = tuple(np.where(m[None],np.float32(0),np.float32(np.nan)).repeat(9,axis=0) + for m in old.leaf_masks) remap(old,new,rest) with self.assertRaisesRegex(ValueError,'positive density'): remap_synchronized(old,new,rest,base_count=7,level_steps=(7,14,28),phase='postcollision_g') diff --git a/tests/validation/multigrid/test_block_stepper.py b/tests/validation/multigrid/test_block_stepper.py index ecebb80..4ec7abc 100644 --- a/tests/validation/multigrid/test_block_stepper.py +++ b/tests/validation/multigrid/test_block_stepper.py @@ -192,6 +192,7 @@ class CpuContracts(unittest.TestCase): backend._lock = RLock() backend._status = "ready" backend._step_count = 0 + backend._ddf_shifting = False # unshifted storage, as for the default config backend._stream = Mock() backend._module = Mock() backend._copy = backend._step = Mock() diff --git a/tests/validation/multigrid/test_fine_surface_gpu.py b/tests/validation/multigrid/test_fine_surface_gpu.py index a8fca1b..58cebb8 100644 --- a/tests/validation/multigrid/test_fine_surface_gpu.py +++ b/tests/validation/multigrid/test_fine_surface_gpu.py @@ -281,7 +281,8 @@ def test_fine_surface_four_hops(speed): @pytest.mark.parametrize("missing", ["surface_velocity_gpu", "link_exchange_gpu"]) def test_missing_surface_device_buffer_rejects_before_launch(missing): backend = implementation.FixedPatchStepper.__new__(implementation.FixedPatchStepper) - backend.fine_boundary = SimpleNamespace(objects=[object_spec(.002)]) + backend._boundary_hosts = [None, SimpleNamespace(objects=[object_spec(.002)])] + backend._level_jets = [(), ()] backend._fine_curved = SimpleNamespace(fluid_idx_gpu=object(), surface_velocity_gpu=object(), link_exchange_gpu=object()) setattr(backend._fine_curved, missing, None) diff --git a/tests/validation/multigrid/test_refinement_followup.py b/tests/validation/multigrid/test_refinement_followup.py index 9af399f..f6f9c0d 100644 --- a/tests/validation/multigrid/test_refinement_followup.py +++ b/tests/validation/multigrid/test_refinement_followup.py @@ -106,7 +106,7 @@ class FaultGuardsCPU(unittest.TestCase): def fake_backend(self): backend = PeriodicPatchStepper.__new__(PeriodicPatchStepper) - backend.fine_layout = None # dense fine storage + backend._layouts = [None, None] # dense storage on both levels backend.ctx = Mock(activate=nullcontext) backend._lock = RLock() backend._status = "ready" @@ -158,7 +158,9 @@ class FaultGuardsCPU(unittest.TestCase): p = implementation.FixedPatch2D.from_config(cfg, (4, 4, 12, 12)) with patch.object(cuda, "Stream"), patch.object(implementation.FixedPatch2D, "from_config", return_value=replace(p, tau_coarse=.9)): - with self.assertRaisesRegex(RuntimeError, "omega/tau"): + # The hierarchy rejects a pair tau that disagrees with its level config + # (hierarchy.py) before the per-level omega/tau check can be reached. + with self.assertRaisesRegex(RuntimeError, "config chain is inconsistent"): PeriodicPatchStepper(cfg, p.bounds, context=context) module = Mock() module.get_global.return_value = (Mock(), 16)