[ck2cti] Allow stoichiometric coefficients ending in decimal points
Cherry-pick of trunk r2936.
This commit is contained in:
parent
b4779c4310
commit
d787349771
1 changed files with 9 additions and 8 deletions
|
|
@ -39,9 +39,6 @@ import numpy as np
|
|||
import re
|
||||
import itertools
|
||||
|
||||
reFloat = re.compile(r'\+?\d*\.?\d+([eEdD][-+]?\d+)?$')
|
||||
reInt = re.compile(r'\+?\d+$')
|
||||
|
||||
QUANTITY_UNITS = {'MOL': 'mol',
|
||||
'MOLE': 'mol',
|
||||
'MOLES': 'mol',
|
||||
|
|
@ -1077,12 +1074,16 @@ class Parser(object):
|
|||
j = reaction.find(token)
|
||||
i = len(token)
|
||||
reaction = reaction[:j] + ' '*i + reaction[j+i:]
|
||||
if reInt.match(token):
|
||||
if token == '+':
|
||||
continue
|
||||
|
||||
try:
|
||||
locs[j] = int(token), 'coeff'
|
||||
elif reFloat.match(token):
|
||||
locs[j] = float(token), 'coeff'
|
||||
elif token != '+':
|
||||
raise InputParseError('Unexpected token "{0}" in reaction expression "{1}".'.format(token, reaction))
|
||||
except ValueError:
|
||||
try:
|
||||
locs[j] = float(token), 'coeff'
|
||||
except ValueError:
|
||||
raise InputParseError('Unexpected token "{0}" in reaction expression "{1}".'.format(token, reaction))
|
||||
|
||||
reactants = []
|
||||
products = []
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue