Open YoungBaymax opened 9 months ago
A float32 ndarray remained 3 decimal places can't be convert to a list properly by using tolist(), but float64 can.
import numpy as np a = np.random.random((5,)) a64 = a.astype(np.float64) out64 = np.around(a64, 3) outlist64 = out64.tolist() print(outlist64)
a32 = a.astype(np.float32) out32 = np.around(a32, 3) outlist32 = out.tolist() print(outlist32)
This is a meta-repository for PSF backed or managed systems.
If you are reporting a bug to get help/support, please consider opening a question on Stack Overflow.
A float32 ndarray remained 3 decimal places can't be convert to a list properly by using tolist(), but float64 can.
import numpy as np a = np.random.random((5,)) a64 = a.astype(np.float64) out64 = np.around(a64, 3) outlist64 = out64.tolist() print(outlist64)
a32 = a.astype(np.float32) out32 = np.around(a32, 3) outlist32 = out.tolist() print(outlist32)