Skip to content

Commit f54c924

Browse files
authored
Merge pull request #1672 from virtualcell/fix-stoch-math-mapping-getprobrate-npe
Fix NPE in StochMathMapping for symbol-less rate expressions
2 parents c5f4f2c + 88b838c commit f54c924

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

vcell-core/src/main/java/cbit/vcell/mapping/StochMathMapping.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ private Expression getProbabilityRate(ReactionStep reactionStep, GeneralKinetics
142142

143143
// collect symbolTableEntries for speciesContexts within netRateExpr and replace with concentration parameter
144144
netRateExpr = new Expression(netRateExpr);
145-
for (String symbol : netRateExpr.getSymbols()) {
145+
// Expression.getSymbols() returns null when the expression has no free symbols
146+
// (e.g. a constant rate, or a rate that only references already-resolved values).
147+
String[] symbols = netRateExpr.getSymbols();
148+
for (int i = 0; symbols != null && i < symbols.length; i++) {
149+
String symbol = symbols[i];
146150
SymbolTableEntry symbolTableEntry = netRateExpr.getSymbolBinding(symbol);
147151
if (symbolTableEntry instanceof Kinetics.KineticsProxyParameter proxyParameter
148152
&& proxyParameter.getTarget() instanceof SpeciesContext sc) {

0 commit comments

Comments
 (0)