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

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

    lq = u.Magnitude((np.arange(1.0, 4.0) * u.Jy))
    if (power == 0):
        assert np.all(((lq ** power) == 1.0))
    elif (power == 1):
        assert np.all(((lq ** power) == lq))
    else:
        with pytest.raises(u.UnitsError):
            (lq ** power)
    lq2 = u.Magnitude(np.arange(10.0))
    t = (lq2 ** power)
    if (power == 0):
        assert (t.unit is u.dimensionless_unscaled)
        assert np.all((t.value == 1.0))
    elif (power == 1):
        assert np.all((t == lq2))
    else:
        assert (not isinstance(t, type(lq2)))
        assert (t.unit == (lq2.unit.function_unit ** power))
        with u.set_enabled_equivalencies(u.logarithmic()):
            with pytest.raises(u.UnitsError):
                t.to(u.dimensionless_unscaled)
