summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Mastbaum <mastbaum@hep.upenn.edu>2012-05-01 11:46:30 -0400
committertlatorre <tlatorre@uchicago.edu>2021-05-09 08:42:39 -0700
commit8a4a94466930205826c638a69a3501b6aecd5006 (patch)
tree61196154e6b40e3cbebc9b7ac7fa7b75ec6f2d05
parentb22129a30493e415a6d239cc64f1695eb1a8be93 (diff)
downloadchroma-8a4a94466930205826c638a69a3501b6aecd5006.tar.gz
chroma-8a4a94466930205826c638a69a3501b6aecd5006.tar.bz2
chroma-8a4a94466930205826c638a69a3501b6aecd5006.zip
more unit test fixes
update remaining unit tests to build BVHs with ``loader.create_geometry_from_obj`` instead of the (removed) ``build`` method.
-rw-r--r--chroma/sim.py4
-rw-r--r--test/test_detector.py7
-rw-r--r--test/test_pdf.py4
-rw-r--r--test/test_propagation.py5
-rw-r--r--test/test_ray_intersection.py3
-rw-r--r--test/test_reemission.py9
6 files changed, 16 insertions, 16 deletions
diff --git a/chroma/sim.py b/chroma/sim.py
index c7b2026..a8b0c90 100644
--- a/chroma/sim.py
+++ b/chroma/sim.py
@@ -40,10 +40,6 @@ class Simulation(object):
self.context = gpu.create_cuda_context(cuda_device)
- if not hasattr(detector, 'mesh'):
- # need to build geometry
- detector.build()
-
if hasattr(detector, 'num_channels'):
self.gpu_geometry = gpu.GPUDetector(detector)
self.gpu_daq = gpu.GPUDaq(self.gpu_geometry)
diff --git a/test/test_detector.py b/test/test_detector.py
index 9660e59..e1ff622 100644
--- a/test/test_detector.py
+++ b/test/test_detector.py
@@ -2,6 +2,7 @@ import unittest
import numpy as np
from chroma.geometry import Solid, Geometry, vacuum
+from chroma.loader import create_geometry_from_obj
from chroma.detector import Detector
from chroma.make import box
from chroma.sim import Simulation
@@ -17,10 +18,10 @@ class TestDetector(unittest.TestCase):
cube.set_time_dist_gaussian(1.2, -6.0, 6.0)
cube.set_charge_dist_gaussian(1.0, 0.1, 0.5, 1.5)
- cube.build(use_cache=False)
+ geo = create_geometry_from_obj(cube, update_bvh_cache=False)
- self.cube = cube
- self.sim = Simulation(cube, geant4_processes=0)
+ self.geo = geo
+ self.sim = Simulation(self.geo, geant4_processes=0)
def testTime(self):
'''Test PMT time distribution'''
diff --git a/test/test_pdf.py b/test/test_pdf.py
index df13a2a..1d9e20a 100644
--- a/test/test_pdf.py
+++ b/test/test_pdf.py
@@ -3,6 +3,7 @@ import numpy as np
import itertools
import chroma.demo
+from chroma.loader import create_geometry_from_obj
from chroma.generator.photon import G4ParallelGenerator
from chroma.generator.vertex import constant_particle_gun
from chroma.demo.optics import water
@@ -11,8 +12,7 @@ from chroma.sim import Simulation
class TestPDF(unittest.TestCase):
def setUp(self):
- self.detector = chroma.demo.tiny()
- self.detector.build()
+ self.detector = create_geometry_from_obj(chroma.demo.tiny(), update_bvh_cache=False)
self.vertex_gen = constant_particle_gun('e-', (0,0,0), (1,0,0), 10)
def testGPUPDF(self):
diff --git a/test/test_propagation.py b/test/test_propagation.py
index e1b52ae..114fcfb 100644
--- a/test/test_propagation.py
+++ b/test/test_propagation.py
@@ -2,6 +2,7 @@ import unittest
import numpy as np
from chroma.geometry import Solid, Geometry, vacuum
+from chroma.loader import create_geometry_from_obj
from chroma.make import box
from chroma.sim import Simulation
from chroma.event import Photons
@@ -19,8 +20,8 @@ class TestPropagation(unittest.TestCase):
# Setup geometry
cube = Geometry(vacuum)
cube.add_solid(Solid(box(100,100,100), vacuum, vacuum))
- cube.build(use_cache=False)
- sim = Simulation(cube, geant4_processes=0)
+ geo = create_geometry_from_obj(cube, update_bvh_cache=False)
+ sim = Simulation(geo, geant4_processes=0)
# Create initial photons
nphotons = 10000
diff --git a/test/test_ray_intersection.py b/test/test_ray_intersection.py
index 8a33ac3..d79a9dd 100644
--- a/test/test_ray_intersection.py
+++ b/test/test_ray_intersection.py
@@ -9,7 +9,8 @@ class TestRayIntersection(unittest.TestCase):
self.context = chroma.gpu.create_cuda_context()
self.module = chroma.gpu.get_cu_module('mesh.h')
self.gpu_funcs = chroma.gpu.GPUFuncs(self.module)
- self.box = chroma.gpu.GPUGeometry(chroma.build(chroma.make.cube(size=1000.0)))
+ cube = chroma.loader.create_geometry_from_obj(chroma.make.cube(size=1000.0), update_bvh_cache=False)
+ self.box = chroma.gpu.GPUGeometry(cube)
pos, dir = chroma.project.from_film()
self.pos_gpu = ga.to_gpu(chroma.gpu.to_float3(pos))
diff --git a/test/test_reemission.py b/test/test_reemission.py
index 8fd3569..4ad5fef 100644
--- a/test/test_reemission.py
+++ b/test/test_reemission.py
@@ -13,10 +13,11 @@ from chroma.tools import enable_debug_on_crash
class TestReemission(unittest.TestCase):
def testBulkReemission(self):
- '''Test bulk reemission by starting a bunch of monoenergetic photons at
- the center of a wavelength-shifting sphere, forcing reemission, and
- checking that the final wavelength distribution matches the wls
- spectrum.
+ '''Test bulk reemission
+
+ Start a bunch of monoenergetic photons at the center of a wavelength-
+ shifting sphere, forcing reemission, and check that the final
+ wavelength distribution matches the wls spectrum.
'''
nphotons = 1000