mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 04:22:16 +00:00
Require NumPy 1.7 API.
This commit is contained in:
@@ -75,4 +75,6 @@
|
||||
#include <boost/config/auto_link.hpp>
|
||||
#endif // auto-linking disabled
|
||||
|
||||
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
||||
|
||||
#endif // CONFIG_NUMPY20170215_H_
|
||||
|
||||
@@ -13,9 +13,8 @@
|
||||
*/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/numpy/numpy_object_mgr_traits.hpp>
|
||||
#include <boost/python/numpy/config.hpp>
|
||||
|
||||
#include <boost/python/numpy/numpy_object_mgr_traits.hpp>
|
||||
#include <boost/mpl/for_each.hpp>
|
||||
#include <boost/type_traits/add_pointer.hpp>
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/numpy/config.hpp>
|
||||
#ifdef BOOST_PYTHON_NUMPY_INTERNAL
|
||||
#define NO_IMPORT_ARRAY
|
||||
#define NO_IMPORT_UFUNC
|
||||
|
||||
@@ -22,20 +22,20 @@ namespace detail
|
||||
ndarray::bitflag numpy_to_bitflag(int const f)
|
||||
{
|
||||
ndarray::bitflag r = ndarray::NONE;
|
||||
if (f & NPY_C_CONTIGUOUS) r = (r | ndarray::C_CONTIGUOUS);
|
||||
if (f & NPY_F_CONTIGUOUS) r = (r | ndarray::F_CONTIGUOUS);
|
||||
if (f & NPY_ALIGNED) r = (r | ndarray::ALIGNED);
|
||||
if (f & NPY_WRITEABLE) r = (r | ndarray::WRITEABLE);
|
||||
if (f & NPY_ARRAY_C_CONTIGUOUS) r = (r | ndarray::C_CONTIGUOUS);
|
||||
if (f & NPY_ARRAY_F_CONTIGUOUS) r = (r | ndarray::F_CONTIGUOUS);
|
||||
if (f & NPY_ARRAY_ALIGNED) r = (r | ndarray::ALIGNED);
|
||||
if (f & NPY_ARRAY_WRITEABLE) r = (r | ndarray::WRITEABLE);
|
||||
return r;
|
||||
}
|
||||
|
||||
int bitflag_to_numpy(ndarray::bitflag f)
|
||||
{
|
||||
int r = 0;
|
||||
if (f & ndarray::C_CONTIGUOUS) r |= NPY_C_CONTIGUOUS;
|
||||
if (f & ndarray::F_CONTIGUOUS) r |= NPY_F_CONTIGUOUS;
|
||||
if (f & ndarray::ALIGNED) r |= NPY_ALIGNED;
|
||||
if (f & ndarray::WRITEABLE) r |= NPY_WRITEABLE;
|
||||
if (f & ndarray::C_CONTIGUOUS) r |= NPY_ARRAY_C_CONTIGUOUS;
|
||||
if (f & ndarray::F_CONTIGUOUS) r |= NPY_ARRAY_F_CONTIGUOUS;
|
||||
if (f & ndarray::ALIGNED) r |= NPY_ARRAY_ALIGNED;
|
||||
if (f & ndarray::WRITEABLE) r |= NPY_ARRAY_WRITEABLE;
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -119,10 +119,10 @@ ndarray from_data_impl(void * data,
|
||||
}
|
||||
int itemsize = dt.get_itemsize();
|
||||
int flags = 0;
|
||||
if (writeable) flags |= NPY_WRITEABLE;
|
||||
if (is_c_contiguous(shape, strides, itemsize)) flags |= NPY_C_CONTIGUOUS;
|
||||
if (is_f_contiguous(shape, strides, itemsize)) flags |= NPY_F_CONTIGUOUS;
|
||||
if (is_aligned(strides, itemsize)) flags |= NPY_ALIGNED;
|
||||
if (writeable) flags |= NPY_ARRAY_WRITEABLE;
|
||||
if (is_c_contiguous(shape, strides, itemsize)) flags |= NPY_ARRAY_C_CONTIGUOUS;
|
||||
if (is_f_contiguous(shape, strides, itemsize)) flags |= NPY_ARRAY_F_CONTIGUOUS;
|
||||
if (is_aligned(strides, itemsize)) flags |= NPY_ARRAY_ALIGNED;
|
||||
ndarray r(python::detail::new_reference
|
||||
(PyArray_NewFromDescr(&PyArray_Type,
|
||||
incref_dtype(dt),
|
||||
@@ -243,13 +243,13 @@ ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt)
|
||||
ndarray array(python::object const & obj)
|
||||
{
|
||||
return ndarray(python::detail::new_reference
|
||||
(PyArray_FromAny(obj.ptr(), NULL, 0, 0, NPY_ENSUREARRAY, NULL)));
|
||||
(PyArray_FromAny(obj.ptr(), NULL, 0, 0, NPY_ARRAY_ENSUREARRAY, NULL)));
|
||||
}
|
||||
|
||||
ndarray array(python::object const & obj, dtype const & dt)
|
||||
{
|
||||
return ndarray(python::detail::new_reference
|
||||
(PyArray_FromAny(obj.ptr(), detail::incref_dtype(dt), 0, 0, NPY_ENSUREARRAY, NULL)));
|
||||
(PyArray_FromAny(obj.ptr(), detail::incref_dtype(dt), 0, 0, NPY_ARRAY_ENSUREARRAY, NULL)));
|
||||
}
|
||||
|
||||
ndarray from_object(python::object const & obj, dtype const & dt, int nd_min, int nd_max, ndarray::bitflag flags)
|
||||
|
||||
Reference in New Issue
Block a user