Skip to content

Commit

Permalink
New: Allow None values in formula
Browse files Browse the repository at this point in the history
  • Loading branch information
avcopan committed Dec 5, 2024
1 parent 5a89ff8 commit a2515df
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions automol/form/_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import collections
import functools
import itertools
from collections.abc import Sequence

import pyparsing as pp
from _collections_abc import Sequence
from pyparsing import pyparsing_common as ppc

from phydat import ptab
Expand Down Expand Up @@ -112,13 +112,11 @@ def add_element(fml: Formula, symb: str, num: int = 1) -> Formula:

symb = ptab.to_symbol(symb)
fml = fml.copy()
if symb in fml:
fml[symb] += num
if fml.get(symb) is not None:
fml[symb] += num if num is not None else 0
else:
fml[symb] = num

assert fml[symb] > 0

return fml


Expand Down

0 comments on commit a2515df

Please sign in to comment.