@@ -96,7 +96,7 @@ def _get_formula_parser():
9696 | '{' formula '}'
9797 | '[' formula ']' ) count prime charge?
9898 formula :: term+
99- hydrate :: ( '.' | '\u00B7 ' | '* ' ) count? formula
99+ hydrate :: ( '.. ' | '\u00B7 ' | '. ' ) count? formula
100100 state :: '(' ( 's' | 'l' | 'g' | 'aq' | 'cr' ) ')'
101101 compound :: count formula hydrate? state?
102102
@@ -115,7 +115,7 @@ def _get_formula_parser():
115115 | '{' formula '}'
116116 | '[' formula ']' ) count prime charge?
117117 formula :: term+
118- hydrate :: ( '..' | '\u00B7 ' | '* ' ) count? formula
118+ hydrate :: ( '..' | '\u00B7 ' | '. ' ) count? formula
119119 state :: '(' ( 's' | 'l' | 'g' | 'aq' | 'cr' ) ')'
120120 compound :: count formula hydrate? state?
121121 """
@@ -378,7 +378,7 @@ def formula_to_composition(
378378 True
379379 >>> formula_to_composition('.NHO-(aq)') == {0: -1, 1: 1, 7: 1, 8: 1}
380380 True
381- >>> formula_to_composition('Na2CO3* 7H2O') == {11: 2, 6: 1, 8: 10, 1: 14}
381+ >>> formula_to_composition('Na2CO3.. 7H2O') == {11: 2, 6: 1, 8: 10, 1: 14}
382382 True
383383
384384 """
@@ -387,10 +387,10 @@ def formula_to_composition(
387387
388388 stoich_tok , chg_tok = _formula_to_parts (formula , prefixes , suffixes )[:2 ]
389389 tot_comp = {}
390- if ".." in stoich_tok :
391- parts = stoich_tok .split (".." )
392- elif "\u00b7 " in stoich_tok :
390+ if "\u00b7 " in stoich_tok :
393391 parts = stoich_tok .split ('\u00b7 ' )
392+ elif '..' in stoich_tok :
393+ parts = stoich_tok .split (".." )
394394 elif '.' in stoich_tok :
395395 warnings .warn (
396396 ("dot is ambiguous in chempy-0.8.x, prefer '*' or '\u00b7 ' for complexes."
@@ -399,7 +399,7 @@ def formula_to_composition(
399399 )
400400 parts = stoich_tok .split ('.' )
401401 else :
402- parts = list ( filter ( len , internal_asterisk . split ( stoich_tok )))
402+ parts = [ stoich_tok ]
403403
404404 for idx , stoich in enumerate (parts ):
405405 if idx == 0 :
@@ -536,9 +536,6 @@ def to_reaction(line, substance_keys, token, Cls, globals_=None, **kwargs):
536536 )
537537
538538
539- internal_asterisk = re .compile (r"([^\s\*]+)\*([a-zA-Z0-9]+)" )
540-
541-
542539def _formula_to_format (
543540 sub ,
544541 sup ,
@@ -549,7 +546,6 @@ def _formula_to_format(
549546):
550547 parts = _formula_to_parts (formula , prefixes .keys (), suffixes )
551548 parts0 = parts [0 ].replace (".." , "\u00B7 " )
552- parts0 = internal_asterisk .sub ("\u00B7 " , parts0 )
553549 if '.' in parts0 :
554550 warnings .warn (
555551 ("dot is ambiguous in chempy-0.8.x, prefer '*' or '' for complexes."
0 commit comments