Skip to content

Commit

Permalink
fix(syntax): Fixed not ignoring vertical mode hidden by comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale authored Feb 13, 2024
2 parents 7f7b606 + e77427a commit 847129e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion montepy/input_parser/input_syntax_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def flush_input():
):
yield from flush_input()
# die if it is a vertical syntax format
if "#" in line[0:BLANK_SPACE_CONTINUE]:
if "#" in line[0:BLANK_SPACE_CONTINUE] and not line_is_comment:
raise errors.UnsupportedFeature("Vertical Input format is not allowed")
# cut line down to allowed length
old_line = line
Expand Down
1 change: 1 addition & 0 deletions tests/inputs/test.imcnp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ foo

MCNP Test Model for MOAA
C cells
c # hidden vertical Do not touch
c
1 1 20
-1000 $ dollar comment
Expand Down
7 changes: 4 additions & 3 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ def test_cell_card_pass_through(self):
# test input pass-through
answer = [
"C cells",
"c # hidden vertical Do not touch",
"c",
"1 1 20",
" -1000 $ dollar comment",
Expand All @@ -354,20 +355,20 @@ def test_cell_card_pass_through(self):
cell = new_prob.cells[1]
output = cell.format_for_mcnp_input((6, 2, 0))
print(output)
self.assertEqual(int(output[3].split("$")[0]), -5)
self.assertEqual(int(output[4].split("$")[0]), -5)
# test mass density printer
cell.mass_density = 10.0
with self.assertWarns(LineExpansionWarning):
output = cell.format_for_mcnp_input((6, 2, 0))
print(output)
self.assertAlmostEqual(float(output[2].split()[2]), -10)
self.assertAlmostEqual(float(output[3].split()[2]), -10)
# ensure that surface number updated
# Test material number change
new_prob = copy.deepcopy(problem)
new_prob.materials[1].number = 5
cell = new_prob.cells[1]
output = cell.format_for_mcnp_input((6, 2, 0))
self.assertEqual(int(output[2].split()[1]), 5)
self.assertEqual(int(output[3].split()[1]), 5)

def test_thermal_scattering_pass_through(self):
problem = copy.deepcopy(self.simple_problem)
Expand Down

0 comments on commit 847129e

Please sign in to comment.