Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

3 dots and a comma in NumPy array display

Tags:

numpy

I was printing one list of values in Python, when I got this:

[ 0.00020885  0.00021386  0.0002141  ...,  0.0501399   0.12051606
  0.12359095]

What is the problem here? The list should have at least size 20. What happened to the elements shown as ...?

like image 794
Ricky Robinson Avatar asked Jul 05 '12 14:07

Ricky Robinson


People also ask

What does three dots mean in NumPy?

If you work with NumPy, then you can use ... to abbreviate your slicing syntax by replacing variable-length dimensions with the Ellipsis object. With the clutter-free syntax that the three dots provide, you can make your code more readable.

Why does my NumPy array have commas?

The trailing comma distinguishes a one-element tuple from a parenthesized n . In a dimension entry, instructs NumPy to choose the length that will keep the total number of array elements the same.

What is Ellipsis in NumPy?

The ellipsis is used in numpy to slice higher-dimensional data structures. It's designed to mean at this point, insert as many full slices ( : ) to extend the multi-dimensional slice to all dimensions.


1 Answers

The problem is that you are not printing a Python list, but a NumPy array. NumPy output can be configured using numpy.set_printoptions().

Data types matter. If you wonder about the behaviour of some object, first check its type.

like image 183
Sven Marnach Avatar answered Oct 18 '22 11:10

Sven Marnach