python / psf-infra-meta

Meta-repository for PSF backed or managed systems. Created mainly for the issue tracker :)
10 stars 9 forks source link

numpy ndarray convert function tolist() #147

Open YoungBaymax opened 9 months ago

YoungBaymax commented 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)

bswck commented 5 months ago

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.