def landscapes_approx(diag,p_dim,x_min,x_max,nb_nodes,nb_ld): """Compute a dicretization of the first nb_ld landscape of a p_dim-dimensional persistence diagram on a regular grid on the interval [x_min,x_max]. The output is a nb_ld x nb_nodes numpy array + diag: a persistence diagram (in the Gudhi format) + dim: the dimension in homology to consider """ landscape = np.zeros((nb_ld,nb_nodes)) diag_dim = [] for pair in diag: #get persistence points for homology in dimension dim if (pair[0] == p_dim): diag_dim.append(pair[1]) step = (x_max - x_min) / (nb_nodes - 1) #Warning: naive and not the most efficient way to proceed!!!!! for i in range(nb_nodes): x = x_min + i * step t = x / np.sqrt(2) event_list = [] for pair in diag_dim: b = pair[0] d = pair[1] if b <= t <= d: if t >= (d+b)/2: event_list.append((d-t)*np.sqrt(2)) else: event_list.append((t-b)*np.sqrt(2)) event_list.sort(reverse=True) event_list = np.asarray(event_list) for j in range(nb_ld): if(j