diff --git a/montepy/__init__.py b/montepy/__init__.py index ac6b79ec..ac195ceb 100644 --- a/montepy/__init__.py +++ b/montepy/__init__.py @@ -23,7 +23,8 @@ from montepy.universe import Universe import sys -__version__ = "0.2.5dev2" +__version__ = "0.2.5" + # enable deprecated warnings for users if not sys.warnoptions: import os, warnings diff --git a/montepy/input_parser/syntax_node.py b/montepy/input_parser/syntax_node.py index ff301500..b6c1b6d1 100644 --- a/montepy/input_parser/syntax_node.py +++ b/montepy/input_parser/syntax_node.py @@ -241,8 +241,19 @@ def format(self): @property def comments(self): - for node in self.nodes.values(): - yield from node.comments + for key, node in self.nodes.items(): + if isinstance(node, SyntaxNodeBase): + yield from node.comments + elif isinstance(node, dict): + yield from GeometryTree._recurse_comments(node) + + @staticmethod + def _recurse_comments(tree): + for node in tree.values(): + if isinstance(node, SyntaxNodeBase): + yield from node.comments + elif isinstance(node, dict): + yield from GeometryTree._recurse_comments(node) @property def left(self): diff --git a/tests/test_edge_cases.py b/tests/test_edge_cases.py index ba4c6609..9285e4e7 100644 --- a/tests/test_edge_cases.py +++ b/tests/test_edge_cases.py @@ -160,3 +160,19 @@ def test_void_cell_set_material(self): print(output) parts = output[0].split() self.assertAlmostEqual(float(parts[2]), -dens_value, places=9) + + def test_geometry_comments(self): + in_strs = """21073 130 0.010000 (-11516 97 -401 ) $ C 1 Lower water + :(-11526 97 -401 ) $ C 2 Lower water + :(-11536 97 -401 ) $ C 3 Lower water + :(-11546 97 -401 ) $ C 4 Lower water + :(-11556 97 -401 ) $ C 5 Lower water + :(-11576 97 -401 ) imp:n=1 $ C 7 Lower water""".split( + "\n" + ) + input = montepy.input_parser.mcnp_input.Input( + in_strs, montepy.input_parser.block_type.BlockType.CELL + ) + cell = montepy.Cell(input) + # this step caused an error for #163 + cell.comments