Skip to content

Commit 0ab46df

Browse files
authored
Fix cell data parsing (#3848)
1 parent 70be650 commit 0ab46df

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

openmc/cell.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -747,15 +747,6 @@ def from_xml_element(cls, elem, surfaces, materials, get_universe):
747747
c.region = Region.from_expression(region, surfaces)
748748

749749
# Check for other attributes
750-
temperature = get_elem_list(elem, 'temperature', float)
751-
if temperature is not None:
752-
if len(temperature) > 1:
753-
c.temperature = temperature
754-
else:
755-
c.temperature = temperature[0]
756-
density = get_elem_list(elem, 'density', float)
757-
if density is not None:
758-
c.density = density if len(density) > 1 else density[0]
759750
v = get_text(elem, 'volume')
760751
if v is not None:
761752
c.volume = float(v)
@@ -764,6 +755,8 @@ def from_xml_element(cls, elem, surfaces, materials, get_universe):
764755
if values is not None:
765756
if key == 'rotation' and len(values) == 9:
766757
values = np.array(values).reshape(3, 3)
758+
elif len(values) == 1:
759+
values = values[0]
767760
setattr(c, key, values)
768761

769762
# Add this cell to appropriate universe

tests/unit_tests/test_model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ def test_import_properties(run_in_tmpdir, mpi_intracomm):
265265
# Check to see that values are assigned to the C and python representations
266266
# First python
267267
cell = model.geometry.get_all_cells()[1]
268-
assert cell.temperature == [600.0]
269-
assert cell.density == [pytest.approx(10.0, 1e-5)]
268+
assert cell.temperature == 600.0
269+
assert cell.density == pytest.approx(10.0, 1e-5)
270270
assert cell.fill.get_mass_density() == pytest.approx(5.0)
271271
# Now C
272272
assert openmc.lib.cells[1].get_temperature() == 600.
@@ -286,8 +286,8 @@ def test_import_properties(run_in_tmpdir, mpi_intracomm):
286286
'with_properties/settings.xml'
287287
)
288288
cell = model_with_properties.geometry.get_all_cells()[1]
289-
assert cell.temperature == [600.0]
290-
assert cell.density == [pytest.approx(10.0, 1e-5)]
289+
assert cell.temperature == 600.0
290+
assert cell.density == pytest.approx(10.0, 1e-5)
291291
assert cell.fill.get_mass_density() == pytest.approx(5.0)
292292

293293

0 commit comments

Comments
 (0)