numpy: handle keepdims in reductions