Skip to content

Commit 94d58eb

Browse files
pshriwiseclaude
andcommitted
Fix test assertions for scalar temperature/density in Cell.from_xml_element
Cell.from_xml_element now converts single-element lists to scalars (via `elif len(values) == 1: values = values[0]`), so temperature and density round-trip as scalars when a single value is specified. Update test assertions accordingly and fix XML serialization check to use attribute lookup instead of sub-element for scalar temperature. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ceed0c0 commit 94d58eb

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

tests/unit_tests/dagmc/test_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,14 @@ def test_dagmc_xml_temperature_roundtrip():
352352

353353
dag_univ = openmc.DAGMCUniverse.from_xml_element(elem, mats)
354354
assert dag_univ.cells[7].fill.id == 1
355-
assert dag_univ.cells[7].temperature == pytest.approx([825.0])
355+
assert dag_univ.cells[7].temperature == pytest.approx(825.0)
356356

357357
root = ET.Element('geometry')
358358
dag_univ.create_xml_subelement(root)
359359
dagmc_elem = root.find('dagmc_universe')
360360
xml_cell = dagmc_elem.find('cell')
361-
assert xml_cell.find('temperature').text == '825.0'
361+
assert xml_cell.get('temperature') == '825.0'
362362

363363
dag_univ_roundtrip = openmc.DAGMCUniverse.from_xml_element(dagmc_elem, mats)
364364
assert dag_univ_roundtrip.cells[7].fill.id == 1
365-
assert dag_univ_roundtrip.cells[7].temperature == pytest.approx([825.0])
365+
assert dag_univ_roundtrip.cells[7].temperature == pytest.approx(825.0)

tests/unit_tests/test_cell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ def test_dagmccell_from_xml_element():
391391
assert cell.id == 5
392392
assert cell.name == 'fuel'
393393
assert cell.fill is mat
394-
assert cell.density == [10.5]
395-
assert cell.temperature == [900.0]
394+
assert cell.density == 10.5
395+
assert cell.temperature == 900.0
396396

397397
# volume round-trip
398398
xml = '<cell id="6" material="1" volume="42.0"/>'

0 commit comments

Comments
 (0)