Skip to content
Snippets Groups Projects
Commit 1ee9a139 authored by Rob Moss's avatar Rob Moss
Browse files

Simplify pypfilt.state.repack

We can use numpy.lib.recfunctions.structured_to_unstructured and avoid
raising exceptions under certain conditions, such as the ValueError "To
change to a dtype of a different size, the array must be C-contiguous".
parent 38bebb9a
No related branches found
No related tags found
No related merge requests found
......@@ -202,6 +202,5 @@ def repack(svec, astype=float):
msg = 'Fields {} are not compatible with type {}'
raise ValueError(msg.format(', '.join(incompat), astype))
out = numpy.lib.recfunctions.repack_fields(svec).view(astype)
new_shape = (*svec.shape, -1)
return np.squeeze(out.reshape(new_shape))
out = numpy.lib.recfunctions.structured_to_unstructured(svec)
return out.view(astype)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment