Skip to content
Snippets Groups Projects
Commit 8d2078d2 authored by David Schäfer's avatar David Schäfer
Browse files

[FIX] reduce runtime by ~45% (!) through the removal of builtins.any

parent f454ae07
No related branches found
No related tags found
2 merge requests!271Static expansion of regular expressions,!260Follow-Up Translations
This commit is part of merge request !260. Comments created here will be created in the context of that merge request.
...@@ -221,7 +221,7 @@ class Flags: ...@@ -221,7 +221,7 @@ class Flags:
if colname: if colname:
errm += f"of column {colname} " errm += f"of column {colname} "
if any(history.hist[0] != UNFLAGGED): if (history.hist[0] != UNFLAGGED).any():
raise ValueError(errm + "missing an UNFLAGGED-column at first position") raise ValueError(errm + "missing an UNFLAGGED-column at first position")
# this ensures that the mask does not shadow UNFLAGGED with a NaN. # this ensures that the mask does not shadow UNFLAGGED with a NaN.
......
...@@ -439,7 +439,7 @@ class History: ...@@ -439,7 +439,7 @@ class History:
f"'mask' must be of type pd.DataFrame, but {type(mask).__name__} was given" f"'mask' must be of type pd.DataFrame, but {type(mask).__name__} was given"
) )
if any(mask.dtypes != bool): if (mask.dtypes != bool).any():
raise ValueError("dtype of all columns in 'mask' must be bool") raise ValueError("dtype of all columns in 'mask' must be bool")
if not mask.empty and not mask.iloc[:, -1].all(): if not mask.empty and not mask.iloc[:, -1].all():
...@@ -467,7 +467,7 @@ class History: ...@@ -467,7 +467,7 @@ class History:
f"'hist' must be of type pd.DataFrame, but {type(obj).__name__} was given" f"'hist' must be of type pd.DataFrame, but {type(obj).__name__} was given"
) )
if any(obj.dtypes != float): if (obj.dtypes != float).any():
raise ValueError("dtype of all columns in hist must be float") raise ValueError("dtype of all columns in hist must be float")
if not obj.empty and ( if not obj.empty and (
......
...@@ -243,7 +243,7 @@ def _maskData( ...@@ -243,7 +243,7 @@ def _maskData(
for c in columns: for c in columns:
col_mask = _isflagged(flags[c].to_numpy(), thresh) col_mask = _isflagged(flags[c].to_numpy(), thresh)
if any(col_mask): if col_mask.any():
col_data = data[c].to_numpy(dtype=np.float64) col_data = data[c].to_numpy(dtype=np.float64)
col_data[col_mask] = np.nan col_data[col_mask] = np.nan
...@@ -357,7 +357,7 @@ def _unmaskData(data: dios.DictOfSeries, old_state: CallState) -> dios.DictOfSer ...@@ -357,7 +357,7 @@ def _unmaskData(data: dios.DictOfSeries, old_state: CallState) -> dios.DictOfSer
restore_old_mask = old_state.mask[c].to_numpy() & data[c].isna().to_numpy() restore_old_mask = old_state.mask[c].to_numpy() & data[c].isna().to_numpy()
# we have nothing to restore # we have nothing to restore
if not any(restore_old_mask): if not restore_old_mask.any():
continue continue
# restore old values if no new are present # restore old values if no new are present
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment