from simplification.cutil import simplify_coords
import numpy as np
x = np.array([1,2,3,4,5])
y = np.array([0,1,1,1,0])
coords = np.transpose(np.stack((x,y)))
simplified = simplify_coords(coords, 1.0)
returns the error
Traceback (most recent call last):
File "simplification-c-contiguous-bug.py", line 10, in <module>
simplified = simplify_coords(coords, 1.0)
File "simplification/cutil.pyx", line 51, in simplification.cutil.simplify_coords
File "simplification/cutil.pyx", line 65, in simplification.cutil.simplify_coords
File "stringsource", line 658, in View.MemoryView.memoryview_cwrapper
File "stringsource", line 349, in View.MemoryView.memoryview.__cinit__
ValueError: ndarray is not C-contiguous
Adding the line coords = np.ascontiguousarray(coords) solves the error.
I would guess that this implicit assumption of a contiguous array (see here for an explanation) in your code is unwanted behavior and could be fixed by an explicit check.
Hi!
The following code:
returns the error
Adding the line
coords = np.ascontiguousarray(coords)
solves the error.I would guess that this implicit assumption of a contiguous array (see here for an explanation) in your code is unwanted behavior and could be fixed by an explicit check.
Thanks!