Skip to content

Commit

Permalink
Merge branch 'develop' into README-update
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale authored Jan 12, 2024
2 parents dc28388 + 790538e commit 9ab7bfd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion montepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions montepy/input_parser/syntax_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_edge_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9ab7bfd

Please sign in to comment.