Skip to content

Commit

Permalink
Merge pull request #28 from legend-exp/test-pyg4
Browse files Browse the repository at this point in the history
tests: add tests for pyg4 glue
  • Loading branch information
ManuelHu authored Aug 16, 2023
2 parents a1926c1 + 4dd8702 commit 7f6b8c4
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ write_to = "src/legendoptics/_version.py"
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = "error"
filterwarnings = [
"error",
"ignore::PendingDeprecationWarning:pyg4ometry",
"ignore::DeprecationWarning"
]
log_cli_level = "info"
testpaths = "tests"

Expand Down
59 changes: 59 additions & 0 deletions tests/test_pyg4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import pint
import pyg4ometry.geant4 as g4

u = pint.get_application_registry()


def _create_dummy_mat():
reg = g4.Registry()
mat = g4.MaterialSingleElement("dummy", 1, 1, 1, reg)
return reg, mat


def test_pyg4_attach():
"""Test the attaching of all properties to Geant4 materials."""
import legendoptics # noqa: F401
import legendoptics.copper
import legendoptics.fibers
import legendoptics.germanium
import legendoptics.lar
import legendoptics.nylon
import legendoptics.silicon
import legendoptics.tetratex
import legendoptics.tpb

u = pint.get_application_registry()

reg, mat = _create_dummy_mat()
legendoptics.lar.pyg4_lar_attach_rindex(mat, reg)
legendoptics.lar.pyg4_lar_attach_attenuation(mat, reg, 90 * u.K)
legendoptics.lar.pyg4_lar_attach_scintillation(mat, reg)

reg, mat = _create_dummy_mat()
legendoptics.tpb.pyg4_tpb_attach_rindex(mat, reg)
legendoptics.tpb.pyg4_tpb_attach_wls(mat, reg)

reg, mat = _create_dummy_mat()
legendoptics.fibers.pyg4_fiber_cladding1_attach_rindex(mat, reg)
reg, mat = _create_dummy_mat()
legendoptics.fibers.pyg4_fiber_cladding1_attach_rindex(mat, reg)
reg, mat = _create_dummy_mat()
legendoptics.fibers.pyg4_fiber_core_attach_rindex(mat, reg)
legendoptics.fibers.pyg4_fiber_core_attach_wls(mat, reg)
legendoptics.fibers.pyg4_fiber_core_attach_absorption(mat, reg)

reg, mat = _create_dummy_mat()
legendoptics.tetratex.pyg4_tetratex_attach_reflectivity(mat, reg)

reg, mat = _create_dummy_mat()
legendoptics.germanium.pyg4_germanium_attach_reflectivity(mat, reg)

reg, mat = _create_dummy_mat()
legendoptics.copper.pyg4_copper_attach_reflectivity(mat, reg)

reg, mat = _create_dummy_mat()
legendoptics.silicon.pyg4_silicon_attach_complex_rindex(mat, reg)

reg, mat = _create_dummy_mat()
legendoptics.nylon.pyg4_nylon_attach_rindex(mat, reg)
legendoptics.nylon.pyg4_nylon_attach_absorption(mat, reg)

0 comments on commit 7f6b8c4

Please sign in to comment.