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

renamed History.max to History.squeeze

parent 265519e2
No related branches found
No related tags found
6 merge requests!685Release 2.4,!684Release 2.4,!567Release 2.2.1,!566Release 2.2,!501Release 2.1,!469renamed History.max to History.squeeze
Pipeline #95166 passed with stage
in 2 minutes and 21 seconds
......@@ -20,6 +20,7 @@ This changelog starts with version 2.0.0. Basically all parts of the system, inc
- new function `progagateFlags`
### Changed
- renamed `History.max` to renamed `History.squeeze`
- documentation pipeline changed to base on methods decorators
- `flagOffsets` parameters `thresh` and `thresh_relative` now both are optional
- flags concatenation tasks (for squeezed and explicit histories) are now all channeled through the function `concatFlags`
......
......@@ -248,7 +248,7 @@ class Flags:
errm += f"of column {colname} "
# this ensures that the mask does not shadow UNFLAGGED with a NaN.
if history.max().hasnans:
if history.squeeze().hasnans:
raise ValueError(errm + "is not valid (result of max() contains NaNs)")
return history
......@@ -320,7 +320,7 @@ class Flags:
# item access
def __getitem__(self, key: str) -> pd.Series:
return self._data[key].max()
return self._data[key].squeeze()
def __setitem__(self, key: SelectT, value: ValueT):
# force-KW is only internally available
......
......@@ -208,7 +208,7 @@ class History:
self.meta += value_meta
return self
def max(self, raw=False) -> pd.Series:
def squeeze(self, raw=False) -> pd.Series:
"""
Get the maximum value per row of the FH.
......
......@@ -273,7 +273,7 @@ class FunctionWrapper:
start = len(old_history.columns)
new_history = self._sliceHistory(new_history, slice(start, None))
squeezed = new_history.max(raw=True)
squeezed = new_history.squeeze(raw=True)
out.history[col] = out.history[col].append(squeezed, meta=meta)
return out
......
......@@ -558,7 +558,7 @@ def concatFlags(
history = flags.history[field].apply(dummy.index, func, func_kws)
if squeeze:
history = history.max(raw=True)
history = history.squeeze(raw=True)
meta = {
"func": f"concatFlags({field})",
......
......@@ -163,7 +163,7 @@ def test_get_flags(data: Union[pd.DataFrame, dios.DictOfSeries, Dict[str, pd.Ser
var = flags[c]
assert isinstance(var, pd.Series)
assert not var.empty
assert var.equals(flags._data[c].max())
assert var.equals(flags._data[c].squeeze())
# always a copy
assert var is not flags[c]
......@@ -184,22 +184,22 @@ def test_set_flags(data: Union[pd.DataFrame, dios.DictOfSeries, Dict[str, pd.Ser
flags[c] = new
assert len(flags.history[c]) == hlen + 1
assert all(flags.history[c].max() == 9999.0)
assert all(flags.history[c].max() == flags[c])
assert all(flags.history[c].squeeze() == 9999.0)
assert all(flags.history[c].squeeze() == flags[c])
# check if deep-copied correctly
new[:] = 8888.0
assert all(flags.history[c].max() == 9999.0)
assert all(flags.history[c].squeeze() == 9999.0)
# flags always overwrite former
flags[c] = new
assert len(flags.history[c]) == hlen + 2
assert all(flags.history[c].max() == 8888.0)
assert all(flags.history[c].max() == flags[c])
assert all(flags.history[c].squeeze() == 8888.0)
assert all(flags.history[c].squeeze() == flags[c])
# check if deep-copied correctly
new[:] = 7777.0
assert all(flags.history[c].max() == 8888.0)
assert all(flags.history[c].squeeze() == 8888.0)
@pytest.mark.parametrize("data", testdata)
......
......@@ -84,7 +84,7 @@ def check_invariants(hist):
# advanced
assert hist.columns.equals(pd.Index(range(len(hist))))
assert isinstance(hist.max(), pd.Series)
assert isinstance(hist.squeeze(), pd.Series)
def is_equal(hist1: History, hist2: History):
......@@ -235,4 +235,4 @@ def test_append_force(__hist, s, max_val):
hist = __hist
hist.append(s)
check_invariants(hist)
assert all(hist.max() == max_val)
assert all(hist.squeeze() == max_val)
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