Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

tuple to numpy, data accuracy

When I convert tuple to numpy,there is a problem of data accuracy.Code like this:

import numpy as np
a=(0.547693688614422, -0.7854270889025808, 0.6267478456110592)
print(a)
print(type(a))
tmp=np.array(a)
print(tmp)

The result like this:

(0.547693688614422, -0.7854270889025808, 0.6267478456110592)
<class 'tuple'>
[ 0.54769369 -0.78542709  0.62674785]

please help.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

One way is to set this:

In [1039]: np.set_printoptions(precision=20)

In [1041]: tmp=np.array(a)

In [1042]: tmp
Out[1042]: array([ 0.547693688614422 , -0.7854270889025808,  0.6267478456110592])

In [1043]: tmp.dtype
Out[1043]: dtype('float64')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading