np.frombuffer missing
SimonCraenen opened this issue · 4 comments
The np.frombuffer api appears to be missing.
I can use ndarray.tobytes to get a byte array but I can't find an api to go from a byte array back to an ndarray.
My current workaround looks like this:
ndarray a = np.ones((3, 3), dtype: np.Float32);
var abytes = a.tobytes(NumpyLib.NPY_ORDER.NPY_CORDER);
var afloatbytes = new float[abytes.Length / 4];
Buffer.BlockCopy(abytes, 0, afloatbytes, 0, abytes.Length);
ndarray c = np.array(afloatbytes, order: NumpyLib.NPY_ORDER.NPY_CORDER, copy: false).reshape((3, 3));
My apologies. I did not get an email on this issue. I am just seeing it today after looking at open issues on this project
Is this still an active problem for you?
My apologies as well for my late reply. The current workaround functions fine but it would be nice if it could be simplified with the np.frombuffer method to function similarly to how it would in python.
Good news. I went and implemented np.frombuffer shortly after that. It is in the latest release of numpydotnet.
thank you,
Kevin