> it's a bit inelegant I agree but this case happens due to the array2d when y.ndim == 1 as input.

OK, but then we need to test and store the shape of y before the call to
array2d.