Perhaps it is simpler to check here that ndim <= 2, and after the squeeze that it is == 1.