diff --git a/petab/v2/lint.py b/petab/v2/lint.py index 489b7d6e..c5cf5eb9 100644 --- a/petab/v2/lint.py +++ b/petab/v2/lint.py @@ -324,7 +324,7 @@ def run(self, problem: Problem) -> ValidationIssue | None: # handle default-experiment used_experiments = set( filter( - lambda x: not isinstance(x, float) or not np.isnan(x), + lambda x: not pd.isna(x), used_experiments, ) ) @@ -839,7 +839,8 @@ def append_overrides(overrides): CheckMeasurementTable(), CheckConditionTable(), CheckExperimentTable(), - CheckValidPetabIdColumn("experiment", EXPERIMENT_ID, ignore_nan=True), + CheckValidPetabIdColumn("measurement", EXPERIMENT_ID, ignore_nan=True), + CheckValidPetabIdColumn("experiment", EXPERIMENT_ID), CheckValidPetabIdColumn("experiment", CONDITION_ID), CheckExperimentConditionsExist(), CheckObservableTable(), diff --git a/petab/v2/petab1to2.py b/petab/v2/petab1to2.py index 350b746f..9ef8da8a 100644 --- a/petab/v2/petab1to2.py +++ b/petab/v2/petab1to2.py @@ -12,8 +12,8 @@ from .. import v1, v2 from ..v1 import Problem as ProblemV1 from ..v1.yaml import get_path_prefix, load_yaml, validate, write_yaml -from ..v2.models import MODEL_TYPE_SBML from ..versions import get_major_version +from .models import MODEL_TYPE_SBML __all__ = ["petab1to2"] @@ -70,7 +70,6 @@ def petab1to2(yaml_config: Path | str, output_dir: Path | str = None): # Update YAML file new_yaml_config = _update_yaml(yaml_config) - # Write new YAML file output_dir = Path(output_dir) output_dir.mkdir(parents=True, exist_ok=True) @@ -179,10 +178,8 @@ def create_experiment_id(sim_cond_id: str, preeq_cond_id: str) -> str: # add pre-eq condition id if not present or convert to string # for simplicity if v1.C.PREEQUILIBRATION_CONDITION_ID in measurement_df.columns: - measurement_df[ - v1.C.PREEQUILIBRATION_CONDITION_ID - ] = measurement_df[v1.C.PREEQUILIBRATION_CONDITION_ID].fillna( - "" + measurement_df.fillna( + {v1.C.PREEQUILIBRATION_CONDITION_ID: ""}, inplace=True ) else: measurement_df[v1.C.PREEQUILIBRATION_CONDITION_ID] = "" @@ -223,6 +220,7 @@ def create_experiment_id(sim_cond_id: str, preeq_cond_id: str) -> str: measurement_df, get_dest_path(measurement_file) ) + # Write new YAML file new_yaml_file = output_dir / Path(yaml_file).name write_yaml(new_yaml_config, new_yaml_file)