mirror of
https://github.com/boostorg/python.git
synced 2026-01-26 06:42:27 +00:00
replace non-constant array sizes with scoped_array
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#define BOOST_NUMPY_INTERNAL
|
||||
#include <boost/numpy/internal.hpp>
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -209,10 +210,10 @@ python::object ndarray::scalarize() const
|
||||
ndarray zeros(python::tuple const & shape, dtype const & dt)
|
||||
{
|
||||
int nd = len(shape);
|
||||
Py_intptr_t dims[nd];
|
||||
boost::scoped_array<Py_intptr_t> dims(new Py_intptr_t[nd]);
|
||||
for (int n=0; n<nd; ++n) dims[n] = python::extract<Py_intptr_t>(shape[n]);
|
||||
return ndarray(python::detail::new_reference
|
||||
(PyArray_Zeros(nd, dims, detail::incref_dtype(dt), 0)));
|
||||
(PyArray_Zeros(nd, dims.get(), detail::incref_dtype(dt), 0)));
|
||||
}
|
||||
|
||||
ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt)
|
||||
@@ -224,10 +225,10 @@ ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt)
|
||||
ndarray empty(python::tuple const & shape, dtype const & dt)
|
||||
{
|
||||
int nd = len(shape);
|
||||
Py_intptr_t dims[nd];
|
||||
boost::scoped_array<Py_intptr_t> dims(new Py_intptr_t[nd]);
|
||||
for (int n=0; n<nd; ++n) dims[n] = python::extract<Py_intptr_t>(shape[n]);
|
||||
return ndarray(python::detail::new_reference
|
||||
(PyArray_Empty(nd, dims, detail::incref_dtype(dt), 0)));
|
||||
(PyArray_Empty(nd, dims.get(), detail::incref_dtype(dt), 0)));
|
||||
}
|
||||
|
||||
ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt)
|
||||
|
||||
Reference in New Issue
Block a user