Skip to content

Commit 6cd2ccb

Browse files
committed
Fix TypeError in JAXProblem._get_measurements
Use pandas 2.x & 3.x compatible check for string dtypes. Fixes #3120.
1 parent ab5f225 commit 6cd2ccb

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

python/sdist/amici/jax/petab.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,9 @@ def _get_measurements(
286286
for col in [petab.OBSERVABLE_PARAMETERS, petab.NOISE_PARAMETERS]:
287287
n_pars[col] = 0
288288
if col in self._petab_problem.measurement_df:
289-
if np.issubdtype(
290-
self._petab_problem.measurement_df[col].dtype, np.number
289+
if pd.api.types.is_string_dtype(
290+
self._petab_problem.measurement_df[col].dtype
291291
):
292-
n_pars[col] = 1 - int(
293-
self._petab_problem.measurement_df[col].isna().all()
294-
)
295-
else:
296292
n_pars[col] = (
297293
self._petab_problem.measurement_df[col]
298294
.str.split(petab.C.PARAMETER_SEPARATOR)
@@ -303,6 +299,10 @@ def _get_measurements(
303299
)
304300
.max()
305301
)
302+
else:
303+
n_pars[col] = 1 - int(
304+
self._petab_problem.measurement_df[col].isna().all()
305+
)
306306

307307
for _, simulation_condition in simulation_conditions.iterrows():
308308
query = " & ".join(

0 commit comments

Comments
 (0)