-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from legend-exp/python
setup for running Python scripts in unit tests
- Loading branch information
Showing
10 changed files
with
206 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ authors = [ | |
{ name = "Luigi Pertoldi", email = "[email protected]" }, | ||
] | ||
maintainers = [ | ||
{ name = "The LEGEND Collaboration" }, | ||
{ name = "The LEGEND Collaboration" }, | ||
] | ||
description = "A python wrapper for remage" | ||
readme = "README.md" | ||
|
@@ -32,17 +32,32 @@ classifiers = [ | |
] | ||
dynamic = ["version"] | ||
dependencies = [ | ||
"legend-pydataobj", | ||
"legend-pydataobj", | ||
] | ||
|
||
[project.optional-dependencies] | ||
test = [ | ||
"pytest >=6", | ||
"pytest-cov >=3", | ||
"awkward", | ||
"hist[plot]", | ||
"legend-pygeom-optics", | ||
"legend-pygeom-hpges", | ||
"legend-pygeom-tools", | ||
"matplotlib", | ||
"mplhep", | ||
"numpy", | ||
"pandas", | ||
"pyg4ometry", | ||
"numba", # without this, uv somehow fails to pick a good numba version | ||
] | ||
dev = [ | ||
"pytest >=6", | ||
"pytest-cov >=3", | ||
docs = [ | ||
"sphinx-copybutton", | ||
"sphinx-togglebutton", | ||
"sphinx-inline-tabs", | ||
"exhale", | ||
"breathe", | ||
"myst-parser", | ||
] | ||
|
||
[project.scripts] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
file( | ||
GLOB _aux | ||
RELATIVE ${PROJECT_SOURCE_DIR} | ||
macros/*.mac gdml/*.gdml *.py) | ||
|
||
# copy them to the build area | ||
foreach(_file ${_aux}) | ||
configure_file(${PROJECT_SOURCE_DIR}/${_file} ${PROJECT_BINARY_DIR}/${_file} COPYONLY) | ||
endforeach() | ||
|
||
add_test(NAME germanium/gen-output COMMAND ${REMAGE_PYEXE} -g gdml/geometry.gdml -w -o output.lh5 | ||
-- macros/run.mac) | ||
set_tests_properties(germanium/gen-output PROPERTIES LABELS extra FIXTURES_SETUP output-fixture) | ||
|
||
add_test(NAME germanium/bremsstrahlung COMMAND ${PYTHONPATH} ./test_brem.py) | ||
|
||
add_test(NAME germanium/e-range COMMAND ${PYTHONPATH} ./test_e_range.py) | ||
|
||
foreach(_test germanium/bremsstrahlung germanium/e-range) | ||
set_tests_properties(${_test} PROPERTIES LABELS extra FIXTURES_REQUIRED output-fixture) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" ?> | ||
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd"> | ||
<define/> | ||
<materials> | ||
<isotope name="Ge70" Z="32" N="70"> | ||
<atom value="69.924"/> | ||
</isotope> | ||
<isotope name="Ge72" Z="32" N="72"> | ||
<atom value="71.922"/> | ||
</isotope> | ||
<isotope name="Ge73" Z="32" N="73"> | ||
<atom value="72.923"/> | ||
</isotope> | ||
<isotope name="Ge74" Z="32" N="74"> | ||
<atom value="73.921"/> | ||
</isotope> | ||
<isotope name="Ge76" Z="32" N="76"> | ||
<atom value="75.921"/> | ||
</isotope> | ||
<element name="ElementNaturalGermanium" formula="NatGe"> | ||
<fraction ref="Ge70" n="0.2057"/> | ||
<fraction ref="Ge72" n="0.2745"/> | ||
<fraction ref="Ge73" n="0.0775"/> | ||
<fraction ref="Ge74" n="0.365"/> | ||
<fraction ref="Ge76" n="0.0773"/> | ||
</element> | ||
<material name="NaturalGermanium"> | ||
<D value="5.3234"/> | ||
<fraction ref="ElementNaturalGermanium" n="1"/> | ||
</material> | ||
</materials> | ||
<solids> | ||
<orb name="world" r="20" lunit="cm"/> | ||
<orb name="germanium" r="15" lunit="cm"/> | ||
</solids> | ||
<structure> | ||
<volume name="germanium"> | ||
<materialref ref="NaturalGermanium"/> | ||
<solidref ref="germanium"/> | ||
</volume> | ||
<volume name="world"> | ||
<materialref ref="G4_Galactic"/> | ||
<solidref ref="world"/> | ||
<physvol name="germanium"> | ||
<volumeref ref="germanium"/> | ||
</physvol> | ||
</volume> | ||
</structure> | ||
<setup name="Default" version="1.0"> | ||
<world ref="world"/> | ||
</setup> | ||
</gdml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import annotations | ||
|
||
import legendhpges as hpges | ||
import pyg4ometry as pg4 | ||
|
||
reg = pg4.geant4.Registry() | ||
|
||
# create a world volume | ||
world_s = pg4.geant4.solid.Orb("world", 20, registry=reg, lunit="cm") | ||
world_l = pg4.geant4.LogicalVolume(world_s, "G4_Galactic", "world", registry=reg) | ||
reg.setWorld(world_l) | ||
|
||
# let's make a germanium balloon | ||
natge = hpges.materials.make_natural_germanium(reg) | ||
|
||
ge_s = pg4.geant4.solid.Orb("germanium", 15, registry=reg, lunit="cm") | ||
ge_l = pg4.geant4.LogicalVolume(ge_s, natge, "germanium", registry=reg) | ||
pg4.geant4.PhysicalVolume( | ||
[0, 0, 0], [0, 0, 0], ge_l, "germanium", world_l, registry=reg | ||
) | ||
|
||
w = pg4.gdml.Writer() | ||
w.addDetector(reg) | ||
w.write("geometry.gdml") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/RMG/Geometry/RegisterDetector Germanium germanium 001 | ||
|
||
/run/initialize | ||
|
||
/RMG/Generator/Confine Volume | ||
/RMG/Generator/Confinement/Geometrical/AddSolid Sphere | ||
/RMG/Generator/Confinement/Geometrical/Sphere/OuterRadius 10 | ||
|
||
/RMG/Generator/Confinement/Geometrical/CenterPositionX 0 | ||
/RMG/Generator/Confinement/Geometrical/CenterPositionY 0 | ||
/RMG/Generator/Confinement/Geometrical/CenterPositionZ 0 | ||
|
||
/RMG/Generator/Select GPS | ||
/gps/particle e- | ||
/gps/ang/type iso | ||
/gps/energy 1000 keV | ||
|
||
/run/beamOn 10000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# lh5.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# lh5.read() |