Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When trying to infer units of the added
inferUnits-4.xml
file, libsbml crashes.My change only fixes the crash but does not make libsbml able to infer the units.
The reason why libsbml crashes (or is not able to infer the units) is that the file contains a
function_1
with more than 2 arguments.UnitFormulaFormatter::inferUnitDefinition
then tries to reduce the kinetic law's math node to a binary tree but fails to do that properly because of thefunction_1
call.Maybe a full fix would be to fix
ASTNode::reduceToBinary()
to detect that there is a call to a function of more than 2 params and build a binary tree of the function first.For now, avoiding a crash seems like a quick win.
Note that replacing
<ci> function_1 </ci>
by<time />
in the input file avoids the crash and let libsbml infer units correctly.Motivation and Context
Avoid crashing when infering units.
Types of changes
Checklist:
Testing