|
42 | 42 | "CheckObservablesDoNotShadowModelEntities", |
43 | 43 | "CheckUnusedConditions", |
44 | 44 | "CheckPriorDistribution", |
| 45 | + "CheckUndefinedExperiments", |
45 | 46 | "lint_problem", |
46 | 47 | "default_validation_tasks", |
47 | 48 | ] |
@@ -691,6 +692,28 @@ def run(self, problem: Problem) -> ValidationIssue | None: |
691 | 692 | return None |
692 | 693 |
|
693 | 694 |
|
| 695 | +class CheckUndefinedExperiments(ValidationTask): |
| 696 | + """A task to check for experiments that are used in the measurement |
| 697 | + table but not defined in the experiment table.""" |
| 698 | + |
| 699 | + def run(self, problem: Problem) -> ValidationIssue | None: |
| 700 | + used_experiments = { |
| 701 | + m.experiment_id |
| 702 | + for m in problem.measurements |
| 703 | + if m.experiment_id is not None |
| 704 | + } |
| 705 | + available_experiments = {e.id for e in problem.experiments} |
| 706 | + |
| 707 | + if undefined_experiments := used_experiments - available_experiments: |
| 708 | + return ValidationWarning( |
| 709 | + f"Experiments {undefined_experiments} are used in the " |
| 710 | + "measurements table but are not defined in the experiments " |
| 711 | + "table." |
| 712 | + ) |
| 713 | + |
| 714 | + return None |
| 715 | + |
| 716 | + |
694 | 717 | class CheckUnusedConditions(ValidationTask): |
695 | 718 | """A task to check for conditions that are not used in the experiment |
696 | 719 | table.""" |
@@ -1053,6 +1076,7 @@ def get_placeholders( |
1053 | 1076 | CheckValidConditionTargets(), |
1054 | 1077 | CheckExperimentTable(), |
1055 | 1078 | CheckExperimentConditionsExist(), |
| 1079 | + CheckUndefinedExperiments(), |
1056 | 1080 | CheckObservablesDoNotShadowModelEntities(), |
1057 | 1081 | CheckAllParametersPresentInParameterTable(), |
1058 | 1082 | CheckValidParameterInConditionOrParameterTable(), |
|
0 commit comments