aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qolab/tableflow/__init__.py2
-rw-r--r--tests/test_tableflow.py32
2 files changed, 33 insertions, 1 deletions
diff --git a/qolab/tableflow/__init__.py b/qolab/tableflow/__init__.py
index 2a150a8..1466dde 100644
--- a/qolab/tableflow/__init__.py
+++ b/qolab/tableflow/__init__.py
@@ -81,7 +81,7 @@ def reflowTable(tIn, tOut, process_row_func=None, postProcessedColums=None, extr
iOut = ilocRowOrAdd(tOut, rowIn)
rowOutBefore = tOut.iloc[iOut]
- if not (redo or isRedoNeeded(rowOut, postProcessedColums) ):
+ if not (redo or isRedoNeeded(rowOutBefore, postProcessedColums) ):
continue
# processing data describing row
diff --git a/tests/test_tableflow.py b/tests/test_tableflow.py
index fce3449..fd52525 100644
--- a/tests/test_tableflow.py
+++ b/tests/test_tableflow.py
@@ -78,7 +78,39 @@ def test_isRedoNeeded():
def test_reflowTable():
tIn,tOut = tblfl.loadInOutTables(inputFileName='tests/tableflow_test_data/tableIn1.csv', outputFileName='tests/tableflow_test_data/tableOut1pariallyProcessed.csv', comment='#')
tOutRef = tOut.copy()
+ # check for warnings
with pytest.warns(UserWarning):
tblfl.reflowTable(tIn,tOut)
+ with pytest.warns(UserWarning):
+ tblfl.reflowTable(tIn,tOut,postProcessedColums=['dummyName'])
+
+ def frow(row):
+ return row
+ with pytest.warns(UserWarning):
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow)
+
+ # now run reflow
+ def frow(row, extraInfo=None):
+ row['out1'] = row['x']*row['x']
+ return row
+ assert len(tIn) != len(tOut)
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow, postProcessedColums=['out1','out2'])
+ assert len(tIn) == len(tOut)
+ assert (tOut['out1'] == tOut['x']*tOut['x']).all()
+
+ # check that reflow is done
+ tOut.loc[tOut['x']==1, 'out1'] = pd.NA
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow, postProcessedColums=['out1','out2'])
+ assert (tOut['out1'] == tOut['x']*tOut['x']).all()
+
+ # check that reflow is not reprocessed
+ tOut.loc[tOut['x']==1, 'out1'] = 12121 # crazy number
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow, postProcessedColums=['out1','out2'])
+ assert (tOut.loc[tOut['x']==1, 'out1'] == 12121).all() # should not change
+ # now we are forcing redo
+ tOut.loc[tOut['x']==1, 'out1'] = 12121 # crazy number
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow, postProcessedColums=['out1','out2'], redo=True)
+ assert not (tOut.loc[tOut['x']==1, 'out1'] == 12121).all() # must not be the same
+ assert (tOut['out1'] == tOut['x']*tOut['x']).all()