Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pandas 2.1.0 FutureWarnings #226

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[flake8]

extend-ignore =
# whitespace before ":", conflicts with black
E203
F403
F405
# line too long, conflicts with black in rare cases
E501
exclude =
build,
dist,
Expand Down
2 changes: 1 addition & 1 deletion petab/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def calculate_residuals_for_table(
# create residual df as copy of measurement df, change column
residual_df = measurement_df.copy(deep=True).rename(
columns={MEASUREMENT: RESIDUAL})

residual_df[RESIDUAL] = residual_df[RESIDUAL].astype("float64")
# matching columns
compared_cols = set(MEASUREMENT_DF_COLS)
compared_cols -= {MEASUREMENT}
Expand Down
4 changes: 2 additions & 2 deletions petab/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ def condition_parameters_to_parameter_table(problem: Problem):
continue

series = problem.condition_df[parameter_id]
value = petab.to_float_if_float(series[0])
value = petab.to_float_if_float(series.iloc[0])

# same value for all conditions and no parametric overrides (str)?
if isinstance(value, float) and len(series.unique()) == 1:
replacements[parameter_id] = series[0]
replacements[parameter_id] = series.iloc[0]

if not replacements:
return
Expand Down
2 changes: 2 additions & 0 deletions petab/visualize/data_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def get_data_per_observable(measurement_df: pd.DataFrame) -> pd.DataFrame:
"""

my_measurements = measurement_df.copy()
my_measurements[PREEQUILIBRATION_CONDITION_ID] = my_measurements[PREEQUILIBRATION_CONDITION_ID].astype("object")

index = [SIMULATION_CONDITION_ID]
if PREEQUILIBRATION_CONDITION_ID in my_measurements:
my_measurements[PREEQUILIBRATION_CONDITION_ID].fillna('', inplace=True)
Expand Down
2 changes: 2 additions & 0 deletions petab/visualize/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def set_default(column: str, value):
if column not in vis_df:
vis_df[column] = value
elif value is not None:
if isinstance(value, str):
vis_df[column] = vis_df[column].astype('object')
vis_df[column].fillna(value, inplace=True)

set_default(C.PLOT_NAME, "")
Expand Down
1 change: 1 addition & 0 deletions tests/test_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_get_parametric_overrides():

assert conditions.get_parametric_overrides(condition_df) == []

condition_df['fixedParameter1'] = condition_df['fixedParameter1'].astype("object")
condition_df.loc[0, 'fixedParameter1'] = 'parameterId'

assert conditions.get_parametric_overrides(condition_df) == ['parameterId']
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def test_check_parameter_df():
LOWER_BOUND: [1e-5, 1e-6, 1e-7],
UPPER_BOUND: [1e5, 1e6, 1e7]
}).set_index(PARAMETER_ID)

parameter_df[NOMINAL_VALUE] = parameter_df[NOMINAL_VALUE].astype("object")
lint.check_parameter_df(df=parameter_df)

# NOMINAL_VALUE empty, for non-estimated parameter
Expand Down
1 change: 1 addition & 0 deletions tests/test_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def condition_df_2_conditions():
'fixedParameter1': [1.0, 2.0]
})
condition_df.set_index('conditionId', inplace=True)
condition_df.fixedParameter1 = condition_df.fixedParameter1.astype("object")
return condition_df


Expand Down