File indexing completed on 2026-09-26 08:02:35
0001
0002
0003
0004
0005
0006
0007
0008
0009 import os
0010
0011 import detray.core
0012 import detray.io
0013 import detray.tests
0014
0015
0016 def test_detector_writer_config():
0017 config = detray.io.DetectorWriterConfig()
0018 config.path = "./json_writer_test/"
0019 config.replaceFiles = True
0020 config.compactifyJson = True
0021 config.writeMaterial = False
0022 config.writeGrids = False
0023
0024 assert config.path == "./json_writer_test/"
0025 assert config.replaceFiles
0026 assert config.compactifyJson
0027 assert not config.writeMaterial
0028 assert not config.writeGrids
0029
0030
0031 def test_write_geometry_only(tmp_path):
0032 """Both writer flags reach the C++ writer and suppress their output."""
0033 out_dir = str(tmp_path) + os.sep
0034
0035 det, names = detray.tests.buildToyDetector(
0036 detray.core.HostMemoryResource(), detray.tests.ToyDetectorConfig()
0037 )
0038
0039 config = detray.io.DetectorWriterConfig()
0040 config.path = out_dir
0041
0042 config.writeMaterial = False
0043 config.writeGrids = False
0044
0045 detray.io.writeDetector(det, names, config)
0046
0047 assert os.listdir(out_dir) == ["toy_detector_geometry.json"]