summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/tests/control5
-rwxr-xr-xdebian/tests/python.py46
-rwxr-xr-xdebian/tests/python.sh11
3 files changed, 61 insertions, 1 deletions
diff --git a/debian/tests/control b/debian/tests/control
index 5b92a47..1b4d2c3 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,2 +1,5 @@
Tests: utils.sh
-Depends: phat-utils, shunit2 \ No newline at end of file
+Depends: phat-utils, shunit2
+
+Tests: python.sh
+Depends: python3-all, python3-phat
diff --git a/debian/tests/python.py b/debian/tests/python.py
new file mode 100755
index 0000000..eaad48f
--- /dev/null
+++ b/debian/tests/python.py
@@ -0,0 +1,46 @@
+import phat
+
+def main():
+ files = ["single_triangle"]
+
+ for file in files:
+ ref = []
+ with open("debian/tests/reference/%s.txt" %(file), "r") as f:
+ f.readline()
+ for line in f:
+ splitline = line.strip().split(" ")
+ assert(len(splitline) == 2)
+ ref.append((int(splitline[0]), int(splitline[1])))
+ ref.sort()
+
+ cols = []
+ with open("examples/%s.dat" %(file), "r") as f:
+ for line in f:
+ if not line.startswith("#") and line.strip() != "":
+ splitline = line.rstrip().split(" ")
+ cols.append((int(splitline[0]), [int(x) for x in splitline[1:]]))
+
+ for repr in phat.representations:
+ for alg in phat.reductions:
+ for dualize in [False, True]:
+ print("File %s, representation %s, algorithm %s, dualization %s" %(file, repr, alg, str(dualize)))
+
+ bd = phat.boundary_matrix(representation=repr)
+ bd.columns = cols
+ if dualize:
+ pairs = list(bd.compute_persistence_pairs_dualized(reduction=alg))
+ else:
+ pairs = list(bd.compute_persistence_pairs(reduction=alg))
+ pairs.sort()
+
+ if ref == pairs:
+ print("OK!")
+ else:
+ print("ERROR!")
+ print("Got", pairs)
+ print("Expected", ref)
+ exit(1)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/debian/tests/python.sh b/debian/tests/python.sh
new file mode 100755
index 0000000..b66e101
--- /dev/null
+++ b/debian/tests/python.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+for py3ver in $(py3versions -vs)
+do
+ echo "Running tests with Python ${py3ver}."
+ /usr/bin/python${py3ver} -B debian/tests/python.py
+ echo "---------"
+done
+