Skip to content Skip to sidebar Skip to footer

What Is The Difference Between The `slice` (:) And The `ellipsis` (...) Operators In `numpy`?

I came across a code where the author have used the ellipsis operator (e.g., [..., 1]) with numpy array instead of a slice operator (e.g., [:, 1]) to get arrays part. My research o

Solution 1:

The motivations behind the two are completely different.

  • The ellipsis means "all the other dimensions (which I can't be bothered to enumerate or am unsure or don't care how many there are) in their entirety"

  • the slice means "the subset of the current dimension as specified by the starting and ending indices (and stride)".


Post a Comment for "What Is The Difference Between The `slice` (:) And The `ellipsis` (...) Operators In `numpy`?"