summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGard Spreemann <gspr@nonempty.org>2020-03-09 11:17:26 +0100
committerGard Spreemann <gspr@nonempty.org>2020-03-09 11:17:26 +0100
commita1de2b36590341b693db312d0b34bf53fbde9171 (patch)
tree79ac6cfcf46174c42c1b451d6465b188cee0eb5d
parent42fc5dd706d8364b1fe347729e049962549ba1c5 (diff)
-rw-r--r--debian/changelog3
-rw-r--r--debian/tests/control2
-rwxr-xr-xdebian/tests/examples.py76
-rw-r--r--debian/tests/reference/projective_plane.csv.txt20
-rw-r--r--debian/tests/reference/projective_plane.dipha.txt20
-rw-r--r--debian/tests/reference/projective_plane.lower_distance_matrix.txt20
-rw-r--r--debian/tests/reference/sphere_3_192.lower_distance_matrix.txt251
7 files changed, 391 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index 3f2870a..1e9acb1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,9 @@ ripser (1.1.20200206.286d36-2) unstable; urgency=medium
* Add patch to prevent overflow on 32 bit architectures.
* Standards-version 4.5.0. No changes needed.
+ * Add tests.
- -- Gard Spreemann <gspr@nonempty.org> Sun, 08 Mar 2020 15:15:35 +0100
+ -- Gard Spreemann <gspr@nonempty.org> Mon, 09 Mar 2020 11:16:50 +0100
ripser (1.1.20200206.286d36-1) unstable; urgency=medium
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..a948b2f
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,2 @@
+Tests: examples.py
+Depends: python3, python3-numpy, ripser
diff --git a/debian/tests/examples.py b/debian/tests/examples.py
new file mode 100755
index 0000000..a5a4836
--- /dev/null
+++ b/debian/tests/examples.py
@@ -0,0 +1,76 @@
+#!/usr/bin/python3
+
+import numpy as np
+import subprocess
+
+def parse_output(s):
+ ret = []
+ current_dim = None
+ for line in s.splitlines():
+ if line.startswith("persistence intervals in dim"):
+ splitline = line.rstrip().rstrip(":").split(" ")
+ assert(len(splitline) == 5)
+ current_dim = int(splitline[-1])
+ while len(ret) < current_dim + 1:
+ ret.append(([], []))
+ elif line.startswith(" ["):
+ splitline = line.lstrip(" [").rstrip().rstrip(")").split(",")
+ assert(len(splitline) == 2)
+ if splitline[1].strip() == "":
+ ret[current_dim][1].append(float(splitline[0]))
+ else:
+ ret[current_dim][0].append((float(splitline[0]), float(splitline[1])))
+
+ return ret
+
+def main():
+ tests = [(None, "lower-distance", 2, "sphere_3_192.lower_distance_matrix"),
+ (None, "distance", 2, "projective_plane.csv"),
+ (None, "dipha", 2, "projective_plane.dipha"),
+ (None, "lower-distance", 2, "projective_plane.lower_distance_matrix"),
+ (2, "lower-distance", 2, "sphere_3_192.lower_distance_matrix"),
+ (2, "distance", 2, "projective_plane.csv"),
+ (2, "dipha", 2, "projective_plane.dipha"),
+ (2, "lower-distance", 2, "projective_plane.lower_distance_matrix")]
+
+ for (coeff, format, dim, prefix) in tests:
+ if coeff is None:
+ print("Running test %s." %(prefix))
+ proc = subprocess.Popen(["/usr/bin/ripser", "--dim", str(dim), "--format", format, "examples/%s" %(prefix)], stdout=subprocess.PIPE)
+ else:
+ print("Running test %s with coefficients in Z/%dZ." %(prefix, coeff))
+ proc = subprocess.Popen(["/usr/bin/ripser-coeff", "--modulus", str(coeff), "--dim", str(dim), "--format", format, "examples/%s" %(prefix)], stdout=subprocess.PIPE)
+
+ output = proc.communicate()[0].decode("utf-8")
+ assert(proc.returncode == 0)
+ pd = parse_output(output)
+
+ with open("debian/tests/reference/%s.txt" %(prefix), "r") as f:
+ pd_ref = parse_output(f.read())
+
+ assert(len(pd) == len(pd_ref))
+
+ for d in range(0, len(pd)):
+ fin = np.array(sorted(pd[d][0]))
+ inf = np.array(sorted(pd[d][1]))
+ print("Finite bars in dimension %d:" %(d))
+ print(fin)
+ print("Infinite bars in dimension %d:" %(d))
+ print(inf)
+
+ fin_ref = np.array(sorted(pd_ref[d][0]))
+ inf_ref = np.array(sorted(pd_ref[d][1]))
+
+ assert(fin.shape == fin_ref.shape)
+ assert(inf.shape == inf_ref.shape)
+
+ np.testing.assert_allclose(fin, fin_ref)
+ np.testing.assert_allclose(inf, inf_ref)
+
+ print("------")
+
+ print("-------------------------------------------------")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/debian/tests/reference/projective_plane.csv.txt b/debian/tests/reference/projective_plane.csv.txt
new file mode 100644
index 0000000..c135026
--- /dev/null
+++ b/debian/tests/reference/projective_plane.csv.txt
@@ -0,0 +1,20 @@
+value range: [1,2]
+distance matrix with 13 points
+persistence intervals in dim 0:
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0, )
+persistence intervals in dim 1:
+ [1,2)
+persistence intervals in dim 2:
+ [1,2)
diff --git a/debian/tests/reference/projective_plane.dipha.txt b/debian/tests/reference/projective_plane.dipha.txt
new file mode 100644
index 0000000..c135026
--- /dev/null
+++ b/debian/tests/reference/projective_plane.dipha.txt
@@ -0,0 +1,20 @@
+value range: [1,2]
+distance matrix with 13 points
+persistence intervals in dim 0:
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0, )
+persistence intervals in dim 1:
+ [1,2)
+persistence intervals in dim 2:
+ [1,2)
diff --git a/debian/tests/reference/projective_plane.lower_distance_matrix.txt b/debian/tests/reference/projective_plane.lower_distance_matrix.txt
new file mode 100644
index 0000000..c135026
--- /dev/null
+++ b/debian/tests/reference/projective_plane.lower_distance_matrix.txt
@@ -0,0 +1,20 @@
+value range: [1,2]
+distance matrix with 13 points
+persistence intervals in dim 0:
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0,1)
+ [0, )
+persistence intervals in dim 1:
+ [1,2)
+persistence intervals in dim 2:
+ [1,2)
diff --git a/debian/tests/reference/sphere_3_192.lower_distance_matrix.txt b/debian/tests/reference/sphere_3_192.lower_distance_matrix.txt
new file mode 100644
index 0000000..71f9b72
--- /dev/null
+++ b/debian/tests/reference/sphere_3_192.lower_distance_matrix.txt
@@ -0,0 +1,251 @@
+value range: [0.00367531,2]
+sparse distance matrix with 192 points and 17857/18431 entries
+persistence intervals in dim 0:
+ [0,0.00391946)
+ [0,0.00367531)
+ [0,0.0120098)
+ [0,0.0173134)
+ [0,0.0217315)
+ [0,0.0311057)
+ [0,0.037954)
+ [0,0.0387451)
+ [0,0.0433426)
+ [0,0.0471186)
+ [0,0.0487061)
+ [0,0.048826)
+ [0,0.0496187)
+ [0,0.0515157)
+ [0,0.0522132)
+ [0,0.0559886)
+ [0,0.0560443)
+ [0,0.057488)
+ [0,0.0593071)
+ [0,0.0623736)
+ [0,0.0633425)
+ [0,0.0637053)
+ [0,0.0651112)
+ [0,0.0672609)
+ [0,0.0692368)
+ [0,0.0702075)
+ [0,0.0714516)
+ [0,0.0728647)
+ [0,0.0741239)
+ [0,0.0743236)
+ [0,0.0746054)
+ [0,0.0753955)
+ [0,0.076909)
+ [0,0.0782455)
+ [0,0.0792212)
+ [0,0.0800348)
+ [0,0.0802451)
+ [0,0.0814685)
+ [0,0.0831358)
+ [0,0.0831521)
+ [0,0.084341)
+ [0,0.0857401)
+ [0,0.0870489)
+ [0,0.0884133)
+ [0,0.0959033)
+ [0,0.0970981)
+ [0,0.0988752)
+ [0,0.0994522)
+ [0,0.108768)
+ [0,0.109526)
+ [0,0.111131)
+ [0,0.111798)
+ [0,0.115939)
+ [0,0.119187)
+ [0,0.121955)
+ [0,0.122089)
+ [0,0.123527)
+ [0,0.124774)
+ [0,0.126595)
+ [0,0.127383)
+ [0,0.127864)
+ [0,0.129741)
+ [0,0.131438)
+ [0,0.131638)
+ [0,0.133033)
+ [0,0.133525)
+ [0,0.133722)
+ [0,0.134886)
+ [0,0.135402)
+ [0,0.138674)
+ [0,0.141823)
+ [0,0.142152)
+ [0,0.142537)
+ [0,0.142834)
+ [0,0.143085)
+ [0,0.143151)
+ [0,0.145018)
+ [0,0.145725)
+ [0,0.147203)
+ [0,0.147289)
+ [0,0.147427)
+ [0,0.148506)
+ [0,0.149017)
+ [0,0.149226)
+ [0,0.150747)
+ [0,0.151643)
+ [0,0.15244)
+ [0,0.154095)
+ [0,0.15587)
+ [0,0.1569)
+ [0,0.157251)
+ [0,0.157293)
+ [0,0.157373)
+ [0,0.158413)
+ [0,0.159282)
+ [0,0.162464)
+ [0,0.164809)
+ [0,0.164815)
+ [0,0.165202)
+ [0,0.165314)
+ [0,0.165494)
+ [0,0.165592)
+ [0,0.165907)
+ [0,0.167455)
+ [0,0.168587)
+ [0,0.173412)
+ [0,0.173586)
+ [0,0.173684)
+ [0,0.174172)
+ [0,0.17493)
+ [0,0.175016)
+ [0,0.176306)
+ [0,0.179609)
+ [0,0.18428)
+ [0,0.184757)
+ [0,0.189106)
+ [0,0.190642)
+ [0,0.191661)
+ [0,0.192356)
+ [0,0.192406)
+ [0,0.192733)
+ [0,0.193791)
+ [0,0.193804)
+ [0,0.195722)
+ [0,0.197377)
+ [0,0.199673)
+ [0,0.201961)
+ [0,0.202564)
+ [0,0.203812)
+ [0,0.204208)
+ [0,0.204544)
+ [0,0.205389)
+ [0,0.207016)
+ [0,0.207261)
+ [0,0.207714)
+ [0,0.208063)
+ [0,0.208851)
+ [0,0.210372)
+ [0,0.214018)
+ [0,0.215759)
+ [0,0.218526)
+ [0,0.218561)
+ [0,0.223232)
+ [0,0.227524)
+ [0,0.227933)
+ [0,0.2286)
+ [0,0.228917)
+ [0,0.231179)
+ [0,0.231675)
+ [0,0.234112)
+ [0,0.234969)
+ [0,0.237571)
+ [0,0.23879)
+ [0,0.240632)
+ [0,0.24348)
+ [0,0.24509)
+ [0,0.246491)
+ [0,0.247042)
+ [0,0.248879)
+ [0,0.249339)
+ [0,0.249345)
+ [0,0.253163)
+ [0,0.253227)
+ [0,0.25725)
+ [0,0.257997)
+ [0,0.264334)
+ [0,0.264483)
+ [0,0.266592)
+ [0,0.266635)
+ [0,0.268806)
+ [0,0.270996)
+ [0,0.274611)
+ [0,0.276431)
+ [0,0.277191)
+ [0,0.277582)
+ [0,0.280629)
+ [0,0.282169)
+ [0,0.283562)
+ [0,0.283881)
+ [0,0.285416)
+ [0,0.287316)
+ [0,0.288591)
+ [0,0.289189)
+ [0,0.293466)
+ [0,0.297053)
+ [0,0.297933)
+ [0,0.304062)
+ [0,0.316023)
+ [0,0.319493)
+ [0,0.323964)
+ [0,0.332695)
+ [0, )
+persistence intervals in dim 1:
+ [0.542696,0.558863)
+ [0.531636,0.578093)
+ [0.530723,0.576869)
+ [0.463389,0.505345)
+ [0.445398,0.448892)
+ [0.443911,0.54761)
+ [0.431628,0.477277)
+ [0.413789,0.487379)
+ [0.412572,0.46308)
+ [0.411549,0.471715)
+ [0.409968,0.478461)
+ [0.386278,0.4922)
+ [0.381084,0.421374)
+ [0.377729,0.514046)
+ [0.377147,0.414788)
+ [0.377019,0.434385)
+ [0.374531,0.477153)
+ [0.370051,0.483155)
+ [0.361715,0.403181)
+ [0.354747,0.454956)
+ [0.352356,0.541947)
+ [0.350913,0.369543)
+ [0.35058,0.580726)
+ [0.347806,0.638039)
+ [0.347388,0.559978)
+ [0.344005,0.387193)
+ [0.34298,0.65758)
+ [0.339394,0.463666)
+ [0.33836,0.350411)
+ [0.33392,0.35111)
+ [0.33364,0.3797)
+ [0.331259,0.356381)
+ [0.329066,0.386148)
+ [0.324571,0.343083)
+ [0.324159,0.399094)
+ [0.322683,0.482958)
+ [0.318032,0.417462)
+ [0.317521,0.349622)
+ [0.316534,0.682559)
+ [0.309419,0.37151)
+ [0.309336,0.310216)
+ [0.308779,0.346297)
+ [0.304761,0.647803)
+ [0.301986,0.478334)
+ [0.301045,0.303943)
+ [0.29997,0.311993)
+ [0.298341,0.360737)
+ [0.279016,0.301331)
+ [0.2576,0.373749)
+ [0.253337,0.292286)
+ [0.24546,0.248903)
+ [0.240869,0.288747)
+ [0.189652,0.197515)
+persistence intervals in dim 2:
+ [0.720484,1.65562)