diff --git a/km3buu/config.py b/km3buu/config.py index b9c7a0c6eff1fb4d6f5b4aa25b3cdb1e4895c162..9059d6b94d377e4079c3dd688ca87b5138fb391f 100644 --- a/km3buu/config.py +++ b/km3buu/config.py @@ -45,6 +45,7 @@ GSEAGEN_MEDIA_COMPOSITION_FILE = "MediaComposition.xml" class Config(object): + def __init__(self, config_path=CONFIG_PATH): self.config = ConfigParser() self._config_path = config_path diff --git a/km3buu/geometry.py b/km3buu/geometry.py index 1ae11351e13f342f8c686177d149f0eba03f1466..42378c3b4d6457f2f0530fa009a08186c1db1131 100644 --- a/km3buu/geometry.py +++ b/km3buu/geometry.py @@ -19,6 +19,7 @@ class DetectorVolume(ABC): """ Detector geometry class """ + def __init__(self): self._volume = -1.0 self._coord_origin = (0., 0., 0.) @@ -82,6 +83,7 @@ class CanVolume(DetectorVolume): zmax: float [m] (default: 476.5) Cylinder top z position """ + def __init__(self, radius=403.4, zmin=0.0, zmax=476.5): super().__init__() self._radius = radius @@ -118,6 +120,7 @@ class SphericalVolume(DetectorVolume): Coordinate center of the sphere (x, y, z) """ + def __init__(self, radius, coord_origin=(0, 0, 0)): super().__init__() self._radius = radius diff --git a/km3buu/jobcard.py b/km3buu/jobcard.py index a03f217c936a97dfac60369874d56046135eb491..15c99f6b7b1f26d9eec1910273785ca2517022c5 100644 --- a/km3buu/jobcard.py +++ b/km3buu/jobcard.py @@ -58,6 +58,7 @@ class Jobcard(f90nml.Namelist): input_path: str The input path pointing to the GiBUU lookup data which should be used """ + def __init__(self, *args, filename=DEFAULT_JOBCARD_FILENAME, diff --git a/km3buu/output.py b/km3buu/output.py index 31766f0b30178cd19141ff6ca4e866d3393a516b..61e5f75391d57e5c87bcbb4086b1e6dc372c5544 100644 --- a/km3buu/output.py +++ b/km3buu/output.py @@ -274,6 +274,7 @@ def read_nu_abs_xsection(filepath): class GiBUUOutput: + def __init__(self, data_dir): """ Class for parsing GiBUU output files @@ -580,6 +581,7 @@ class GiBUUOutput: return self._generated_events def _determine_flux_index(self): + def fluxfunc(x, a, b): return a * x**b diff --git a/km3buu/tests/test_config.py b/km3buu/tests/test_config.py index 18e2a13ec87d2122279a0a15a349da9e2a446e9c..65436a054e56e37945cb31052ebd130f6d406112 100644 --- a/km3buu/tests/test_config.py +++ b/km3buu/tests/test_config.py @@ -32,6 +32,7 @@ path=/tmp/gseagen class TestConfig(unittest.TestCase): + def setUp(self): self.cfg_tmpfile = NamedTemporaryFile(delete=False) self.mock_image_file = NamedTemporaryFile(delete=False) diff --git a/km3buu/tests/test_ctrl.py b/km3buu/tests/test_ctrl.py index 34d4faa8e300471b005b04c82637d8099384ca06..23090173209c3eebc8e86f3f51d9445af8a65862 100644 --- a/km3buu/tests/test_ctrl.py +++ b/km3buu/tests/test_ctrl.py @@ -25,6 +25,7 @@ TESTDATA_DIR = data_path("gibuu") class TestCTRLbyJobcardFile(unittest.TestCase): + def setUp(self): self.filename = join(TESTDATA_DIR, "km3net_testdata.job") self.output_dir = TemporaryDirectory() @@ -48,6 +49,7 @@ class TestCTRLbyJobcardFile(unittest.TestCase): class TestCTRLbyJobcardObject(unittest.TestCase): + def setUp(self): log = get_logger("ctrl.py") log.setLevel("INFO") diff --git a/km3buu/tests/test_environment.py b/km3buu/tests/test_environment.py index 247690b1e66adda9d5c3c93be01c24a19f5738d8..b5d76bf3b4819b7aecf1d7fe1452ee86ee2d1c58 100644 --- a/km3buu/tests/test_environment.py +++ b/km3buu/tests/test_environment.py @@ -19,6 +19,7 @@ from km3buu import DOCKER_URL, IMAGE_NAME class TestBuild(unittest.TestCase): + def test_wrong_dir_path(self): wrong_path = "foobar" try: diff --git a/km3buu/tests/test_geometry.py b/km3buu/tests/test_geometry.py index 292cac2dd3b709a8279c02976db9148471de7b7a..10a22bda09609c05816a60379fdbd402080f8b2a 100644 --- a/km3buu/tests/test_geometry.py +++ b/km3buu/tests/test_geometry.py @@ -17,12 +17,14 @@ import numpy as np class TestGeneralGeometry(unittest.TestCase): + def test_abstract_init(self): with self.assertRaises(TypeError) as ctx: d = DetectorVolume() class TestSphere(unittest.TestCase): + def setUp(self): self.detector_geometry = SphericalVolume(20, (2, 2, 2)) @@ -44,6 +46,7 @@ class TestSphere(unittest.TestCase): class TestCan(unittest.TestCase): + def setUp(self): self.detector_geometry = CanVolume() diff --git a/km3buu/tests/test_jobcard.py b/km3buu/tests/test_jobcard.py index 6fc45b08949ab74b1a53076233d43e7375dec8fa..69dc53951bfd9945d4fe165bf57434752013838d 100644 --- a/km3buu/tests/test_jobcard.py +++ b/km3buu/tests/test_jobcard.py @@ -20,6 +20,7 @@ from tempfile import TemporaryFile, TemporaryDirectory class TestJobcard(unittest.TestCase): + def setUp(self): self.test_jobcard = Jobcard() # Insert some test elements @@ -49,6 +50,7 @@ class TestJobcard(unittest.TestCase): class TestNeutrinoEnergyRangeJobcard(unittest.TestCase): + def setUp(self): self.test_fluxfile = TemporaryFile() self.test_Z = np.random.randint(1, 100) @@ -99,6 +101,7 @@ class TestNeutrinoEnergyRangeJobcard(unittest.TestCase): class TestNeutrinoSingleEnergyJobcard(unittest.TestCase): + def setUp(self): self.test_fluxfile = TemporaryFile() self.test_Z = np.random.randint(1, 100) @@ -133,6 +136,7 @@ class TestNeutrinoSingleEnergyJobcard(unittest.TestCase): class TestJobcardSeed(unittest.TestCase): + def setUp(self): jc = generate_neutrino_jobcard(100, "CC", diff --git a/km3buu/tests/test_output.py b/km3buu/tests/test_output.py index e6ff083e86bf2be85e29326e899867684426625f..02c9aba5e0206dd9c8658e843c976c9afd9e9609 100644 --- a/km3buu/tests/test_output.py +++ b/km3buu/tests/test_output.py @@ -37,6 +37,7 @@ except ModuleNotFoundError: class TestXSection(unittest.TestCase): + def test_xsection_all(self): filename = join(TESTDATA_DIR, XSECTION_FILENAMES["all"]) xsection = read_nu_abs_xsection(filename) @@ -47,6 +48,7 @@ class TestXSection(unittest.TestCase): class TestGiBUUOutput(unittest.TestCase): + def setup_class(self): self.output = GiBUUOutput(TESTDATA_DIR) @@ -91,6 +93,7 @@ class TestGiBUUOutput(unittest.TestCase): @pytest.mark.skipif(not KM3NET_LIB_AVAILABLE, reason="KM3NeT dataformat required") class TestAANET(unittest.TestCase): + def setUp(self): output = GiBUUOutput(TESTDATA_DIR) datafile = NamedTemporaryFile(suffix=".root") diff --git a/km3buu/tests/test_propagation.py b/km3buu/tests/test_propagation.py index 27d17044e99561100afe8ee46058e0732a1d1420..b1cbea92d9438be21a0338bf6da515b32b386950 100644 --- a/km3buu/tests/test_propagation.py +++ b/km3buu/tests/test_propagation.py @@ -28,6 +28,7 @@ pp.RandomGenerator.get().set_seed(1234) @pytest.mark.skip(reason="CI boost lib problem") class TestTauPropagation(unittest.TestCase): + def setUp(self): data = ak.Array({ "lepOut_E": [