Skip to content
Snippets Groups Projects

Follow-Up Translations

Merged David Schäfer requested to merge translations into develop
1 file
+ 21
13
Compare changes
  • Side-by-side
  • Inline
+ 21
13
@@ -78,7 +78,7 @@ class History:
hist = hist.copy()
mask = mask.copy()
self.hist = hist
self.hist = hist.astype("category")
self.mask = mask
@property
@@ -166,7 +166,7 @@ class History:
touched = s.notna()
self.mask.iloc[touched, :pos] = False
self.hist[pos] = s
self.hist[pos] = s.astype("category")
return self
@@ -269,7 +269,7 @@ class History:
# clear the current mask
self.mask.loc[(~value_mask & value_hist.notna()).any(axis="columns")] = False
self.hist.loc[:, columns] = value_hist.copy()
self.hist.loc[:, columns] = value_hist.astype("category")
self.mask.loc[:, columns] = value_mask.copy()
return self
@@ -316,7 +316,7 @@ class History:
# the last column maybe is not entirely True, but
# the following append, will fix this
self.hist = self.hist.iloc[:, :-n]
self.mask = self.mask.iloc[:, :-n]
self.mask = self.mask.iloc[:, :-n].astype("category")
self.append(s)
return self
@@ -383,10 +383,14 @@ class History:
-------
History
"""
self.hist = self.hist.reindex(index=index, copy=False, fill_value=np.nan)
self.hist = self.hist.reindex(
index=index, copy=False, fill_value=np.nan
).astype("category")
self.mask = self.mask.reindex(index=index, copy=False, fill_value=False)
# Note: all following code must handle empty frames
self.hist.iloc[:, -1:] = self.hist.iloc[:, -1:].fillna(fill_value_last)
self.hist.iloc[:, -1:] = (
self.hist.iloc[:, -1:].fillna(fill_value_last).astype("category")
)
self.mask.iloc[:, -1:] = True
return self
@@ -467,8 +471,8 @@ class History:
f"'hist' must be of type pd.DataFrame, but {type(obj).__name__} was given"
)
if (obj.dtypes != float).any():
raise ValueError("dtype of all columns in hist must be float")
# if (obj.dtypes != float).any():
# raise ValueError("dtype of all columns in hist must be float")
if not obj.empty and (
not obj.columns.equals(pd.Index(range(len(obj.columns))))
@@ -490,8 +494,8 @@ class History:
f"value must be of type pd.Series, but {type(obj).__name__} was given"
)
if not obj.dtype == float:
raise ValueError("dtype must be float")
# if not obj.dtype == float:
# raise ValueError("dtype must be float")
return obj
@@ -545,12 +549,16 @@ def applyFunctionOnHistory(
new_history = History()
if func_handle_df:
history.hist = hist_func(history.hist, **hist_kws)
history.hist = hist_func(history.hist.astype(float), **hist_kws).astype(
"category"
)
history.mask = hist_func(history.mask, **mask_kws)
else:
for pos in history.columns:
new_history.hist[pos] = hist_func(history.hist[pos], **hist_kws)
new_history.hist[pos] = hist_func(
history.hist[pos].astype(float), **hist_kws
).astype("category")
new_history.mask[pos] = mask_func(history.mask[pos], **mask_kws)
# handle unstable state
@@ -560,7 +568,7 @@ def applyFunctionOnHistory(
if isinstance(last_column, str) and last_column == "dummy":
last_column = pd.Series(UNTOUCHED, index=new_history.index, dtype=float)
new_history.append(last_column, force=True)
new_history.append(last_column.astype("category"), force=True)
# assure a boolean mask and UNFLAGGED column
new_history.mask = new_history.mask.fillna(True).astype(bool)
Loading