Skip to content

Commit

Permalink
fix logical expression in tests. they should now be windows compatible (
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxSac authored Apr 16, 2021
1 parent 44265c6 commit 6af52b1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
16 changes: 8 additions & 8 deletions tests/Bremsstrahlung_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -455,19 +455,19 @@ 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
} else {
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);
Expand Down
4 changes: 2 additions & 2 deletions tests/Compton_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
18 changes: 9 additions & 9 deletions tests/Epairproduction_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions tests/Ionization_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ TEST(Ionization, Test_of_dEdx)
auto medium = CreateMedium(mediumName);
auto ecuts = std::make_shared<EnergyCutSettings>(ecut, vcut, cont_rand);

if (parametrization != "BetheBlochRossi" and particle_def.mass != ME)
if (parametrization != "BetheBlochRossi" && particle_def.mass != ME)
continue;

nlohmann::json config;
Expand Down Expand Up @@ -205,7 +205,7 @@ TEST(Ionization, Test_of_dNdx)
auto medium = CreateMedium(mediumName);
auto ecuts = std::make_shared<EnergyCutSettings>(ecut, vcut, cont_rand);

if (parametrization != "BetheBlochRossi" and particle_def.mass != ME)
if (parametrization != "BetheBlochRossi" && particle_def.mass != ME)
continue;

nlohmann::json config;
Expand Down Expand Up @@ -250,7 +250,7 @@ TEST(Ionization, Test_Stochastic_Loss)
auto medium = CreateMedium(mediumName);
auto ecuts = std::make_shared<EnergyCutSettings>(ecut, vcut, cont_rand);

if (parametrization != "BetheBlochRossi" and particle_def.mass != ME)
if (parametrization != "BetheBlochRossi" && particle_def.mass != ME)
continue;

nlohmann::json config;
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/Mupairproduction_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions tests/Photonuclear_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion tests/Scattering_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6af52b1

Please sign in to comment.