File indexing completed on 2026-11-26 09:23:20
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.replace_files = True
0020 config.compactify_json = True
0021 config.write_material = False
0022 config.write_grids = False
0023
0024 assert config.path == "./json_writer_test/"
0025 assert config.replace_files
0026 assert config.compactify_json
0027 assert not config.write_material
0028 assert not config.write_grids
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.build_toy_detector(
0036 detray.core.HostMemoryResource(), detray.tests.ToyDetectorConfig()
0037 )
0038
0039 config = detray.io.DetectorWriterConfig()
0040 config.path = out_dir
0041
0042 config.write_material = False
0043 config.write_grids = False
0044
0045 detray.io.write_detector_json(det, names, config)
0046
0047 assert os.listdir(out_dir) == ["toy_detector_geometry.json"]