From 86e05c8ca0dba54d2cba4d2dc4f0f9685a09a8b8 Mon Sep 17 00:00:00 2001 From: Cleaf-y <112595834+Cleaf-y@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:48:46 +0800 Subject: [PATCH] Fix error on Windows in heapq.pyx of issue #36 by specifying dtype Addressing Issue #36 The expected type was 'Py_ssize_t', but 'long' was provided instead. This led to runtime exception. The solution was to explicitly set the dtype parameter to np.intp in the np.full function call. This modification resolves the error on Windows by ensuring the type matches the expected 'Py_ssize_t', as np.intp is the numpy data type that maps to 'ssize_t' on the platform being compiled on, thus aligning with Python's indexing types and C's ssize_t on Windows. --- pykonal/heapq.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pykonal/heapq.pyx b/pykonal/heapq.pyx index 918a2ed..214dd2b 100644 --- a/pykonal/heapq.pyx +++ b/pykonal/heapq.pyx @@ -33,7 +33,7 @@ cdef class Heap(object): """ def __init__(self, values): self.cy_values = values - self.cy_heap_index = np.full(values.shape, fill_value=-1) + self.cy_heap_index = np.full(values.shape, fill_value=-1, dtype=np.intp) @property