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

Andras Deak deak.andris at gmail.com
Wed Oct 18 14:31:54 EDT 2017


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


More information about the NumPy-Discussion mailing list