Skip to content

Commit 1954d3e

Browse files
authored
petab-import: fix fixed parameter selection with pandas>=3 (#3161)
Fixes a pandas>=3.0 compatibility issue in the PEtab importer which resulted in incorrect selection of fixed parameters.
1 parent 33affbf commit 1954d3e

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

.github/workflows/test_petab_test_suite.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172
git clone https://github.com/PEtab-dev/petab_test_suite \
173173
&& source ./venv/bin/activate \
174174
&& cd petab_test_suite \
175-
&& git checkout 9542847fb99bcbdffc236e2ef45ba90580a210fa \
175+
&& git checkout a1935c4d197c3b72dfaf85b9c28268314f4e6ef2 \
176176
&& pip3 install -e .
177177
178178
# TODO: once there is a PEtab v2 benchmark collection
@@ -186,7 +186,7 @@ jobs:
186186
run: |
187187
source ./venv/bin/activate \
188188
&& python3 -m pip uninstall -y petab \
189-
&& python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@44c8062ce1b87a74a0ba1bd2551de0cdc2a13ff1 \
189+
&& python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@main \
190190
&& python3 -m pip install git+https://github.com/pysb/pysb@master \
191191
&& python3 -m pip install sympy>=1.12.1
192192

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ See also our [versioning policy](https://amici.readthedocs.io/en/latest/versioni
1010

1111
* Fixed an issue that resulted in failure to import the `PetabImporter` if
1212
the jax-dependencies weren't installed.
13-
13+
* Fixed a pandas>=3.0 compatibility issue in the PEtab importer which resulted
14+
in incorrect selection of fixed parameters.
1415

1516
### v1.0.0
1617

python/sdist/amici/importers/petab/v1/_import_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def get_fixed_parameters(
225225
# TODO: could check if the final overriding parameter is estimated
226226
# or not, but for now, we skip the parameter if there is any kind
227227
# of overriding
228-
if condition_df[p].dtype != "O"
228+
if not pd.api.types.is_string_dtype(condition_df[p].dtype)
229229
# p is a parameter
230230
and not petab_problem.model.is_state_variable(p)
231231
)

python/sdist/amici/sim/sundials/petab/v1/_conditions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ def create_edata_for_condition(
351351
# create an ExpData object
352352
edata = ExpData(amici_model)
353353
edata.id = condition[SIMULATION_CONDITION_ID]
354-
if condition.get(PREEQUILIBRATION_CONDITION_ID):
355-
edata.id += "+" + condition.get(PREEQUILIBRATION_CONDITION_ID)
354+
if not pd.isna(preeq_id := condition.get(PREEQUILIBRATION_CONDITION_ID)):
355+
edata.id += f"+{preeq_id}"
356356
##########################################################################
357357
# enable initial parameters reinitialization
358358

@@ -444,7 +444,11 @@ def create_edatas(
444444
if PREEQUILIBRATION_CONDITION_ID in condition:
445445
measurement_index = (
446446
condition.get(SIMULATION_CONDITION_ID),
447-
condition.get(PREEQUILIBRATION_CONDITION_ID) or "",
447+
preeq_id
448+
if not pd.isna(
449+
preeq_id := condition.get(PREEQUILIBRATION_CONDITION_ID)
450+
)
451+
else "",
448452
)
449453
else:
450454
measurement_index = (condition.get(SIMULATION_CONDITION_ID),)

0 commit comments

Comments
 (0)