Skip to content

Commit

Permalink
Merge pull request #167 from stewartboogert/xsdSchema
Browse files Browse the repository at this point in the history
Fix gdml schema location and fixed some tests
  • Loading branch information
stewartboogert authored Aug 5, 2024
2 parents ed4d5ed + e109245 commit 764191c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/pyg4ometry/gdml/Writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, prepend=""):
self.top.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
self.top.setAttribute(
"xsi:noNamespaceSchemaLocation",
"http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd",
"http://cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd",
)

self.defines = self.top.appendChild(self.doc.createElement("define"))
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def pytest_sessionfinish(session, exitstatus):
@pytest.fixture(scope="session")
def testdata():
g4data = G4EdgeTestData()
g4data.checkout("601004e")
g4data.checkout("ec37079")
return g4data
11 changes: 9 additions & 2 deletions tests/geant4/T0031_CutTubs_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
flat_ends = 2


def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath=None):
def Test(
vis=False, interactive=False, type=normal, outputPath=None, outputFile=None, refFilePath=None
):
if not outputPath:
outputPath = _pl.Path(__file__).parent

if not outputFile:
outputFile = "T0031_CutTubs_number.gdml"
else:
outputFile = _pl.Path(outputFile)

reg = _g4.Registry()

# defines
Expand Down Expand Up @@ -69,7 +76,7 @@ def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath
reg.setWorld(wl.name)

# gdml output
outputFile = outputPath / "T0031_CutTubs_numbers.gdml"
outputFile = outputPath / outputFile
w = _gd.Writer()
w.addDetector(reg)
w.write(outputFile)
Expand Down
11 changes: 9 additions & 2 deletions tests/geant4/T0032_CutTubs_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
flat_ends = 2


def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath=None):
def Test(
vis=False, interactive=False, type=normal, outputPath=None, outputFile=None, refFilePath=None
):
if not outputPath:
outputPath = _pl.Path(__file__).parent

if not outputFile:
outputFile = "T0032_CutTubs_string.gdml"
else:
outputFile = _pl.Path(outputFile)

reg = _g4.Registry()

# defines
Expand Down Expand Up @@ -70,7 +77,7 @@ def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath
reg.setWorld(wl.name)

# gdml output
outputFile = outputPath / "T0032_CutTubs_string.gdml"
outputFile = outputPath / outputFile
w = _gd.Writer()
w.addDetector(reg)
w.write(outputFile)
Expand Down
13 changes: 10 additions & 3 deletions tests/geant4/T0034_CutTubs_DefineTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
flat_ends = 2


def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath=None):
def Test(
vis=False, interactive=False, type=normal, outputPath=None, outputFile=None, refFilePath=None
):
if not outputPath:
outputPath = _pl.Path(__file__).parent

reg = _g4.Registry()
if not outputFile:
outputFile = "T0034_CutTubs_DefineTree.gdml"
else:
outputFile = _pl.Path(outputFile)

reg = _g4.Registry()

# defines
wx = _gd.Constant("wx", "100", reg, True)
Expand Down Expand Up @@ -85,7 +92,7 @@ def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath
reg.setWorld(wl.name)

# gdml output
outputFile = outputPath / "T0034_CutTubs_DefineTree.gdml"
outputFile = outputPath / outputFile
w = _gd.Writer()
w.addDetector(reg)
w.write(outputFile)
Expand Down
3 changes: 3 additions & 0 deletions tests/geant4/test_geant4solids.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ def test_PythonGeant_T003_CutTubs(tmptestdir, testdata):
vis=False,
interactive=False,
outputPath=tmptestdir,
outputFile="T0031_CutTubs_numbers.gdml",
refFilePath=testdata["gdml/T0031_CutTubs_numbers.gdml"],
)

T0032_CutTubs_string.Test(
vis=False,
interactive=False,
outputPath=tmptestdir,
outputFile="T0032_CutTubs_string.gdml",
refFilePath=testdata["gdml/T0032_CutTubs_string.gdml"],
)

Expand All @@ -192,6 +194,7 @@ def test_PythonGeant_T003_CutTubs(tmptestdir, testdata):
vis=False,
interactive=False,
outputPath=tmptestdir,
outputFile="T0034_CutTubs_DefineTree.gdml",
refFilePath=testdata["gdml/T0034_CutTubs_DefineTree.gdml"],
)

Expand Down

0 comments on commit 764191c

Please sign in to comment.