2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 06:02:14 +00:00

Merge pull request #17 from awishnick/master

Added astype to ndarray
This commit is contained in:
Jim Bosch
2013-01-18 13:46:42 -08:00
3 changed files with 16 additions and 0 deletions

View File

@@ -79,6 +79,9 @@ public:
/// @brief Return a view of the scalar with the given dtype.
ndarray view(dtype const & dt) const;
/// @brief Copy the array, cast to a specified type.
ndarray astype(dtype const & dt) const;
/// @brief Copy the scalar (deep for all non-object fields).
ndarray copy() const;

View File

@@ -37,6 +37,7 @@ synopsis
};
ndarray view(dtype const & dt) const;
ndarray astype(dtype const & dt) const;
ndarray copy() const;
int const shape(int n) const;
int const strides(int n) const;
@@ -92,6 +93,12 @@ constructors
:Returns: new ndarray with old ndarray data cast as supplied dtype
::
ndarray astype(dtype const & dt) const;
:Returns: new ndarray with old ndarray data converted to supplied dtype
::
ndarray copy() const;

View File

@@ -146,6 +146,12 @@ ndarray ndarray::view(dtype const & dt) const
return ndarray(python::detail::new_reference
(PyObject_CallMethod(this->ptr(), const_cast<char*>("view"), const_cast<char*>("O"), dt.ptr())));
}
ndarray ndarray::astype(dtype const & dt) const
{
return ndarray(python::detail::new_reference
(PyObject_CallMethod(this->ptr(), const_cast<char*>("astype"), const_cast<char*>("O"), dt.ptr())));
}
ndarray ndarray::copy() const
{