From f68e095c9fabf4348d28bc783472db14be83bd26 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 2 Jul 2025 14:12:40 +0200 Subject: [PATCH 1/3] v2: Remove redundant CheckAllObservablesDefined There is already . --- petab/v2/lint.py | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/petab/v2/lint.py b/petab/v2/lint.py index 2558ea3c..57002c0f 100644 --- a/petab/v2/lint.py +++ b/petab/v2/lint.py @@ -39,7 +39,6 @@ "CheckUnusedExperiments", "CheckObservablesDoNotShadowModelEntities", "CheckUnusedConditions", - "CheckAllObservablesDefined", "CheckPriorDistribution", "lint_problem", "default_validation_tasks", @@ -261,8 +260,8 @@ def run(self, problem: Problem) -> ValidationIssue | None: } if undefined_observables := (used_observables - defined_observables): return ValidationError( - f"Observables {undefined_observables} used in " - "measurement table but not defined in observable table." + f"Observable(s) {undefined_observables} are used in the " + "measurement table but are not defined in observable table." ) return None @@ -290,7 +289,7 @@ def run(self, problem: Problem) -> ValidationIssue | None: except KeyError: messages.append( f"Observable {m.observable_id} used in measurement " - f"table is not defined." + f"table is not defined in the observable table." ) continue @@ -443,31 +442,6 @@ def run(self, problem: Problem) -> ValidationIssue | None: return None -class CheckAllObservablesDefined(ValidationTask): - """A task to validate that all observables in the measurement table are - defined in the observable table.""" - - def run(self, problem: Problem) -> ValidationIssue | None: - if problem.measurement_df is None: - return None - - measurement_df = problem.measurement_df - observable_df = problem.observable_df - used_observables = set(measurement_df[OBSERVABLE_ID].values) - defined_observables = ( - set(observable_df.index.values) - if observable_df is not None - else set() - ) - if undefined_observables := (used_observables - defined_observables): - return ValidationError( - f"Observables {undefined_observables} are used in the" - "measurements table but are not defined in observables table." - ) - - return None - - class CheckUniquePrimaryKeys(ValidationTask): """Check that all primary keys are unique.""" @@ -1092,7 +1066,6 @@ def get_placeholders( # CheckVisualizationTable(), # TODO validate mapping table CheckValidParameterInConditionOrParameterTable(), - CheckAllObservablesDefined(), CheckAllParametersPresentInParameterTable(), CheckValidConditionTargets(), CheckPriorDistribution(), From d41a98b60f129c365cc337033adc020f1f3045b3 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 3 Jul 2025 13:35:38 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com> --- petab/v2/lint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/petab/v2/lint.py b/petab/v2/lint.py index 57002c0f..726f0235 100644 --- a/petab/v2/lint.py +++ b/petab/v2/lint.py @@ -261,7 +261,7 @@ def run(self, problem: Problem) -> ValidationIssue | None: if undefined_observables := (used_observables - defined_observables): return ValidationError( f"Observable(s) {undefined_observables} are used in the " - "measurement table but are not defined in observable table." + "measurement table but are not defined in the observable table." ) return None @@ -288,8 +288,8 @@ def run(self, problem: Problem) -> ValidationIssue | None: expected = observable_parameters_count[m.observable_id] except KeyError: messages.append( - f"Observable {m.observable_id} used in measurement " - f"table is not defined in the observable table." + f"Observable {m.observable_id} is used in the measurement " + f"table but is not defined in the observable table." ) continue From f296f073fc07bc468f0627d53d9e2b394df38a75 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 3 Jul 2025 13:44:14 +0200 Subject: [PATCH 3/3] .. --- petab/v2/lint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/petab/v2/lint.py b/petab/v2/lint.py index 726f0235..38b7ff74 100644 --- a/petab/v2/lint.py +++ b/petab/v2/lint.py @@ -261,7 +261,8 @@ def run(self, problem: Problem) -> ValidationIssue | None: if undefined_observables := (used_observables - defined_observables): return ValidationError( f"Observable(s) {undefined_observables} are used in the " - "measurement table but are not defined in the observable table." + "measurement table but are not defined in the observable " + "table." ) return None