diff --git a/tests/eigency_tests/eigency_tests.pyx b/tests/eigency_tests/eigency_tests.pyx index f82cec0..f8ce32d 100644 --- a/tests/eigency_tests/eigency_tests.pyx +++ b/tests/eigency_tests/eigency_tests.pyx @@ -46,7 +46,9 @@ cdef extern from "eigency_tests/eigency_tests_cpp.h": cdef PlainObjectBase _function_type_double "function_type_double" (Map[ArrayXXd] &) cdef PlainObjectBase _function_type_float "function_type_float" (Map[ArrayXXf] &) cdef PlainObjectBase _function_type_long "function_type_long" (FlattenedMap[Array, long, Dynamic, Dynamic] &) + cdef PlainObjectBase _function_type_long_long "function_type_long_long" (FlattenedMap[Array, long long, Dynamic, Dynamic] &) cdef PlainObjectBase _function_type_ulong "function_type_ulong" (FlattenedMap[Array, unsigned long, Dynamic, Dynamic] &) + cdef PlainObjectBase _function_type_ulong_long "function_type_ulong_long" (FlattenedMap[Array, unsigned long long, Dynamic, Dynamic] &) cdef PlainObjectBase _function_type_int "function_type_int" (Map[ArrayXXi] &) cdef PlainObjectBase _function_type_uint "function_type_uint" (FlattenedMap[Array, unsigned int, Dynamic, Dynamic] &) cdef PlainObjectBase _function_type_short "function_type_short" (FlattenedMap[Array, short, Dynamic, Dynamic] &) @@ -151,10 +153,18 @@ def function_type_float32(np.ndarray[np.float32_t, ndim=2] array): def function_type_long(np.ndarray[long, ndim=2] array): return ndarray(_function_type_long(FlattenedMap[Array, long, Dynamic, Dynamic](array))) +# Functions with different matrix types: long long +def function_type_long_long(np.ndarray[long long, ndim=2] array): + return ndarray(_function_type_long_long(FlattenedMap[Array, longlong, Dynamic, Dynamic](array))) + # Functions with different matrix types: ulong def function_type_ulong(np.ndarray[unsigned long, ndim=2] array): return ndarray(_function_type_ulong(FlattenedMap[Array, ulong, Dynamic, Dynamic](array))) +# Functions with different matrix types: ulong long +def function_type_ulong_long(np.ndarray[unsigned long long, ndim=2] array): + return ndarray(_function_type_ulong_long(FlattenedMap[Array, ulonglong, Dynamic, Dynamic](array))) + # Functions with different matrix types: int def function_type_intc(np.ndarray[np.int32_t, ndim=2] array): return ndarray(_function_type_int(Map[ArrayXXi](array))) diff --git a/tests/eigency_tests/eigency_tests_cpp.cpp b/tests/eigency_tests/eigency_tests_cpp.cpp index 3193688..ad5a2b2 100644 --- a/tests/eigency_tests/eigency_tests_cpp.cpp +++ b/tests/eigency_tests/eigency_tests_cpp.cpp @@ -88,11 +88,22 @@ Eigen::Array function_type_long(Eigen::Map return output; } +Eigen::Array function_type_long_long(Eigen::Map > &mat) { + Eigen::Array output = mat; + return output; +} + Eigen::Array function_type_ulong(Eigen::Map > &mat) { Eigen::Array output = mat; return output; } +Eigen::Array function_type_ulong_long(Eigen::Map > &mat) { + Eigen::Array output = mat; + return output; +} + + Eigen::ArrayXXi function_type_int(Eigen::Map &mat) { Eigen::ArrayXXi output = mat; return output; diff --git a/tests/eigency_tests/eigency_tests_cpp.h b/tests/eigency_tests/eigency_tests_cpp.h index 0d8d29e..ea6a5fd 100644 --- a/tests/eigency_tests/eigency_tests_cpp.h +++ b/tests/eigency_tests/eigency_tests_cpp.h @@ -41,7 +41,9 @@ CustomStrideMap &function_filter3(CustomStrideMap &); Eigen::ArrayXXd function_type_double(Eigen::Map &array); Eigen::ArrayXXf function_type_float(Eigen::Map &array); Eigen::Array function_type_long(Eigen::Map > &mat); +Eigen::Array function_type_long_long(Eigen::Map > &mat); Eigen::Array function_type_ulong(Eigen::Map > &mat); +Eigen::Array function_type_ulong_long(Eigen::Map > &mat); Eigen::ArrayXXi function_type_int(Eigen::Map &array); Eigen::Array function_type_uint(Eigen::Map > &array); Eigen::Array function_type_short(Eigen::Map > &mat); diff --git a/tests/run_tests.py b/tests/run_tests.py index 6ab42cc..ef53359 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -161,20 +161,30 @@ def test_function_type_float32(self): def test_function_type_int(self): # C++ long - Note that this is the standard Python integer + # with numpy 1 int is 32 in numpy 2 int is 64, so we need to be more specific mat_in = np.array([[1, 2, 3, 4], [5, 6, 7, 8]], order="F") - mat_out = eigency_tests.function_type_long(mat_in) + if mat_in.dtype == np.dtype('long'): + mat_out = eigency_tests.function_type_long(mat_in) + else: + mat_out = eigency_tests.function_type_long_long(mat_in) assert_array_equal(mat_in, mat_out) def test_function_type_long(self): # C++ long - Note that this is the standard Python integer mat_in = np.array([[1, 2, 3, 4], [5, 6, 7, 8]], order="F", dtype=int) - mat_out = eigency_tests.function_type_long(mat_in) + if mat_in.dtype == np.dtype('long'): + mat_out = eigency_tests.function_type_long(mat_in) + else: + mat_out = eigency_tests.function_type_long_long(mat_in) assert_array_equal(mat_in, mat_out) def test_function_type_ulong(self): # C++ ulong mat_in = np.array([[1, 2, 3, 4], [5, 6, 7, 8]], order="F", dtype=np.uint) - mat_out = eigency_tests.function_type_ulong(mat_in) + if mat_in.dtype == np.dtype('ulong'): + mat_out = eigency_tests.function_type_ulong(mat_in) + else: + mat_out = eigency_tests.function_type_ulong_long(mat_in) assert_array_equal(mat_in, mat_out) def test_function_type_intc(self):