Commit a63d93ba by Johan Mabille

constructor fix

parent c209323c
...@@ -201,6 +201,7 @@ struct buffer_info { ...@@ -201,6 +201,7 @@ struct buffer_info {
std::vector<size_t> shape; // Shape of the tensor (1 entry per dimension) std::vector<size_t> shape; // Shape of the tensor (1 entry per dimension)
std::vector<size_t> strides; // Number of entries between adjacent entries (for each per dimension) std::vector<size_t> strides; // Number of entries between adjacent entries (for each per dimension)
buffer_info() : ptr(nullptr), view(nullptr) {}
buffer_info(void *ptr, size_t itemsize, const std::string &format, int ndim, buffer_info(void *ptr, size_t itemsize, const std::string &format, int ndim,
const std::vector<size_t> &shape, const std::vector<size_t> &strides) const std::vector<size_t> &shape, const std::vector<size_t> &strides)
: ptr(ptr), itemsize(itemsize), size(1), format(format), : ptr(ptr), itemsize(itemsize), size(1), format(format),
......
...@@ -128,6 +128,7 @@ template <typename T, int ExtraFlags = 0> class array_t : public array { ...@@ -128,6 +128,7 @@ template <typename T, int ExtraFlags = 0> class array_t : public array {
public: public:
PYBIND11_OBJECT_CVT(array_t, array, is_non_null, m_ptr = ensure(m_ptr)); PYBIND11_OBJECT_CVT(array_t, array, is_non_null, m_ptr = ensure(m_ptr));
array_t() : array() { } array_t() : array() { }
array_t(const buffer_info& info) : array(info) {}
static bool is_non_null(PyObject *ptr) { return ptr != nullptr; } static bool is_non_null(PyObject *ptr) { return ptr != nullptr; }
static PyObject *ensure(PyObject *ptr) { static PyObject *ensure(PyObject *ptr) {
if (ptr == nullptr) if (ptr == nullptr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment