'Check that raising LogUnits to some power is only possible when the
physical unit is dimensionless, and that conversion is turned off when
the resulting logarithmic unit (such as mag**2) is incompatible.'

@pytest.mark.parametrize(u'power', (2, 0.5, 1, 0))
def test_raise_to_power(self, power):

    lu1 = u.mag(u.Jy)
    if (power == 0):
        assert ((lu1 ** power) == u.dimensionless_unscaled)
    elif (power == 1):
        assert ((lu1 ** power) == lu1)
    else:
        with pytest.raises(u.UnitsError):
            (lu1 ** power)
    lu2 = u.mag(u.dimensionless_unscaled)
    t = (lu2 ** power)
    if (power == 0):
        assert (t == u.dimensionless_unscaled)
    elif (power == 1):
        assert (t == lu2)
    else:
        assert (not isinstance(t, type(lu2)))
        assert (t == (lu2.function_unit ** power))
        t2 = (t ** (1.0 / power))
        assert (t2 == lu2.function_unit)
        with u.set_enabled_equivalencies(u.logarithmic()):
            assert_allclose(t2.to(u.dimensionless_unscaled, np.arange(3.0)), lu2.to(lu2.physical_unit, np.arange(3.0)))
