BUG : changed logic on converting to scalar

Instead of checking on size == 1 check on ndim == 0.  This matters for `tt.sum()` (should covert to scalar) vs `tt.sum(keepdims=True)` (should not convert to scalar).