replace MapAxis input, requested changes
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
import numpy as np
-from numpy.testing import assert_allclose, assert_almost_equal
+from numpy.testing import assert_allclose
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.units import Unit
@@ -393,7 +393,7 @@ def test_psfmap_from_gauss():
sigma = (np.arange(energy.shape[0])*0.1 +0.1)*u.deg
# with energy-dependent sigma
- psfmap = PSFMap.from_gauss(energy, rad, sigma)
+ psfmap = PSFMap.from_gauss(energy_axis, rad_axis, sigma)
assert psfmap.psf_map.geom.axes[0] == rad_axis
assert psfmap.psf_map.geom.axes[1] == energy_axis
assert psfmap.psf_map.unit == Unit("sr-1")
@@ -402,17 +402,17 @@ def test_psfmap_from_gauss():
psfmap.get_energy_dependent_table_psf().containment_radius(1*u.TeV)[0],
psfmap.containment_radius_map(1*u.TeV).data[0][0]*u.deg
)
- assert_almost_equal(
+ assert_allclose(
psfmap.containment_radius_map(energy[3], 0.68).data[0][0]/sigma[3].value,
- 1.5095921854516636, decimal=2
+ 1.51, atol=1e-3
)
- assert_almost_equal(
+ assert_allclose(
psfmap.containment_radius_map(energy[3], 0.95).data[0][0]/sigma[3].value,
- 2.4477468306808161, decimal=2
+ 2.45,atol=1e-3
)
# with constant sigma
- psfmap1 = PSFMap.from_gauss(energy, rad, sigma[0])
+ psfmap1 = PSFMap.from_gauss(energy_axis, rad_axis, sigma[0])
assert psfmap1.psf_map.geom.axes[0] == rad_axis
assert psfmap1.psf_map.geom.axes[1] == energy_axis
assert psfmap1.psf_map.unit == Unit("sr-1")
@@ -429,4 +429,5 @@ def test_psfmap_from_gauss():
# test that it won't work with different number of sigmas and energies
with pytest.raises(AssertionError):
- psfmap2 = PSFMap.from_gauss(energy, rad, sigma[:3])
\ No newline at end of file
+ psfmap2 = PSFMap.from_gauss(energy_axis, rad_axis, sigma[:3])
+
\ No newline at end of file
