Added extra functionality to Point class( an iterator ) and PersistenceDiagram( dimension property and __len__ func ).
persistence-diagram.h:
Added a new read-only dimension member and member function to access it.
With a new constructor that that takes in an int type to initialize dimension.
persistence-diagram.cpp:
Added new bp::init constructor. Takes in an integer type to initialize the dimension. Exposed the dimension property. Exposed the size property via a __len__ method.
__init__.py:
Added an iterator for Point objects. This iterates over the coords and then the data( if present ).
#!/usr/bin/env python
from pylab import scatter, show, cm, colorbar, axes, savefig
from itertools import izip
from sys import argv, exit
import os.path as osp
def plot(val1_fn, val2_fn, outfn = None):
values1 = []
with open(val1_fn) as fp:
for line in fp.xreadlines():
values1.append(float(line.split()[1]))
values2 = []
with open(val2_fn) as fp:
for line in fp.xreadlines():
values2.append(float(line.split()[1]))
values1 = [v % 1. for v in values1]
values2 = [v % 1. for v in values2]
print min(values1), max(values2), min(values1), min(values2)
scatter(values1, values2, s=10)
axes().set_aspect('equal')
if not outfn:
show()
else:
savefig(outfn)
if __name__ == '__main__':
if len(argv) < 3:
print "Usage: %s VALUES1 VALUES2 [OUTPUT]" % argv[0]
exit()
val1_fn = argv[1]
val2_fn = argv[2]
outfn = None
if len(argv) > 3:
outfn = argv[3]
plot(val1_fn, val2_fn, outfn)