Open dweindl opened 3 years ago
When addressing that, enable -Werror for model builds. This will show additional errors, e.g. model entities named NULL
colliding with other C++ entities. We might want to just prefix/suffix all model identifiers in order to avoid long lists of potentially problematic names. Any C++ type, keyword, function or variable name, preprocessor macro name, ... used in (the files included by) the model files is problematic.
Having a compartment with ID x
results in:
de_export.py:1034, in DEModel.import_from_sbml_importer.<locals>.transform_dxdt_to_concentration(species_id, dxdt)
1028 raise SBMLException(
1029 f"Species {species_id} is in a compartment {comp} that is"
1030 f" defined by an algebraic equation. This is not"
1031 f" supported."
1032 )
1033 else:
-> 1034 v = si.compartments[comp]
1036 if v == 1.0:
1037 return dxdt
KeyError: x
Some occurrences of x
are correctly replaced by amici_x
, others are not.
Ideally, this masking would already happen when we generate those symbols, so we don't have to substitute later.
EDIT: Possible approach:
reserved = {'x': sp.Symbol('_amici_x'), ...}
dict.__getitem__
)sanitize_id = lambda id: return reserved.get(id, id)
reserved
to all sympify(locals=...)
Having a compartment with ID
x
results in:de_export.py:1034, in DEModel.import_from_sbml_importer.<locals>.transform_dxdt_to_concentration(species_id, dxdt) 1028 raise SBMLException( 1029 f"Species {species_id} is in a compartment {comp} that is" 1030 f" defined by an algebraic equation. This is not" 1031 f" supported." 1032 ) 1033 else: -> 1034 v = si.compartments[comp] 1036 if v == 1.0: 1037 return dxdt KeyError: x
Some occurrences of
x
are correctly replaced byamici_x
, others are not.
That‘s bad. This is implemented via ‚_replace_in_all_expressions‘ right. Might lead to other errors that aren‘t as evident.
Ideally, this masking would already happen when we generate those symbols, so we don't have to substitute later.
Yes.
Using a parameter with ID
k
in an SBML model results in compiler errors. Did not yet investigate in detail, but the problem seems to be that_clean_reserved_symbols()
does not replace reserved symbols everywhere:No replacement of reserved symbols here:
Leading to various errors of this type:
Correctly replaced symbol here: