From 6af52b12846bfd5daf0c04341737bc0f3078fde3 Mon Sep 17 00:00:00 2001 From: Maximilian Sackel Date: Fri, 16 Apr 2021 13:33:29 +0200 Subject: [PATCH] fix logical expression in tests. they should now be windows compatible (#145) --- tests/Bremsstrahlung_TEST.cxx | 16 ++++++++-------- tests/Compton_TEST.cxx | 4 ++-- tests/Epairproduction_TEST.cxx | 18 +++++++++--------- tests/Ionization_TEST.cxx | 16 ++++++++-------- tests/Mupairproduction_TEST.cxx | 4 ++-- tests/Photonuclear_TEST.cxx | 20 ++++++++++---------- tests/Scattering_TEST.cxx | 2 +- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/Bremsstrahlung_TEST.cxx b/tests/Bremsstrahlung_TEST.cxx index 436112da3..be7cb0a26 100644 --- a/tests/Bremsstrahlung_TEST.cxx +++ b/tests/Bremsstrahlung_TEST.cxx @@ -292,7 +292,7 @@ TEST(Bremsstrahlung, Test_of_e) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1 ) { + if (ecut == INF && vcut == 1 ) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss(comp.GetHash(), energy, rate_new), ""); #endif @@ -346,12 +346,12 @@ TEST(Bremsstrahlung, Test_of_dEdx_Interpolant) dEdx_new = cross->CalculatedEdx(energy) * medium->GetMassDensity(); - if (particleName == "TauMinus" and energy < 1.e5) + if (particleName == "TauMinus" && energy < 1.e5) continue; // in this energy regime, the dEdx integral values look absolutely terrible if (vcut * energy == ecut) EXPECT_NEAR(dEdx_new, dEdx_stored, 1e-1 * dEdx_stored); // expecting a kink here - else if (particleName == "EMinus" and mediumName == "uranium" and energy == 10000) + else if (particleName == "EMinus" && mediumName == "uranium" && energy == 10000) EXPECT_NEAR(dEdx_new, dEdx_stored, 5e-3 * dEdx_stored); // integral function hard to interpolate else EXPECT_NEAR(dEdx_new, dEdx_stored, interpolation_precision * dEdx_stored); @@ -399,7 +399,7 @@ TEST(Bremsstrahlung, Test_of_dNdx_Interpolant) if (vcut * energy == ecut) EXPECT_NEAR(dNdx_new, dNdx_stored, 1e-1 * dNdx_stored); // expecting a kink here - else if (particleName == "EMinus" and mediumName == "ice" and energy == 1e12 and lpm == true) + else if (particleName == "EMinus" && mediumName == "ice" && energy == 1e12 && lpm == true) EXPECT_NEAR(dNdx_new, dNdx_stored, 1e-2 * dNdx_stored); // else EXPECT_NEAR(dNdx_new, dNdx_stored, interpolation_precision * dNdx_stored); @@ -455,7 +455,7 @@ TEST(Bremsstrahlung, Test_of_e_Interpolant) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if ( ecut == INF and vcut == 1 ) { + if ( ecut == INF && vcut == 1 ) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss(comp.GetHash(), energy, rate_new), ""); #endif @@ -463,11 +463,11 @@ TEST(Bremsstrahlung, Test_of_e_Interpolant) auto v = cross->CalculateStochasticLoss(comp.GetHash(), energy, rate_new); if (energy * vcut == ecut) EXPECT_NEAR(energy * v, stochastic_loss_stored, 1e-1 * stochastic_loss_stored); // kink in integral - else if (particleName == "EMinus" and mediumName == "uranium") + else if (particleName == "EMinus" && mediumName == "uranium") EXPECT_NEAR(energy * v, stochastic_loss_stored, 5e-1 * stochastic_loss_stored); // there is one test that is failing really hard... - else if (particleName == "EMinus" and energy >= 1e10) + else if (particleName == "EMinus" && energy >= 1e10) EXPECT_NEAR(energy * v, stochastic_loss_stored, 1e-1 * stochastic_loss_stored); // somehow not working well - else if (rnd1 < 0.05 or rnd1 > 0.95) + else if (rnd1 < 0.05 || rnd1 > 0.95) EXPECT_NEAR(energy * v, stochastic_loss_stored, 2e-2 * stochastic_loss_stored); // this seems to have been unreliable in old PROPOSAL else EXPECT_NEAR(energy * v, stochastic_loss_stored, interpolation_precision * stochastic_loss_stored); diff --git a/tests/Compton_TEST.cxx b/tests/Compton_TEST.cxx index 3f2cc7fdc..c4eb6d35d 100644 --- a/tests/Compton_TEST.cxx +++ b/tests/Compton_TEST.cxx @@ -242,7 +242,7 @@ TEST(Compton, Test_of_e) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1) { + if (ecut == INF && vcut == 1) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss( comp.GetHash(), energy, rate_new), @@ -388,7 +388,7 @@ TEST(Compton, Test_of_e_Interpolant) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1) { + if (ecut == INF && vcut == 1) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss( comp.GetHash(), energy, rate_new), diff --git a/tests/Epairproduction_TEST.cxx b/tests/Epairproduction_TEST.cxx index 9fb64975e..f7ec871af 100644 --- a/tests/Epairproduction_TEST.cxx +++ b/tests/Epairproduction_TEST.cxx @@ -303,7 +303,7 @@ TEST(Epairproduction, Test_Stochastic_Loss) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1 ) { + if (ecut == INF && vcut == 1 ) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss(comp.GetHash(), energy, rate_new), ""); #endif @@ -358,13 +358,13 @@ TEST(Epairproduction, Test_of_dEdx_Interpolant) dEdx_new = cross->CalculatedEdx(energy) * medium->GetMassDensity(); - if (particleName == "TauMinus" and mediumName == "uranium" and energy == 1e4) + if (particleName == "TauMinus" && mediumName == "uranium" && energy == 1e4) EXPECT_EQ(dEdx_new, 0.); // lower limit in E for table not precise enough else if (vcut * energy == ecut) EXPECT_NEAR(dEdx_new, dEdx_stored, 5e-2 * dEdx_stored); // kink in interpolated function - else if (particleName == "TauMinus" and energy <= 10000) + else if (particleName == "TauMinus" && energy <= 10000) EXPECT_NEAR(dEdx_new, dEdx_stored, 1e-2 * dEdx_stored); // integrand looks bad - else if (particleName == "TauMinus" and mediumName == "hydrogen" and energy <= 1e5) + else if (particleName == "TauMinus" && mediumName == "hydrogen" && energy <= 1e5) EXPECT_NEAR(dEdx_new, dEdx_stored, 1e-2 * dEdx_stored); // integrand looks bad else EXPECT_NEAR(dEdx_new, dEdx_stored, 1e-3 * dEdx_stored); @@ -409,7 +409,7 @@ TEST(Epairproduction, Test_of_dNdx_Interpolant) dNdx_new = cross->CalculatedNdx(energy) * medium->GetMassDensity(); if (vcut * energy == ecut) EXPECT_NEAR(dNdx_new, dNdx_stored, 5e-2 * dNdx_stored); - else if (particleName == "TauMinus" and mediumName == "hydrogen" and energy <= 1e5) + else if (particleName == "TauMinus" && mediumName == "hydrogen" && energy <= 1e5) EXPECT_NEAR(dNdx_new, dNdx_stored, 1e-2 * dNdx_stored); // integrand looks bad else EXPECT_NEAR(dNdx_new, dNdx_stored, 1e-3 * dNdx_stored); @@ -463,19 +463,19 @@ TEST(Epairproduction, Test_of_e_interpol) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1 ) { + if (ecut == INF && vcut == 1 ) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss(comp.GetHash(), energy, rate_new), ""); #endif } else { auto v = cross->CalculateStochasticLoss(comp.GetHash(), energy, rate_new); - if (rnd1 < 0.1 or rnd1 > 0.9) + if (rnd1 < 0.1 || rnd1 > 0.9) EXPECT_NEAR(v * energy, stochastic_loss_stored, 5E-2 * stochastic_loss_stored); else if (energy * vcut == ecut) EXPECT_NEAR(v * energy, stochastic_loss_stored, 1E-2 * stochastic_loss_stored); - else if (particleName == "TauMinus" and energy <= 1e5) + else if (particleName == "TauMinus" && energy <= 1e5) EXPECT_NEAR(v * energy, stochastic_loss_stored, 1E-2 * stochastic_loss_stored); // integrand problems - else if (particleName == "EMinus" and energy >= 1e11) + else if (particleName == "EMinus" && energy >= 1e11) EXPECT_NEAR(v * energy, stochastic_loss_stored, 1E-2 * stochastic_loss_stored); else EXPECT_NEAR(v * energy, stochastic_loss_stored, 1E-3 * stochastic_loss_stored); diff --git a/tests/Ionization_TEST.cxx b/tests/Ionization_TEST.cxx index b9119d73b..7510f761b 100644 --- a/tests/Ionization_TEST.cxx +++ b/tests/Ionization_TEST.cxx @@ -160,7 +160,7 @@ TEST(Ionization, Test_of_dEdx) auto medium = CreateMedium(mediumName); auto ecuts = std::make_shared(ecut, vcut, cont_rand); - if (parametrization != "BetheBlochRossi" and particle_def.mass != ME) + if (parametrization != "BetheBlochRossi" && particle_def.mass != ME) continue; nlohmann::json config; @@ -205,7 +205,7 @@ TEST(Ionization, Test_of_dNdx) auto medium = CreateMedium(mediumName); auto ecuts = std::make_shared(ecut, vcut, cont_rand); - if (parametrization != "BetheBlochRossi" and particle_def.mass != ME) + if (parametrization != "BetheBlochRossi" && particle_def.mass != ME) continue; nlohmann::json config; @@ -250,7 +250,7 @@ TEST(Ionization, Test_Stochastic_Loss) auto medium = CreateMedium(mediumName); auto ecuts = std::make_shared(ecut, vcut, cont_rand); - if (parametrization != "BetheBlochRossi" and particle_def.mass != ME) + if (parametrization != "BetheBlochRossi" && particle_def.mass != ME) continue; nlohmann::json config; @@ -266,7 +266,7 @@ TEST(Ionization, Test_Stochastic_Loss) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1 ) { + if (ecut == INF && vcut == 1 ) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss(medium->GetHash(), energy, rate_new), ""); #endif @@ -309,7 +309,7 @@ TEST(Ionization, Test_of_dEdx_Interpolant) nlohmann::json config; config["parametrization"] = parametrization; - if (parametrization != "BetheBlochRossi" and particle_def.mass != ME) + if (parametrization != "BetheBlochRossi" && particle_def.mass != ME) continue; auto cross = make_ionization(particle_def, *medium, ecuts, true, @@ -354,7 +354,7 @@ TEST(Ionization, Test_of_dNdx_Interpolant) nlohmann::json config; config["parametrization"] = parametrization; - if (parametrization != "BetheBlochRossi" and particle_def.mass != ME) + if (parametrization != "BetheBlochRossi" && particle_def.mass != ME) continue; auto cross = make_ionization(particle_def, *medium, ecuts, true, @@ -402,7 +402,7 @@ TEST(Ionization, Test_of_e_interpol) nlohmann::json config; config["parametrization"] = parametrization; - if (parametrization != "BetheBlochRossi" and particle_def.mass != ME) + if (parametrization != "BetheBlochRossi" && particle_def.mass != ME) continue; auto cross = make_ionization(particle_def, *medium, ecuts, true, @@ -415,7 +415,7 @@ TEST(Ionization, Test_of_e_interpol) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1 ) { + if (ecut == INF && vcut == 1 ) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss(medium->GetHash(), energy, rate_new), ""); #endif diff --git a/tests/Mupairproduction_TEST.cxx b/tests/Mupairproduction_TEST.cxx index 59afcaf8c..b1ba130a6 100644 --- a/tests/Mupairproduction_TEST.cxx +++ b/tests/Mupairproduction_TEST.cxx @@ -307,7 +307,7 @@ TEST(Mupairproduction, Test_Stochastic_Loss) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1) { + if (ecut == INF && vcut == 1) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss(comp.GetHash(), energy, rate_new), ""); #endif @@ -542,7 +542,7 @@ TEST(Mupairproduction, Test_of_e_interpol) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1 ) { + if (ecut == INF && vcut == 1 ) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss(comp.GetHash(), energy, rate_new), ""); #endif diff --git a/tests/Photonuclear_TEST.cxx b/tests/Photonuclear_TEST.cxx index c9866d863..ef0beec76 100644 --- a/tests/Photonuclear_TEST.cxx +++ b/tests/Photonuclear_TEST.cxx @@ -389,7 +389,7 @@ TEST(PhotoRealPhotonAssumption, Test_of_e) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1) { + if (ecut == INF && vcut == 1) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss( comp.GetHash(), energy, rate_new), @@ -465,13 +465,13 @@ TEST(PhotoRealPhotonAssumption, Test_of_dEdx_Interpolant) dEdx_new = cross->CalculatedEdx(energy) * medium->GetMassDensity(); - if (hard_component == 1 and energy == 1e5) + if (hard_component == 1 && energy == 1e5) EXPECT_NEAR(dEdx_new, dEdx_stored, 1e-1 * dEdx_stored); // kink in function (see issue #124) else if (vcut * energy == ecut) EXPECT_NEAR( dEdx_new, dEdx_stored, 1e-1 * dEdx_stored); // kink in function - else if (parametrization == "Rhode" and energy <= 10000) + else if (parametrization == "Rhode" && energy <= 10000) EXPECT_NEAR(dEdx_new, dEdx_stored, 1e-2 * dEdx_stored); // slight "bumps" in function, hard to // interpolate @@ -521,13 +521,13 @@ TEST(PhotoRealPhotonAssumption, Test_of_dNdx_Interpolant) if (energy * vcut == ecut) EXPECT_NEAR( dNdx_new, dNdx_stored, 1e-1 * dNdx_stored); // kink in function - else if (hard_component == 1 and energy >= 1e10) + else if (hard_component == 1 && energy >= 1e10) EXPECT_NEAR(dNdx_new, dNdx_stored, 1e-2 * dNdx_stored); // for high E, high_component correction // produces artefacts due to hard cutoff // for v=1e-7 in differential cross section // (see issue #124) - else if (hard_component == 1 and energy == 1e5) + else if (hard_component == 1 && energy == 1e5) EXPECT_NEAR(dNdx_new, dNdx_stored, 1e-1 * dNdx_stored); // kink in hard_component for E=1e5 (see // issue #124) @@ -585,7 +585,7 @@ TEST(PhotoRealPhotonAssumption, Test_of_e_Interpolant) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1) { + if (ecut == INF && vcut == 1) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss( comp.GetHash(), energy, rate_new), @@ -763,7 +763,7 @@ TEST(PhotoQ2Integration, Test_of_e) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1) { + if (ecut == INF && vcut == 1) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss( comp.GetHash(), energy, rate_new), @@ -833,8 +833,8 @@ TEST(PhotoQ2Integration, Test_of_dEdx_Interpolant) EXPECT_NEAR( dEdx_new, dEdx_stored, 1e-1 * dEdx_stored); // kink in integral else if (parametrization == "AbramowiczLevinLevyMaor91" - and shadowing == "ButkevichMikheyev" and particleName == "MuMinus" - and energy == 100000000000 and ecut == INF and vcut == 1) + && shadowing == "ButkevichMikheyev" && particleName == "MuMinus" + && energy == 100000000000 && ecut == INF && vcut == 1) EXPECT_NEAR(dEdx_new, dEdx_stored, 1e-2 * dEdx_stored); // bump in integral for these specific // parameter @@ -949,7 +949,7 @@ TEST(PhotoQ2Integration, Test_of_e_Interpolant) sum += dNdx_for_comp; if (sum > dNdx_full * rnd2) { double rate_new = dNdx_for_comp * rnd1; - if (ecut == INF and vcut == 1) { + if (ecut == INF && vcut == 1) { #ifndef NDEBUG EXPECT_DEATH(cross->CalculateStochasticLoss( comp.GetHash(), energy, rate_new), diff --git a/tests/Scattering_TEST.cxx b/tests/Scattering_TEST.cxx index 13d9424f6..bb2cb00be 100644 --- a/tests/Scattering_TEST.cxx +++ b/tests/Scattering_TEST.cxx @@ -396,7 +396,7 @@ TEST(Scattering, ScatterReproducibilityTest) // There has been a correction in the LPM effect parametrization for // bremsstrahlung which influences the scattering angles for electrons // see commit 7be271c3eeafc8b7093340168c2cd739392ee6c4 - if (particleName == "EMinus" and parametrization == "HighlandIntegral") + if (particleName == "EMinus" && parametrization == "HighlandIntegral") continue; while (energy_previous < energy_init)