Commit Graph

4 Commits

Author SHA1 Message Date
Wenzel Jakob 369e9b3937 Permit creation of NumPy arrays with a "base" object that owns the data
This patch adds an extra base handle parameter to most ``py::array`` and
``py::array_t<>`` constructors. If specified along with a pointer to
data, the base object will be registered within NumPy, which increases
the base's reference count. This feature is useful to create shallow
copies of C++ or Python arrays while ensuring that the owners of the
underlying can't be garbage collected while referenced by NumPy.

The commit also adds a simple test function involving a ``wrap()``
function that creates shallow copies of various N-D arrays.
2016-10-13 01:03:40 +02:00
Wenzel Jakob 43f6aa6846 added numpy test (minor): check that 'strides' is respected even when creating new arrays
- This actually works with no changes, I just wasn't 100% convinced and
  decided to write a test to see if it's true.
2016-10-12 23:34:13 +02:00
Ivan Smirnov aca6bcaea5 Add tests for array data access /index methods 2016-09-10 16:42:17 +01:00
Ivan Smirnov 91b3d681ad Expose some dtype/array attributes via NumPy C API 2016-09-10 16:24:00 +01:00