On Monday, September 8, 2014 1:28:46 PM UTC-5, Ethan Anderes wrote:
>
> Ok, if I’m reading that comment right, the problem is
>
>
> julia> squeeze(rand(1))
> 0-dimensional Array{Float64,0}:
> 0.721012
>
> but isn’t that just a bug with my implementation? Or is type stability the
> issue. For example, squeeze([5]) == 5 but squeeze([5 5]) == [5,5] doesn’t
> seem type stable.
>
Not quite. These problems with singleton dimensions appearing in unexpected
places often occur when working with high-dimensional arrays. I'm
unfortunately short on real-world examples I can readily share, but I've
definitely run into this before: a well-intentioned squeeze() ends up
collapsing something that started as an (n x m x p x 1) array which you
expected to become a (n x m x p) array into an (n x p) array because m
happened to be 1. Now you go to slice the resulting array and things aren't
where you thought you'd find them, and stuff breaks in confusing ways.