Skip to content

Commit 99a5352

Browse files
bkpoonstefanseefeld
authored andcommitted
Another fix for numpy 2.0
- Compare pointers directly instead of using PyArray_EquivTypes
1 parent 1fed082 commit 99a5352

1 file changed

Lines changed: 1 addition & 26 deletions

File tree

src/numpy/dtype.cpp

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,7 @@ int dtype::get_itemsize() const {
107107
}
108108

109109
bool equivalent(dtype const & a, dtype const & b) {
110-
// On Windows x64, the behaviour described on
111-
// http://docs.scipy.org/doc/numpy/reference/c-api.array.html for
112-
// PyArray_EquivTypes unfortunately does not extend as expected:
113-
// "For example, on 32-bit platforms, NPY_LONG and NPY_INT are equivalent".
114-
// This should also hold for 64-bit platforms (and does on Linux), but not
115-
// on Windows. Implement an alternative:
116-
#ifdef _MSC_VER
117-
if (sizeof(long) == sizeof(int) &&
118-
// Manually take care of the type equivalence.
119-
((a == dtype::get_builtin<long>() || a == dtype::get_builtin<int>()) &&
120-
(b == dtype::get_builtin<long>() || b == dtype::get_builtin<int>()) ||
121-
(a == dtype::get_builtin<unsigned int>() || a == dtype::get_builtin<unsigned long>()) &&
122-
(b == dtype::get_builtin<unsigned int>() || b == dtype::get_builtin<unsigned long>()))) {
123-
return true;
124-
} else {
125-
return PyArray_EquivTypes(
126-
reinterpret_cast<PyArray_Descr*>(a.ptr()),
127-
reinterpret_cast<PyArray_Descr*>(b.ptr())
128-
);
129-
}
130-
#else
131-
return PyArray_EquivTypes(
132-
reinterpret_cast<PyArray_Descr*>(a.ptr()),
133-
reinterpret_cast<PyArray_Descr*>(b.ptr())
134-
);
135-
#endif
110+
return a == b;
136111
}
137112

138113
namespace

0 commit comments

Comments
 (0)