Fix boolean export/import

This commit is contained in:
Paul Romano 2025-10-02 11:11:11 -05:00
parent 8743e9dc0d
commit 7b63d6318b
2 changed files with 7 additions and 4 deletions

View file

@ -1720,6 +1720,9 @@ class Settings:
root.append(mesh.to_xml_element())
if mesh_memo is not None:
mesh_memo.add(mesh.id)
elif isinstance(value, bool):
subelement = ET.SubElement(element, key)
subelement.text = str(value).lower()
else:
subelement = ET.SubElement(element, key)
subelement.text = str(value)
@ -2122,11 +2125,11 @@ class Settings:
self.random_ray['source_shape'] = child.text
elif child.tag == 'volume_normalized_flux_tallies':
self.random_ray['volume_normalized_flux_tallies'] = (
child.text.lower() in ('true', '1')
child.text in ('true', '1')
)
elif child.tag == 'adjoint':
self.random_ray['adjoint'] = (
child.text.lower() in ('true', '1')
child.text in ('true', '1')
)
elif child.tag == 'sample_method':
self.random_ray['sample_method'] = child.text

View file

@ -165,8 +165,8 @@ def test_export_to_xml(run_in_tmpdir):
assert recovered_mesh.upper_right == [2., 2., 2.]
assert s.random_ray['volume_estimator'] == 'hybrid'
assert s.random_ray['source_shape'] == 'linear'
assert s.random_ray['volume_normalized_flux_tallies'] == True
assert s.random_ray['adjoint'] == False
assert s.random_ray['volume_normalized_flux_tallies']
assert not s.random_ray['adjoint']
assert s.random_ray['sample_method'] == 'halton'
assert s.max_secondaries == 1_000_000
assert s.source_rejection_fraction == 0.01