Repository navigation
Description
lint_problem only catches AssertionError from check_parameter_df, but some of the parameter table checks raise ValueError for invalid values, so lint_problem (and petablint) crashes instead of reporting the problem:
assert_parameter_estimate_is_booleancallsint(estimate), which raisesValueErrorfor, e.g.,estimate="abc"or an empty cell (NaN).assert_parameter_bounds_are_numericcalls.apply(float)without catching theValueError, e.g., forlowerBound="abc".
import pandas as pd
from petab.v1 import lint
from petab.v1.C import *
df = pd.DataFrame(
{
PARAMETER_SCALE: [LIN],
LOWER_BOUND: [0.1],
UPPER_BOUND: [10.0],
NOMINAL_VALUE: [1.0],
ESTIMATE: ["abc"],
},
index=pd.Index(["k"], name=PARAMETER_ID),
)
lint.check_parameter_df(df)
# ValueError: invalid literal for int() with base 10: 'abc'Also, assert_parameter_estimate_is_boolean accepts non-integer values such as estimate=0.5, since int() truncates.
Expected: these functions raise AssertionError naming the affected parameters, so that lint_problem reports them.
A related silent failure: estimate values given as strings (e.g., a parameter table built in memory) pass lint, but the rest of petab.v1 compares estimate numerically, so "1" is treated as not estimated and "0" as not fixed:
df = pd.DataFrame(
{
PARAMETER_SCALE: [LIN, LIN],
LOWER_BOUND: [0.1, 0.1],
UPPER_BOUND: [10.0, 10.0],
NOMINAL_VALUE: [1.0, 2.0],
ESTIMATE: ["1", "0"],
},
index=pd.Index(["k_est", "k_fixed"], name=PARAMETER_ID),
)
lint.check_parameter_df(df) # passes
parameters.get_optimization_parameters(df) # []Tables read from file are not affected, since estimate is parsed as numeric there. Expected: lint rejects non-numeric estimate values, or the library interprets them consistently. All code that decides whether a parameter is estimated, including the selection of non-estimated parameters in check_parameter_df, should use the same interpretation.
🤖 This issue was drafted with AI assistance (Claude Code); the section on string estimate values was generated with AI assistance.
Activity