Skip to content
Snippets Groups Projects
Commit 1728a022 authored by Johannes Schumann's avatar Johannes Schumann
Browse files

Add tests for geometry

parent 8f06a8ae
Branches
Tags
1 merge request!6Detector geometries
Pipeline #19045 failed
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
#!/usr/bin/env python
# coding=utf-8
# Filename: test_output.py
__author__ = "Johannes Schumann"
__copyright__ = "Copyright 2020, Johannes Schumann and the KM3NeT collaboration."
__credits__ = []
__license__ = "MIT"
__maintainer__ = "Johannes Schumann"
__email__ = "jschumann@km3net.de"
__status__ = "Development"
import unittest
from km3buu.geometry import *
class TestGeneralGeometry(unittest.TestCase):
def test_abstract_init(self):
with self.assertRaises(TypeError) as ctx:
d = DetectorVolume()
self.assertTrue('method random_pos' in str(ctx.exception))
class TestSphere(unittest.TestCase):
def setUp(self):
self.detector_geometry = SphericalVolume(20, (2, 2, 2))
def test_volume(self):
volume = self.detector_geometry.volume
self.assertAlmostEqual(volume, 33510.32, 2)
def test_random_pos(self):
for i in range(50):
pos = self.detector_geometry.random_pos()
assert pos[0] > -18.0
assert pos[1] > -18.0
assert pos[2] > -18.0
assert pos[0] < 22.0
assert pos[1] < 22.0
assert pos[2] < 22.0
class TestCan(unittest.TestCase):
def setUp(self):
self.detector_geometry = CanVolume()
def test_volume(self):
volume = self.detector_geometry.volume
self.assertAlmostEqual(volume, 243604084.28, 2)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment