Skip to content

Commit

Permalink
Implemented append for tally groups.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Jan 15, 2024
1 parent 94d0217 commit d98e63e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions montepy/data_inputs/tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from montepy.data_inputs.data_input import DataInputAbstract
from montepy.data_inputs.tally_type import TallyType
from montepy.input_parser.tally_parser import TallyParser
from montepy.input_parser import syntax_node
from montepy.numbered_mcnp_object import Numbered_MCNP_Object
from montepy.utilities import *

Expand Down Expand Up @@ -45,7 +46,7 @@ def __init__(self, input=None):
groups, has_total = TallyGroup.parse_tally_specification(
self._tree["tally"]
)
self._groups = group
self._groups = groups
self._include_total = has_total

@staticmethod
Expand Down Expand Up @@ -80,10 +81,11 @@ def number(self):


class TallyGroup:
__slots__ = {"_cells"}
__slots__ = {"_cells", "_old_numbers"}

def __init__(self, cells=None, nodes=None):
self._cells = montepy.cells.Cells()
self._old_numbers = []

@staticmethod
def parse_tally_specification(tally_spec):
Expand All @@ -97,16 +99,21 @@ def parse_tally_specification(tally_spec):
if in_parens:
if node.value == ")":
in_parens = False
buff.append(node)
buff._append_node(node)
ret.append(buff)
buff = None
else:
buff.apend(node)
buff._append_node(node)
else:
if node.value == "(":
in_parens = True
buff = TallyGroup()
buff.append(node)
buff._append_node(node)
else:
ret.append(TallyGroup(nodes=[node]))
return (ret, has_total)

def _append_node(self, node):
if not isinstance(node, syntax_node.ValueNode):
raise ValueError(f"Can only append ValueNode. {node} given")
self._old_numbers.append(node)

0 comments on commit d98e63e

Please sign in to comment.