From b490668f5ed6a4dabcff2e30200c7f774fbc68cc Mon Sep 17 00:00:00 2001 From: "Eric G. Stern" Date: Thu, 12 Sep 2024 11:28:53 -0500 Subject: [PATCH 1/2] explicitly throw if un-implemented get_bunch_median_cdt() method is called. add checkout_particles() to test_offset_bunch_cdt --- src/synergia/bunch/core_diagnostics.cc | 6 ++++++ src/synergia/bunch/tests/test_offset_bunch_cdt.cc | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/synergia/bunch/core_diagnostics.cc b/src/synergia/bunch/core_diagnostics.cc index b4a1eee24..4f2e1e93b 100644 --- a/src/synergia/bunch/core_diagnostics.cc +++ b/src/synergia/bunch/core_diagnostics.cc @@ -461,6 +461,12 @@ Core_diagnostics::calculate_spatial_mean_stddev(Bunch const& bunch) return mean_and_stddev; } +double +calculate_median_cdt(Bunch const& bunch) +{ + throw std::runtime_error("bunch cdt median not yet implemented"); +} + std::vector Core_diagnostics::kokkos_view_to_stl_vector(karray1d const& view) { diff --git a/src/synergia/bunch/tests/test_offset_bunch_cdt.cc b/src/synergia/bunch/tests/test_offset_bunch_cdt.cc index cc96f7374..d9d39333c 100644 --- a/src/synergia/bunch/tests/test_offset_bunch_cdt.cc +++ b/src/synergia/bunch/tests/test_offset_bunch_cdt.cc @@ -48,6 +48,8 @@ TEST_CASE("Bunch", "[Bunch]") // Offset the bunch cdt bunch.offset_bunch_particles_cdt(-0.02); + bunch.checkout_particles(); + auto new_parts = bunch.get_host_particles(); for (auto i=0; i Date: Fri, 13 Sep 2024 11:07:03 -0500 Subject: [PATCH 2/2] added comment to call attention to bunch_checkout --- src/synergia/bunch/tests/test_offset_bunch_cdt.cc | 3 ++- src/synergia/bunch/tests/test_offset_bunch_cdt.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/synergia/bunch/tests/test_offset_bunch_cdt.cc b/src/synergia/bunch/tests/test_offset_bunch_cdt.cc index d9d39333c..5fbe69023 100644 --- a/src/synergia/bunch/tests/test_offset_bunch_cdt.cc +++ b/src/synergia/bunch/tests/test_offset_bunch_cdt.cc @@ -47,7 +47,8 @@ TEST_CASE("Bunch", "[Bunch]") // Offset the bunch cdt bunch.offset_bunch_particles_cdt(-0.02); - + + // particles changed on the device, so check them out for testing bunch.checkout_particles(); auto new_parts = bunch.get_host_particles(); diff --git a/src/synergia/bunch/tests/test_offset_bunch_cdt.py b/src/synergia/bunch/tests/test_offset_bunch_cdt.py index e2ab9deb7..6b2f3484e 100644 --- a/src/synergia/bunch/tests/test_offset_bunch_cdt.py +++ b/src/synergia/bunch/tests/test_offset_bunch_cdt.py @@ -36,6 +36,7 @@ def test_offset_bunch_cdt(bunch_fixture): bunch_fixture.offset_bunch_particles_cdt(-0.02) # check that cdt is set correctly + # particles changed on device so check them out again bunch_fixture.checkout_particles() lp = bunch_fixture.get_particles_numpy() print('particles cdt after offset: ', lp[:, 4])