Skip to content

Commit 4623597

Browse files
committed
more intuitive setChemFormula
1 parent 94f7c02 commit 4623597

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/CBCommon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
Author: Brett G. Olivier
2121
Contact email: [email protected]
22-
Last edit: $Author: bgoli $ ($Id: CBCommon.py 630 2017-11-03 16:06:50Z bgoli $)
22+
Last edit: $Author: bgoli $ ($Id: CBCommon.py 644 2018-03-14 21:40:47Z bgoli $)
2323
2424
"""
2525
## gets rid of "invalid variable name" info
@@ -150,7 +150,6 @@ def checkChemFormula(cf, quiet=False):
150150
print('WARNING: \"{}\" is not a valid chemical formula.'.format(cf))
151151
return False
152152

153-
#print(R2)
154153
cf2 = ''
155154
for l_ in R2:
156155
if l_[0] not in ptElements:
@@ -165,8 +164,9 @@ def checkChemFormula(cf, quiet=False):
165164

166165
if cf != cf2:
167166
if not quiet:
167+
print(R2)
168168
print('INFO: \"{}\" check formula.'.format(cf))
169-
return True
169+
return False
170170
else:
171171
return True
172172

src/CBModel.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
Author: Brett G. Olivier
2121
Contact email: [email protected]
22-
Last edit: $Author: bgoli $ ($Id: CBModel.py 641 2017-12-20 15:00:55Z bgoli $)
22+
Last edit: $Author: bgoli $ ($Id: CBModel.py 644 2018-03-14 21:40:47Z bgoli $)
2323
2424
"""
2525
## gets rid of "invalid variable name" info
@@ -4228,8 +4228,6 @@ def setReagentOf(self, rid):
42284228
42294229
"""
42304230
raise RuntimeError('\nINFO: The static .setReagentOf() method is deprecated, please update your code to use: \".isReagentOf()\"')
4231-
#if rid not in self.reagent_of:
4232-
#self.reagent_of.append(rid)
42334231

42344232
def setChemFormula(self, cf):
42354233
"""
@@ -4238,12 +4236,9 @@ def setChemFormula(self, cf):
42384236
- *cf* a chemical formula e.g. CH3NO2
42394237
42404238
"""
4241-
assert cf == '' or checkChemFormula(cf)
4239+
if cf != '' and not checkChemFormula(cf, quiet=True):
4240+
print('ERROR: invalid chemFormula \"{}\" being set on Species \"{}\"'.format(cf, self.getId()))
42424241
self.chemFormula = cf
4243-
#if checkChemFormula(cf):
4244-
#self.chemFormula = cf
4245-
#else:
4246-
#self.chemFormula = ''
42474242

42484243
def getChemFormula(self):
42494244
"""

0 commit comments

Comments
 (0)