Skip to content

v1 lint: invalid estimate or bounds values crash lint_problem #641

Backlog

Description

@dweindl

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_boolean calls int(estimate), which raises ValueError for, e.g., estimate="abc" or an empty cell (NaN).
  • assert_parameter_bounds_are_numeric calls .apply(float) without catching the ValueError, e.g., for lowerBound="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.

Relates to #639, #640.

🤖 This issue was drafted with AI assistance (Claude Code); the section on string estimate values was generated with AI assistance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions