Skip to content

Commit

Permalink
catch ALL unit exceptions while adding probability parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Sep 24, 2024
1 parent e35b244 commit cd5a773
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1726,8 +1726,7 @@ protected final SpeciesCountParameter addSpeciesCountParameter(String name, Expr
* @return cbit.vcell.mapping.MathMappingParameter
*/
final ProbabilityParameter addProbabilityParameter(String name, Expression expression, int role,
VCUnitDefinition unitDefinition, ModelProcess argModelProcess) throws java.beans.PropertyVetoException,
VCUnitException {
VCUnitDefinition unitDefinition, ModelProcess argModelProcess) throws java.beans.PropertyVetoException {

GeometryClass geometryClass = null;
if (argModelProcess.getStructure() != null){
Expand All @@ -1741,7 +1740,7 @@ final ProbabilityParameter addProbabilityParameter(String name, Expression expre
logger.warn("expected unit=" + unitDefinition.getSymbol() + ", found=" + expUnit.getSymbol());
// throw new VCUnitException("expected unit=" + unitDefinition.getSymbol() + ", found=" + expUnit.getSymbol());
}
} catch (ExpressionException e){
} catch (VCUnitException | ExpressionException e){
logger.warn("error evaluating units for expression '" + expression + ": " + e.getMessage(), e);
// throw new VCUnitException("error evaluating units for expression '" + expression + ": " + e.getMessage());
}
Expand Down
13 changes: 6 additions & 7 deletions vcell-math/src/main/java/cbit/vcell/units/VCUnitDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@

package cbit.vcell.units;

import java.io.Serializable;
import java.util.HashMap;

import org.vcell.util.Matchable;

import cbit.vcell.matrix.RationalExp;
import cbit.vcell.matrix.RationalNumber;
import cbit.vcell.parser.ExpressionException;
import cbit.vcell.parser.ExpressionUtils;
import cbit.vcell.parser.RationalExpUtils;
import cbit.vcell.units.parser.UnitSymbol;
import org.vcell.util.Matchable;

import java.io.Serializable;
import java.util.HashMap;

public class VCUnitDefinition implements Matchable, Serializable{

Expand Down Expand Up @@ -137,7 +136,7 @@ public VCUnitDefinition raiseTo(ucar.units_vcell.RationalNumber rationalNumber)
powerMap.put(rationalNumber, powerUnit);
return powerUnit;
}else{
throw new RuntimeException("raiseTo( non-integer ) not longer supported - even when solving for unknown units");
throw new VCUnitException("raiseTo( non-integer ) not longer supported - even when solving for unknown units");
}
}

Expand Down Expand Up @@ -215,7 +214,7 @@ public RationalNumber getDimensionlessScale() {
// so have to explicitly look for such cases.
//
final VCUnitDefinition molecules_per_uM_um3 = fieldVCUnitSystem.getInstance("molecules.uM-1.um-3");
final RationalNumber value_molecules_per_uM_um3 = new RationalNumber(new Double(ExpressionUtils.value_molecules_per_uM_um3_NUMERATOR).longValue(),1000000);
final RationalNumber value_molecules_per_uM_um3 = new RationalNumber(Double.valueOf(ExpressionUtils.value_molecules_per_uM_um3_NUMERATOR).longValue(),1000000);

//
// multiply and multiply by powers of KMOLE
Expand Down

0 comments on commit cd5a773

Please sign in to comment.