Use correct shape for 1d numpy arrays

This commit is contained in:
Richard Berger
2021-05-05 17:47:25 -04:00
parent 69d081cd6a
commit 51200de45d

View File

@ -293,7 +293,11 @@ class numpy_wrapper:
ptr = cast(raw_ptr[0], POINTER(c_int_type * nelem * dim)) ptr = cast(raw_ptr[0], POINTER(c_int_type * nelem * dim))
a = np.frombuffer(ptr.contents, dtype=np_int_type) a = np.frombuffer(ptr.contents, dtype=np_int_type)
a.shape = (nelem, dim)
if dim > 1:
a.shape = (nelem, dim)
else:
a.shape = (nelem)
return a return a
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -306,7 +310,11 @@ class numpy_wrapper:
ptr = cast(raw_ptr[0], POINTER(c_double * nelem * dim)) ptr = cast(raw_ptr[0], POINTER(c_double * nelem * dim))
a = np.frombuffer(ptr.contents) a = np.frombuffer(ptr.contents)
a.shape = (nelem, dim)
if dim > 1:
a.shape = (nelem, dim)
else:
a.shape = (nelem)
return a return a
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------