[Numpy-discussion] different values for ndarray when printed with or without

Nissim Derdiger NissimD at elspec-ltd.com
Thu Oct 19 01:36:12 EDT 2017


Nice catch Andre!!!
np.set_printoptions(suppress=True) solved it.
Thanks!!!


Message: 4
Date: Wed, 18 Oct 2017 20:31:54 +0200
From: Andras Deak <deak.andris at gmail.com>
To: Discussion of Numerical Python <numpy-discussion at python.org>
Subject: Re: [Numpy-discussion] different values for ndarray when
	printed with or without
Message-ID:
	<CAMEWA4Pwbx611gAwOjQc8HEu2NSS3-uGaAjhAmwoCQtNFTiooQ at mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"

On Wed, Oct 18, 2017 at 7:30 PM, Nissim Derdiger <NissimD at elspec-ltd.com> wrote:
> 3. difference between values are:
>         [  2.25699615e+02   5.51561475e-01   3.81394744e+00   1.03807904e-01]
>         Instead of:
>         [225.69961547851562, 0.5515614748001099, 3.8139474391937256, 
> 0.10380790382623672]

The behaviour you're describing sounds like a matter of pretty-printing. Numpy uses a shortened format for printing numeric values by default. When you convert to a list, you leave numpy behind and you get the native python behaviour. If you want to control how this pretty-printing happens in numpy, take a close look at
numpy.set_printoptions:
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.set_printoptions.html
.
Now, I still don't see how taking a trivial view of your array would affect this printing, but I believe your values themselves are identical (i.e. correct) in both cases, and they are only displayed differently. If you were to do further computations with your arrays, the results would be the same.
Regards,

Andr?s


------------------------------

Subject: Digest Footer

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion at python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


------------------------------

End of NumPy-Discussion Digest, Vol 133, Issue 14
*************************************************


More information about the NumPy-Discussion mailing list