mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 23:22:01 +00:00
Various cleanup
This commit is contained in:
parent
8fa09cb871
commit
8f2f7cd61c
@ -138,21 +138,19 @@ public:
|
|||||||
// constructor seems to then consume them, so we don't need to strip them ourselves
|
// constructor seems to then consume them, so we don't need to strip them ourselves
|
||||||
auto numpy_internal = module::import("numpy.core._internal");
|
auto numpy_internal = module::import("numpy.core._internal");
|
||||||
auto dtype_from_fmt = (object) numpy_internal.attr("_dtype_from_pep3118");
|
auto dtype_from_fmt = (object) numpy_internal.attr("_dtype_from_pep3118");
|
||||||
auto dtype = dtype_from_fmt(pybind11::str(info.format));
|
auto dtype = strip_padding_fields(dtype_from_fmt(pybind11::str(info.format)));
|
||||||
auto dtype2 = strip_padding_fields(dtype);
|
|
||||||
|
|
||||||
object tmp(api.PyArray_NewFromDescr_(
|
object tmp(api.PyArray_NewFromDescr_(
|
||||||
api.PyArray_Type_, dtype2.release().ptr(), (int) info.ndim, (Py_intptr_t *) &info.shape[0],
|
api.PyArray_Type_, dtype.release().ptr(), (int) info.ndim, (Py_intptr_t *) &info.shape[0],
|
||||||
(Py_intptr_t *) &info.strides[0], info.ptr, 0, nullptr), false);
|
(Py_intptr_t *) &info.strides[0], info.ptr, 0, nullptr), false);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
pybind11_fail("NumPy: unable to create array!");
|
pybind11_fail("NumPy: unable to create array!");
|
||||||
if (info.ptr)
|
if (info.ptr)
|
||||||
tmp = object(api.PyArray_NewCopy_(tmp.ptr(), -1 /* any order */), false);
|
tmp = object(api.PyArray_NewCopy_(tmp.ptr(), -1 /* any order */), false);
|
||||||
m_ptr = tmp.release().ptr();
|
m_ptr = tmp.release().ptr();
|
||||||
auto d = (object) this->attr("dtype");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected:
|
protected:
|
||||||
static API &lookup_api() {
|
static API &lookup_api() {
|
||||||
static API api = API::lookup();
|
static API api = API::lookup();
|
||||||
return api;
|
return api;
|
||||||
|
Loading…
Reference in New Issue
Block a user