From 99a5352b5cf790c559a7b976c1ba99520431d9d1 Mon Sep 17 00:00:00 2001 From: "Billy K. Poon" Date: Mon, 15 Jul 2024 15:48:38 -0700 Subject: [PATCH] Another fix for numpy 2.0 - Compare pointers directly instead of using PyArray_EquivTypes --- src/numpy/dtype.cpp | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/numpy/dtype.cpp b/src/numpy/dtype.cpp index da30d1927..1ce8c6ec3 100644 --- a/src/numpy/dtype.cpp +++ b/src/numpy/dtype.cpp @@ -107,32 +107,7 @@ int dtype::get_itemsize() const { } bool equivalent(dtype const & a, dtype const & b) { - // On Windows x64, the behaviour described on - // http://docs.scipy.org/doc/numpy/reference/c-api.array.html for - // PyArray_EquivTypes unfortunately does not extend as expected: - // "For example, on 32-bit platforms, NPY_LONG and NPY_INT are equivalent". - // This should also hold for 64-bit platforms (and does on Linux), but not - // on Windows. Implement an alternative: -#ifdef _MSC_VER - if (sizeof(long) == sizeof(int) && - // Manually take care of the type equivalence. - ((a == dtype::get_builtin() || a == dtype::get_builtin()) && - (b == dtype::get_builtin() || b == dtype::get_builtin()) || - (a == dtype::get_builtin() || a == dtype::get_builtin()) && - (b == dtype::get_builtin() || b == dtype::get_builtin()))) { - return true; - } else { - return PyArray_EquivTypes( - reinterpret_cast(a.ptr()), - reinterpret_cast(b.ptr()) - ); - } -#else - return PyArray_EquivTypes( - reinterpret_cast(a.ptr()), - reinterpret_cast(b.ptr()) - ); -#endif + return a == b; } namespace