Skip to content

Commit 6053934

Browse files
committed
fixup
1 parent c69c503 commit 6053934

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

petab/v2/lint.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def run(self, problem: Problem) -> ValidationIssue | None:
324324
# handle default-experiment
325325
used_experiments = set(
326326
filter(
327-
lambda x: not isinstance(x, float) or not np.isnan(x),
327+
lambda x: not pd.isna(x),
328328
used_experiments,
329329
)
330330
)
@@ -839,7 +839,8 @@ def append_overrides(overrides):
839839
CheckMeasurementTable(),
840840
CheckConditionTable(),
841841
CheckExperimentTable(),
842-
CheckValidPetabIdColumn("experiment", EXPERIMENT_ID, ignore_nan=True),
842+
CheckValidPetabIdColumn("measurement", EXPERIMENT_ID, ignore_nan=True),
843+
CheckValidPetabIdColumn("experiment", EXPERIMENT_ID),
843844
CheckValidPetabIdColumn("experiment", CONDITION_ID),
844845
CheckExperimentConditionsExist(),
845846
CheckObservableTable(),

petab/v2/petab1to2.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from .. import v1, v2
1313
from ..v1 import Problem as ProblemV1
1414
from ..v1.yaml import get_path_prefix, load_yaml, validate, write_yaml
15-
from ..v2.models import MODEL_TYPE_SBML
1615
from ..versions import get_major_version
16+
from .models import MODEL_TYPE_SBML
1717

1818
__all__ = ["petab1to2"]
1919

@@ -67,13 +67,11 @@ def petab1to2(yaml_config: Path | str, output_dir: Path | str = None):
6767
if v1.lint_problem(petab_problem):
6868
raise ValueError("Provided PEtab problem does not pass linting.")
6969

70+
output_dir = Path(output_dir)
71+
7072
# Update YAML file
7173
new_yaml_config = _update_yaml(yaml_config)
7274

73-
# Write new YAML file
74-
output_dir = Path(output_dir)
75-
output_dir.mkdir(parents=True, exist_ok=True)
76-
7775
# Update tables
7876
# condition tables, observable tables, SBML files, parameter table:
7977
# no changes - just copy
@@ -179,10 +177,8 @@ def create_experiment_id(sim_cond_id: str, preeq_cond_id: str) -> str:
179177
# add pre-eq condition id if not present or convert to string
180178
# for simplicity
181179
if v1.C.PREEQUILIBRATION_CONDITION_ID in measurement_df.columns:
182-
measurement_df[
183-
v1.C.PREEQUILIBRATION_CONDITION_ID
184-
] = measurement_df[v1.C.PREEQUILIBRATION_CONDITION_ID].fillna(
185-
""
180+
measurement_df.fillna(
181+
{v1.C.PREEQUILIBRATION_CONDITION_ID: ""}, inplace=True
186182
)
187183
else:
188184
measurement_df[v1.C.PREEQUILIBRATION_CONDITION_ID] = ""
@@ -223,6 +219,7 @@ def create_experiment_id(sim_cond_id: str, preeq_cond_id: str) -> str:
223219
measurement_df, get_dest_path(measurement_file)
224220
)
225221

222+
# Write new YAML file
226223
new_yaml_file = output_dir / Path(yaml_file).name
227224
write_yaml(new_yaml_config, new_yaml_file)
228225

0 commit comments

Comments
 (0)