0

I have been referencing multiple posts including this one: Difference between np.int, np.int_, int, and np.int_t in cython?

But I am still getting the following errors:

ValueError: Buffer dtype mismatch, expected 'int' but got 'long'

I am trying to define a function that takes int64 and float64 Numpy arrays.

import cython
import numpy as np
cimport numpy as np
cimport cython

np.get_include()

DTYPE = np.int64
fDTYPE = np.float64

def function(signed long long [:,:] array1, 
             signed long long [:] array2, 
             double[:] array3):

    assert array1.dtype == DTYPE
    assert array2.dtype == DTYPE
    assert array3.dtype == fDTYPE
    cdef signed long long x0 = array2[0]
    cdef signed long long y0 = array2[1]
    cdef double a = array3[0]
    cdef double b = array3[1]
    cdef double c = array3[2]

I appreciate all the constructive advice. Thank you!!

Bun
  • 11
  • 2
  • 2
    You should also add, your function is called and make a proper [mre]. – ead Jul 10 '21 at 05:07
  • Also the fact, that you are using windows (I assume) is probably important here. – ead Jul 10 '21 at 05:10
  • You are passing in a buffer of the wrong type. Try using the function signature `def int [:,:] array1, int [:] array2, double[:] array3)`. Memoryviews of type int and signed long long are not automatically converted – Golden Rockefeller Jul 18 '21 at 16:58

0 Answers0