|
| 1 | +diff --git a/libs/python/src/numpy/dtype.cpp b/libs/python/src/numpy/dtype.cpp |
| 2 | +index da30d192..1ce8c6ec 100644 |
| 3 | +--- a/libs/python/src/numpy/dtype.cpp |
| 4 | ++++ b/libs/python/src/numpy/dtype.cpp |
| 5 | +@@ -107,32 +107,7 @@ int dtype::get_itemsize() const { |
| 6 | + } |
| 7 | + |
| 8 | + bool equivalent(dtype const & a, dtype const & b) { |
| 9 | +- // On Windows x64, the behaviour described on |
| 10 | +- // http://docs.scipy.org/doc/numpy/reference/c-api.array.html for |
| 11 | +- // PyArray_EquivTypes unfortunately does not extend as expected: |
| 12 | +- // "For example, on 32-bit platforms, NPY_LONG and NPY_INT are equivalent". |
| 13 | +- // This should also hold for 64-bit platforms (and does on Linux), but not |
| 14 | +- // on Windows. Implement an alternative: |
| 15 | +-#ifdef _MSC_VER |
| 16 | +- if (sizeof(long) == sizeof(int) && |
| 17 | +- // Manually take care of the type equivalence. |
| 18 | +- ((a == dtype::get_builtin<long>() || a == dtype::get_builtin<int>()) && |
| 19 | +- (b == dtype::get_builtin<long>() || b == dtype::get_builtin<int>()) || |
| 20 | +- (a == dtype::get_builtin<unsigned int>() || a == dtype::get_builtin<unsigned long>()) && |
| 21 | +- (b == dtype::get_builtin<unsigned int>() || b == dtype::get_builtin<unsigned long>()))) { |
| 22 | +- return true; |
| 23 | +- } else { |
| 24 | +- return PyArray_EquivTypes( |
| 25 | +- reinterpret_cast<PyArray_Descr*>(a.ptr()), |
| 26 | +- reinterpret_cast<PyArray_Descr*>(b.ptr()) |
| 27 | +- ); |
| 28 | +- } |
| 29 | +-#else |
| 30 | +- return PyArray_EquivTypes( |
| 31 | +- reinterpret_cast<PyArray_Descr*>(a.ptr()), |
| 32 | +- reinterpret_cast<PyArray_Descr*>(b.ptr()) |
| 33 | +- ); |
| 34 | +-#endif |
| 35 | ++ return a == b; |
| 36 | + } |
| 37 | + |
| 38 | + namespace |
0 commit comments