gudhi-devel
gudhi-devel copied to clipboard
`insert_batch` requires data to be writable
import gudhi as gd
import numpy as np
from joblib import Parallel, delayed
edges = np.random.randint(15000, size=(2, 80000))
def ToSimplexTree():
st_copy = gd.SimplexTree()
st_copy.insert_batch(edges, np.zeros(len(edges.T)))
print(len(edges.T), " - ", st_copy.num_vertices(), " - ", st_copy.num_simplices())
return None
Parallel(n_jobs=2)(delayed(ToSimplexTree)() for _ in range(15))
File "<stdin>", line 3, in ToSimplexTree
File "simplex_tree.pyx", line 293, in gudhi.simplex_tree.SimplexTree.insert_batch
File "stringsource", line 660, in View.MemoryView.memoryview_cwrapper
File "stringsource", line 350, in View.MemoryView.memoryview.__cinit__
ValueError: buffer source array is read-only
Note: Making a copy of edges
can be used as a workaround, as writeable flag will become true.
Attempt of fix: with
def insert_batch(self, const some_int[:,:] vertex_array, const some_float[:] filtrations):
cython is not happy with const int_32_t