Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bae42a8

Browse files
committed
copy all array_view members in copy constructor
1 parent a220e1f commit bae42a8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/numpy_cpp.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,11 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
369369

370370
array_view(const array_view &other, bool contiguous = false) : m_arr(NULL), m_data(NULL)
371371
{
372-
if (!set((PyObject *)other.m_arr)) {
373-
throw py::exception();
374-
}
372+
m_arr = other.m_arr;
373+
Py_INCREF(m_arr);
374+
m_data = other.m_data;
375+
m_shape = other.m_shape;
376+
m_strides = other.m_strides;
375377
}
376378

377379
array_view(PyArrayObject *arr, char *data, npy_intp *shape, npy_intp *strides)

0 commit comments

Comments
 (0)