Bugfix: pass struct size as itemsize to descriptor

Without this, partially bound structs will have incorrect itemsize.
This commit is contained in:
Ivan Smirnov 2016-07-03 10:22:40 +01:00
parent eeb4c043f9
commit 13022f1b8c

View File

@ -266,6 +266,7 @@ struct npy_format_descriptor<T, typename std::enable_if<is_pod_struct<T>::value>
args["names"] = names;
args["offsets"] = offsets;
args["formats"] = formats;
args["itemsize"] = int_(sizeof(T));
// This is essentially the same as calling np.dtype() constructor in Python and passing
// it a dict of the form {'names': ..., 'formats': ..., 'offsets': ...}.
if (!api.PyArray_DescrConverter_(args.release().ptr(), &dtype_()) || !dtype_())