Skip to content

Commit

Permalink
Converted SMIDGE bond delimiters from curly braces "{}" to chevrons "…
Browse files Browse the repository at this point in the history
…<>" to make f-string formatting less annoying
  • Loading branch information
timbernat committed Apr 15, 2024
1 parent 3d5bb98 commit 63ae833
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions polymerist/polymers/smidgelib/smidgeread.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def transition(self, register : SMIDGEReaderRegister) -> 'SMIDGEReadState': # sa
']' : MonomerEnd(),
'(' : BranchStart(),
')' : BranchEnd(),
'{' : BondStart(),
'}' : BondEnd(),
'<' : BondStart(),
'>' : BondEnd(),
}
return READ_STATE_MAP.get(register.curr_token, Accumulate()) # treat Accumulate as default (and thereby starting) state

Expand Down
8 changes: 4 additions & 4 deletions polymerist/polymers/smidgelib/smidgewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ class VisitNode(SMIDGEWriterState):
def state_action(self, register: SMIDGEWriterRegister) -> SMIDGEWriterState:
if register.prev_idx is not None:
register.bond_info = MonomerGraphBondInfo(
incoming_flavor=register.monograph.nodes[register.prev_idx].get('neighbor_flavors', {}).get(register.curr_idx),
bondtype=register.monograph.edges[register.prev_idx, register.curr_idx].get('bondtype'),
outgoing_flavor=register.monograph.nodes[register.curr_idx].get('neighbor_flavors', {}).get(register.prev_idx),
incoming_flavor=register.monograph.nodes[register.prev_idx].get(MonomerGraph.FLAVOR_DICT_ATTR, {}).get(register.curr_idx),
bondtype=register.monograph.edges[register.prev_idx, register.curr_idx].get(MonomerGraph.BONDTYPE_ATTR),
outgoing_flavor=register.monograph.nodes[register.curr_idx].get(MonomerGraph.FLAVOR_DICT_ATTR, {}).get(register.prev_idx), # NOTE : the same as incoming_flavor, but with the order of nodes reversed
)
else:
register.bond_info = MonomerGraphBondInfo()
Expand All @@ -97,7 +97,7 @@ def transition(self, register: SMIDGEWriterRegister) -> SMIDGEWriterState:
class WriteEdge(SMIDGEWriterState):
'''Add an entry for the current edge to the output tokens'''
def state_action(self, register: SMIDGEWriterRegister) -> SMIDGEWriterState:
register.tokens.append(f'{{{register.bond_info!s}}}')
register.tokens.append(f'<{register.bond_info!s}>')

def transition(self, register: SMIDGEWriterRegister) -> SMIDGEWriterState:
return WriteNode()
Expand Down

0 comments on commit 63ae833

Please sign in to comment.