Add regression test for NaimaModel.evaluate_error()
@@ -589,8 +589,21 @@ class TestSpectralModelErrorPropagation:
out = model.evaluate_error(0.1 * u.TeV)
assert_allclose(out.data, [1.548176e-10, 1.933612e-11], rtol=1e-3)
- def test_naima_model_error_proprgation(self):
- # Regression test for Naima model
- # https://github.com/gammapy/gammapy/issues/2190
- # TODO: implement test case. Move to Naima model tests!
- pass
+
+@requires_dependency("naima")
+def test_naima_model_error_propagation():
+ import naima
+
+ particle_distribution = naima.models.PowerLaw(
+ amplitude=2e33 / u.eV, e_0=10 * u.TeV, alpha=2.5
+ )
+
+ radiative_model = naima.radiative.PionDecay(
+ particle_distribution, nh=1 * u.cm ** -3
+ )
+ model = NaimaSpectralModel(radiative_model)
+ model.parameters.set_error(amplitude=0.1 * model.amplitude.value)
+
+ out = model.evaluate_error(1 * u.TeV)
+ assert_allclose(out.data, [5.266068e-13, 0], rtol=1e-3)
+
