mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 21:25:13 +00:00
Simplify npy_format_descriptor slightly
This commit is contained in:
parent
bdc9902041
commit
f5b166d042
@ -234,14 +234,12 @@ template <typename T> struct npy_format_descriptor
|
|||||||
array::API& api = array::lookup_api();
|
array::API& api = array::lookup_api();
|
||||||
auto args = py::dict();
|
auto args = py::dict();
|
||||||
py::list names { }, offsets { }, formats { };
|
py::list names { }, offsets { }, formats { };
|
||||||
std::vector<py::object> dtypes;
|
|
||||||
for (auto field : fields) {
|
for (auto field : fields) {
|
||||||
names.append(py::str(field.name));
|
|
||||||
offsets.append(py::int_(field.offset));
|
|
||||||
if (!field.descr)
|
if (!field.descr)
|
||||||
pybind11_fail("NumPy: unsupported field dtype");
|
pybind11_fail("NumPy: unsupported field dtype");
|
||||||
dtypes.emplace_back(field.descr, true);
|
names.append(py::str(field.name));
|
||||||
formats.append(dtypes.back());
|
offsets.append(py::int_(field.offset));
|
||||||
|
formats.append(object(field.descr, true));
|
||||||
}
|
}
|
||||||
args["names"] = names;
|
args["names"] = names;
|
||||||
args["offsets"] = offsets;
|
args["offsets"] = offsets;
|
||||||
|
Loading…
Reference in New Issue
Block a user