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.

On Monday, September 8, 2014 11:17:25 AM UTC-7, Patrick O’Leary wrote:

On Monday, September 8, 2014 1:13:09 PM UTC-5, Ethan Anderes wrote:
>>
>> I’m a bit surprised we don’t have a method for squeeze that works like 
>>
>> function Base.squeeze(A) 
>>   sqzindx = find(collect(size(A)) .== 1)
>>   if isempty(sqzindx)
>>     return A
>>   else
>>     return squeeze(A, tuple(sqzindx...))
>>   end
>> end
>>
>> which simply squeezes out all singleton dimensions.
>>
> Stefan's answer below summarizes why this isn't in Base.
>
>
> https://groups.google.com/forum/#!searchin/julia-users/squeeze/julia-users/QQqVbyTiiPg/_VE3HgKIGu0J
>
​

Reply via email to