Skip to content

Commit

Permalink
added tests for c12 channels
Browse files Browse the repository at this point in the history
  • Loading branch information
JostMigenda committed May 18, 2020
1 parent 257c730 commit fa0e241
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 2 deletions.
2 changes: 2 additions & 0 deletions interaction_channels/c12e.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def dSigma_dE(eNu, eE):
def dSigma_dCosT(eNu, cosT):
# Small values of cosT are preferred, see arXiv:hep-ex/0105068 (fig. 12,14).
# However, energy dependence is unclear, so we use a constant value for now.
if abs(cosT) > 1:
return 0
return 0.5


Expand Down
2 changes: 2 additions & 0 deletions interaction_channels/c12eb.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def dSigma_dE(eNu, eE):
'''
def dSigma_dCosT(eNu, cosT):
# Energy dependence is unclear, so we use a constant value for now.
if abs(cosT) > 1:
return 0
return 0.5


Expand Down
6 changes: 4 additions & 2 deletions interaction_channels/c12nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def get_eE(eNu, cosT=0):
one floating point number
'''
def dSigma_dE(eNu, eE):
if abs(get_eE(eNu) - eE) > epsilon:
# This should never happen, since we set bounds_eE() accordingly above
if eNu < e_thr or abs(get_eE(eNu) - eE) > epsilon:
# This should never happen, since we set bounds for eE and eNu accordingly above
# ... but just in case:
return 0

Expand All @@ -112,6 +112,8 @@ def dSigma_dE(eNu, eE):
'''
def dSigma_dCosT(eNu, cosT):
# Energy dependence is unclear, so we use a constant value for now.
if abs(cosT) > 1:
return 0
return 0.5


Expand Down
57 changes: 57 additions & 0 deletions interaction_channels/test_c12e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import unittest

from . import c12e
from ._crosssectiontest import CrossSectionTest


class C12ETest(CrossSectionTest):
c = c12e # ensure we can access interaction channel module as self.c

# iterable with tuples (eNu, eE, dSigma_dE(eNu, eE))
test_dSigma_dE_values = (
(25, 7.662, 3.3139319366555277e-18),
(25, 7.6629, 3.3139319366555277e-18),
(50, 32.662, 7.669220668928699e-17),
(75, 57.662, 4.196362653200819e-16),
(100, 82.662, 1.2581902241845584e-15),
)

# iterable with tuples (eNu, eE, dSigma_dE(eNu, eE))
test_dSigma_dE_edgecases_values = (
(17.337, 0, 0), # eNu too small
(25, 7.6609, 0), # eE too small
(25, 7.6631, 0), # eE too large
)

# iterable with tuples (eNu, cosT, dSigma_dE(eNu, cosT))
test_dSigma_dCosT_values = (
(20, -0.99, 0.5),
(20, 0.00, 0.5),
(20, 0.99, 0.5),
(50, -0.50, 0.5),
(50, 0.00, 0.5),
(50, 0.50, 0.5),
)

# iterable with tuples (eNu, cosT, get_eE(eNu, cosT))
test_get_eE_values = (
(20, -0.99, 2.662),
(20, 0.00, 2.662),
(20, 0.99, 2.662),
# testing higher energies is more complicated, since there are multiple possible return values
)

# iterable with tuples (eNu, bounds_eE(eNu)[0], bounds_eE(eNu)[1])
test_bounds_eE_values = (
(20, 2.661, 2.663),
(50, 32.661, 32.663),
)

# value of bounds_eNu[0]
test_bounds_eNu_minvalue = 18.138

# ensure that unittest doesn't run tests in the base class, via https://stackoverflow.com/a/22836015
del(CrossSectionTest)

if __name__ == '__main__':
unittest.main()
57 changes: 57 additions & 0 deletions interaction_channels/test_c12eb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import unittest

from . import c12eb
from ._crosssectiontest import CrossSectionTest


class C12EBTest(CrossSectionTest):
c = c12eb # ensure we can access interaction channel module as self.c

# iterable with tuples (eNu, eE, dSigma_dE(eNu, eE))
test_dSigma_dE_values = (
(25, 10.61, 2.63032746305625e-18),
(25, 10.6109, 2.63032746305625e-18),
(50, 35.61, 5.493977104481186e-17),
(75, 60.61, 2.0634285413474464e-16),
(100, 85.61, 4.993427358604262e-16),
)

# iterable with tuples (eNu, eE, dSigma_dE(eNu, eE))
test_dSigma_dE_edgecases_values = (
(14.389, 0, 0), # eNu too small
(25, 10.6089, 0), # eE too small
(25, 10.6111, 0), # eE too large
)

# iterable with tuples (eNu, cosT, dSigma_dE(eNu, cosT))
test_dSigma_dCosT_values = (
(20, -0.99, 0.5),
(20, 0.00, 0.5),
(20, 0.99, 0.5),
(50, -0.50, 0.5),
(50, 0.00, 0.5),
(50, 0.50, 0.5),
)

# iterable with tuples (eNu, cosT, get_eE(eNu, cosT))
test_get_eE_values = (
(20, -0.99, 5.61),
(20, 0.00, 5.61),
(20, 0.99, 5.61),
# testing higher energies is more complicated, since there are multiple possible return values
)

# iterable with tuples (eNu, bounds_eE(eNu)[0], bounds_eE(eNu)[1])
test_bounds_eE_values = (
(20, 5.609, 5.611),
(50, 35.609, 35.611),
)

# value of bounds_eNu[0]
test_bounds_eNu_minvalue = 15.19

# ensure that unittest doesn't run tests in the base class, via https://stackoverflow.com/a/22836015
del(CrossSectionTest)

if __name__ == '__main__':
unittest.main()
57 changes: 57 additions & 0 deletions interaction_channels/test_c12nc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import unittest

from . import c12nc
from ._crosssectiontest import CrossSectionTest


class C12NCTest(CrossSectionTest):
c = c12nc # ensure we can access interaction channel module as self.c

# iterable with tuples (eNu, eE, dSigma_dE(eNu, eE))
test_dSigma_dE_values = (
(25, 15.11, 1.895519358671657e-18),
(25, 15.1109, 1.895519358671657e-18),
(50, 15.11, 2.3590523576277865e-17),
(75, 15.11, 6.950951642452967e-17),
(100, 15.11, 1.396524979034271e-16),
)

# iterable with tuples (eNu, eE, dSigma_dE(eNu, eE))
test_dSigma_dE_edgecases_values = (
(15.1, 15.11, 0), # eNu too small
(25, 15.1089, 0), # eE too small
(25, 15.1111, 0), # eE too large
)

# iterable with tuples (eNu, cosT, dSigma_dE(eNu, cosT))
test_dSigma_dCosT_values = (
(20, -0.99, 0.5),
(20, 0.00, 0.5),
(20, 0.99, 0.5),
(50, -0.50, 0.5),
(50, 0.00, 0.5),
(50, 0.50, 0.5),
)

# iterable with tuples (eNu, cosT, get_eE(eNu, cosT))
test_get_eE_values = (
(20, -0.99, 15.11),
(20, 0.00, 15.11),
(20, 0.99, 15.11),
# testing higher energies is more complicated, since there are multiple possible return values
)

# iterable with tuples (eNu, bounds_eE(eNu)[0], bounds_eE(eNu)[1])
test_bounds_eE_values = (
(20, 15.109, 15.111),
(50, 15.109, 15.111),
)

# value of bounds_eNu[0]
test_bounds_eNu_minvalue = 15.11

# ensure that unittest doesn't run tests in the base class, via https://stackoverflow.com/a/22836015
del(CrossSectionTest)

if __name__ == '__main__':
unittest.main()

0 comments on commit fa0e241

Please sign in to comment.