51 lines
2 KiB
Diff
51 lines
2 KiB
Diff
Submodule libs/python 47d5bc76f6..8d15ce0517:
|
|
diff --git a/libs/python/src/numpy/dtype.cpp b/libs/python/src/numpy/dtype.cpp
|
|
index 88a20a27..1ce8c6ec 100644
|
|
--- a/libs/python/src/numpy/dtype.cpp
|
|
+++ b/libs/python/src/numpy/dtype.cpp
|
|
@@ -98,37 +98,18 @@ python::detail::new_reference dtype::convert(object const & arg, bool align)
|
|
return python::detail::new_reference(reinterpret_cast<PyObject*>(obj));
|
|
}
|
|
|
|
-int dtype::get_itemsize() const { return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;}
|
|
-
|
|
-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<long>() || a == dtype::get_builtin<int>()) &&
|
|
- (b == dtype::get_builtin<long>() || b == dtype::get_builtin<int>()) ||
|
|
- (a == dtype::get_builtin<unsigned int>() || a == dtype::get_builtin<unsigned long>()) &&
|
|
- (b == dtype::get_builtin<unsigned int>() || b == dtype::get_builtin<unsigned long>()))) {
|
|
- return true;
|
|
- } else {
|
|
- return PyArray_EquivTypes(
|
|
- reinterpret_cast<PyArray_Descr*>(a.ptr()),
|
|
- reinterpret_cast<PyArray_Descr*>(b.ptr())
|
|
- );
|
|
- }
|
|
+int dtype::get_itemsize() const {
|
|
+#if NPY_ABI_VERSION < 0x02000000
|
|
+ return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;
|
|
#else
|
|
- return PyArray_EquivTypes(
|
|
- reinterpret_cast<PyArray_Descr*>(a.ptr()),
|
|
- reinterpret_cast<PyArray_Descr*>(b.ptr())
|
|
- );
|
|
+ return PyDataType_ELSIZE(reinterpret_cast<PyArray_Descr*>(ptr()));
|
|
#endif
|
|
}
|
|
|
|
+bool equivalent(dtype const & a, dtype const & b) {
|
|
+ return a == b;
|
|
+}
|
|
+
|
|
namespace
|
|
{
|
|
|