Skip to content
Open
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
2 changes: 1 addition & 1 deletion petab/v1/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_parametric_overrides(condition_df: pd.DataFrame) -> list[str]:
result = []

for column in constant_parameters:
if np.issubdtype(condition_df[column].dtype, np.number):
if not pd.api.types.is_string_dtype(condition_df[column].dtype):
continue

floatified = condition_df.loc[:, column].apply(core.to_float_if_float)
Expand Down
16 changes: 8 additions & 8 deletions petab/v1/lint.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All edits in this file are in repeated code but fine as is

Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def check_condition_df(
)

for column_name in req_cols:
if not np.issubdtype(df[column_name].dtype, np.number):
if pd.api.types.is_string_dtype(df[column_name].dtype):
assert_no_leading_trailing_whitespace(
df[column_name].values, column_name
)
Expand Down Expand Up @@ -173,14 +173,14 @@ def check_measurement_df(
_check_df(df, MEASUREMENT_DF_REQUIRED_COLS, "measurement")

for column_name in MEASUREMENT_DF_REQUIRED_COLS:
if not np.issubdtype(df[column_name].dtype, np.number):
if pd.api.types.is_string_dtype(df[column_name].dtype):
assert_no_leading_trailing_whitespace(
df[column_name].values, column_name
)

for column_name in MEASUREMENT_DF_OPTIONAL_COLS:
if column_name in df and not np.issubdtype(
df[column_name].dtype, np.number
if column_name in df and pd.api.types.is_string_dtype(
df[column_name].dtype
):
assert_no_leading_trailing_whitespace(
df[column_name].values, column_name
Expand Down Expand Up @@ -243,7 +243,7 @@ def check_parameter_df(
check_ids(df.index.values, kind="parameter")

for column_name in PARAMETER_DF_REQUIRED_COLS[1:]: # 0 is PARAMETER_ID
if not np.issubdtype(df[column_name].dtype, np.number):
if pd.api.types.is_string_dtype(df[column_name].dtype):
assert_no_leading_trailing_whitespace(
df[column_name].values, column_name
)
Expand Down Expand Up @@ -304,14 +304,14 @@ def check_observable_df(observable_df: pd.DataFrame) -> None:
check_ids(observable_df.index.values, kind="observable")

for column_name in OBSERVABLE_DF_REQUIRED_COLS[1:]:
if not np.issubdtype(observable_df[column_name].dtype, np.number):
if pd.api.types.is_string_dtype(observable_df[column_name].dtype):
assert_no_leading_trailing_whitespace(
observable_df[column_name].values, column_name
)

for column_name in OBSERVABLE_DF_OPTIONAL_COLS:
if column_name in observable_df and not np.issubdtype(
observable_df[column_name].dtype, np.number
if column_name in observable_df and pd.api.types.is_string_dtype(
observable_df[column_name].dtype
):
assert_no_leading_trailing_whitespace(
observable_df[column_name].values, column_name
Expand Down
2 changes: 1 addition & 1 deletion petab/v1/visualize/data_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_data_per_observable(measurement_df: pd.DataFrame) -> pd.DataFrame:
my_measurements[PREEQUILIBRATION_CONDITION_ID] = (
my_measurements[PREEQUILIBRATION_CONDITION_ID]
.astype("object")
.fillna("", inplace=True)
.fillna("")
)
index.append(PREEQUILIBRATION_CONDITION_ID)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description = "Parameter estimation tabular data"
requires-python = ">=3.11"
dependencies = [
"numpy>=1.15.1",
"pandas>=1.2.0,<3",
"pandas>=1.2.0",
"python-libsbml>=5.17.0",
"sympy",
"colorama",
Expand Down
2 changes: 1 addition & 1 deletion tests/v1/test_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def test_flatten_timepoint_specific_output_overrides():
)

pd.testing.assert_frame_equal(
problem.observable_df, observable_df_expected
problem.observable_df, observable_df_expected, check_dtype=False
)
Comment on lines 510 to 512
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why False? Could add a brief comment.

pd.testing.assert_frame_equal(
problem.measurement_df, measurement_df_expected
Expand Down