Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save VincentRouvreau/7972e3ea4a6b6934040e820a346ba32e to your computer and use it in GitHub Desktop.
Save VincentRouvreau/7972e3ea4a6b6934040e820a346ba32e to your computer and use it in GitHub Desktop.
Persistence graphical tools benchmark
import numpy as np
import gudhi
import matplotlib.pyplot as plt
from timeit import default_timer as timer
from datetime import timedelta
def randpers(nb_elts):
a = np.random.random(size=(nb_elts, 2))
# birth = column 0 | death = column 0 + column 1
return np.concatenate(((a[:,0]).reshape(nb_elts,1), (a[:,0] + a[:,1]).reshape(nb_elts,1)), axis=1)
nb_plots = 1000
for func in [gudhi.plot_persistence_diagram, gudhi.plot_persistence_barcode, gudhi.plot_persistence_density]:
while True:
start = timer()
func(randpers(nb_plots), max_intervals=nb_plots)
# Do not get stuck on matplotlib GUI
plt.ion()
plt.show()
chrono = timedelta(seconds=timer()-start)
print(func, "\t", nb_plots, "\t in ", chrono)
plt.close('all')
nb_plots = nb_plots * 2
if chrono.total_seconds() > 10:
nb_plots = 1000
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment