Super Squeeze

two related questions.

  1. If I have an array with many size 1 dimensions why doesn’t squeeze(arr) find the one dimensions and remove them automatically?

  2. And given it doesn’t what is the best way to make this behavior? I do squeeze(arr, tuple(find(size(test) .== 1)...)) which makes me shudder.

2 Likes

I’m not sure why squeeze doesn’t have the option to remove all dimensions of length 1 automatically. I think we should define a squeeze(A) which removes all axes that have length one while keeping the currently definition of squeeze(A, dim) to drop specific ones.

I think the reasoning was that squeeze(arr) is type-unstable, so it’s best to avoid functions that have fundamentally poor performance.

Also see discussions in PRs here #22000 and #23500