Skip to content

Commit c4fe369

Browse files
committed
Require NumPy 1.7 API.
1 parent 7cfc470 commit c4fe369

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

include/boost/python/numpy/config.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,6 @@
7575
#include <boost/config/auto_link.hpp>
7676
#endif // auto-linking disabled
7777

78+
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
79+
7880
#endif // CONFIG_NUMPY20170215_H_

include/boost/python/numpy/dtype.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
*/
1414

1515
#include <boost/python.hpp>
16-
#include <boost/python/numpy/numpy_object_mgr_traits.hpp>
1716
#include <boost/python/numpy/config.hpp>
18-
17+
#include <boost/python/numpy/numpy_object_mgr_traits.hpp>
1918
#include <boost/mpl/for_each.hpp>
2019
#include <boost/type_traits/add_pointer.hpp>
2120

include/boost/python/numpy/internal.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#include <boost/python.hpp>
18+
#include <boost/python/numpy/config.hpp>
1819
#ifdef BOOST_PYTHON_NUMPY_INTERNAL
1920
#define NO_IMPORT_ARRAY
2021
#define NO_IMPORT_UFUNC

src/numpy/ndarray.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ namespace detail
2222
ndarray::bitflag numpy_to_bitflag(int const f)
2323
{
2424
ndarray::bitflag r = ndarray::NONE;
25-
if (f & NPY_C_CONTIGUOUS) r = (r | ndarray::C_CONTIGUOUS);
26-
if (f & NPY_F_CONTIGUOUS) r = (r | ndarray::F_CONTIGUOUS);
27-
if (f & NPY_ALIGNED) r = (r | ndarray::ALIGNED);
28-
if (f & NPY_WRITEABLE) r = (r | ndarray::WRITEABLE);
25+
if (f & NPY_ARRAY_C_CONTIGUOUS) r = (r | ndarray::C_CONTIGUOUS);
26+
if (f & NPY_ARRAY_F_CONTIGUOUS) r = (r | ndarray::F_CONTIGUOUS);
27+
if (f & NPY_ARRAY_ALIGNED) r = (r | ndarray::ALIGNED);
28+
if (f & NPY_ARRAY_WRITEABLE) r = (r | ndarray::WRITEABLE);
2929
return r;
3030
}
3131

3232
int bitflag_to_numpy(ndarray::bitflag f)
3333
{
3434
int r = 0;
35-
if (f & ndarray::C_CONTIGUOUS) r |= NPY_C_CONTIGUOUS;
36-
if (f & ndarray::F_CONTIGUOUS) r |= NPY_F_CONTIGUOUS;
37-
if (f & ndarray::ALIGNED) r |= NPY_ALIGNED;
38-
if (f & ndarray::WRITEABLE) r |= NPY_WRITEABLE;
35+
if (f & ndarray::C_CONTIGUOUS) r |= NPY_ARRAY_C_CONTIGUOUS;
36+
if (f & ndarray::F_CONTIGUOUS) r |= NPY_ARRAY_F_CONTIGUOUS;
37+
if (f & ndarray::ALIGNED) r |= NPY_ARRAY_ALIGNED;
38+
if (f & ndarray::WRITEABLE) r |= NPY_ARRAY_WRITEABLE;
3939
return r;
4040
}
4141

@@ -119,10 +119,10 @@ ndarray from_data_impl(void * data,
119119
}
120120
int itemsize = dt.get_itemsize();
121121
int flags = 0;
122-
if (writeable) flags |= NPY_WRITEABLE;
123-
if (is_c_contiguous(shape, strides, itemsize)) flags |= NPY_C_CONTIGUOUS;
124-
if (is_f_contiguous(shape, strides, itemsize)) flags |= NPY_F_CONTIGUOUS;
125-
if (is_aligned(strides, itemsize)) flags |= NPY_ALIGNED;
122+
if (writeable) flags |= NPY_ARRAY_WRITEABLE;
123+
if (is_c_contiguous(shape, strides, itemsize)) flags |= NPY_ARRAY_C_CONTIGUOUS;
124+
if (is_f_contiguous(shape, strides, itemsize)) flags |= NPY_ARRAY_F_CONTIGUOUS;
125+
if (is_aligned(strides, itemsize)) flags |= NPY_ARRAY_ALIGNED;
126126
ndarray r(python::detail::new_reference
127127
(PyArray_NewFromDescr(&PyArray_Type,
128128
incref_dtype(dt),
@@ -243,13 +243,13 @@ ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt)
243243
ndarray array(python::object const & obj)
244244
{
245245
return ndarray(python::detail::new_reference
246-
(PyArray_FromAny(obj.ptr(), NULL, 0, 0, NPY_ENSUREARRAY, NULL)));
246+
(PyArray_FromAny(obj.ptr(), NULL, 0, 0, NPY_ARRAY_ENSUREARRAY, NULL)));
247247
}
248248

249249
ndarray array(python::object const & obj, dtype const & dt)
250250
{
251251
return ndarray(python::detail::new_reference
252-
(PyArray_FromAny(obj.ptr(), detail::incref_dtype(dt), 0, 0, NPY_ENSUREARRAY, NULL)));
252+
(PyArray_FromAny(obj.ptr(), detail::incref_dtype(dt), 0, 0, NPY_ARRAY_ENSUREARRAY, NULL)));
253253
}
254254

255255
ndarray from_object(python::object const & obj, dtype const & dt, int nd_min, int nd_max, ndarray::bitflag flags)

0 commit comments

Comments
 (0)