Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Géry Casiez committed May 15, 2024
1 parent c2c8303 commit 52c4adb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ all: testcplusplus testTypescript

# C++ version original
testcplusplus:
cd cpp ; make Makefilecpp
cd cpp ; make -f Makefilecpp

# Typescript
testTypescript:
Expand Down
24 changes: 15 additions & 9 deletions cpp/Makefilecpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
all: testcplusplus
PYTHON = python3

PYTHON=python3
all: liblag compilemain testcplusplus

main: main
qmake6 ; make \
compilemain:
echo "Compiling main.cpp" ; \
qmake6 ; \
make

liblag: lag/liblag.a
cd lag ; qmake6 ; make
liblag:
echo "Compiling liblag" ; \
cd lag ; \
qmake6 ; \
make

testcplusplus: liblag main
./main
$(PYTHON) ../test.py cpp strokesPredicted.csv
testcplusplus:
echo "Running test" ; \
./main ; \
$(PYTHON) ../test.py cpp strokesPredicted.csv
8 changes: 7 additions & 1 deletion cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ int main(int argc, char* argv[]){
getline (file, value, ',' );
double y = stod(value);
getline (file, value, '\n' );
string s = value.substr(0,value.length()-1);

string s;
if (file.good())
s = value.substr(0,value.length()-1);
else
s = value;

InputEvent e = predict(ts, x, y, s);
fileO << ts << "," << x << "," << y << "," << s << "," << e.x << "," << e.y << endl;
//cout << "{ts:" << ts << ", x:" << x << ", y:" << y << ", s: \"" << s << "\", xp:" << e.x << ", yp:" << e.y << "}, ";
Expand Down
2 changes: 1 addition & 1 deletion strokesPredicted64GroundTruth.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1039,4 +1039,4 @@ When,X,Y,Typestate,predX,predY
1112882187898041,485,422,MOVE,460.154,429.275
1112882195804981,484,423,MOVE,463.876,428.51
1112882203041186,484,424,MOVE,470.559,431.199
1112882222107313,484,424,U,480.038,429.278
1112882222107313,484,424,UP,484,424.559
6 changes: 3 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
sys.exit()

for (index, row), (index2, row2) in zip(df.iterrows(), df2.iterrows()):
if math.fabs(row['When'] - row2['When']) > 0.0001:
if math.fabs(row['When'] - row2['When']) > 0.01:
print("line %s: timestamps are different : %s != %s"%(index+2, row['timestamp'], row2['timestamp']), file=sys.stderr)
problem = True
break
if math.fabs(row['predX'] - row2['predX']) > 0.0001:
if math.fabs(row['predX'] - row2['predX']) > 0.01:
print("line %s: predX data is different: %s != %s"%(index+2, row['predX'], row2['predX']), file=sys.stderr)
problem = True
break
if math.fabs(row['predY'] - row2['predY']) > 0.0001:
if math.fabs(row['predY'] - row2['predY']) > 0.01:
print("line %s: predY data is different: %s != %s"%(index+2, row['predY'], row2['predY']), file=sys.stderr)
print("Check your parameters or your implementation")
problem = True
Expand Down
2 changes: 1 addition & 1 deletion typescript/src/test.ts

Large diffs are not rendered by default.

0 comments on commit 52c4adb

Please sign in to comment.