| Total Complexity | 2 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | from asgardpy.analysis import AsgardpyAnalysis |
||
| 4 | from asgardpy.stats import fetch_pivot_energy |
||
| 5 | |||
| 6 | |||
| 7 | @pytest.mark.test_data |
||
| 8 | def test_get_pivot_energy(gpy_hess_magic): |
||
| 9 | """ |
||
| 10 | Check the pivot energy for given fit model on a dataset. |
||
| 11 | """ |
||
| 12 | analysis = AsgardpyAnalysis(gpy_hess_magic) |
||
| 13 | |||
| 14 | analysis.run(["datasets-3d", "datasets-1d"]) |
||
| 15 | |||
| 16 | e_ref = fetch_pivot_energy(analysis) |
||
| 17 | |||
| 18 | assert e_ref.value == 0.20085434771049843 |
||
| 19 | |||
| 20 | |||
| 21 | @pytest.mark.test_data |
||
| 22 | def test_get_pivot_energy_from_start(gpy_hess_magic): |
||
| 23 | """ |
||
| 24 | Check the pivot energy for given fit model on a dataset from the start of |
||
| 25 | the AsgardpyAnalysis object. Test using the custom SpectralModel of ECLP |
||
| 26 | and without any associated EBL absorption model. |
||
| 27 | """ |
||
| 28 | from asgardpy.config.generator import get_model_template |
||
| 29 | |||
| 30 | new_model = get_model_template("eclp") |
||
| 31 | gpy_hess_magic.target.models_file = new_model |
||
| 32 | gpy_hess_magic.target.components[0].spectral.ebl_abs.reference = "" |
||
| 33 | |||
| 34 | analysis = AsgardpyAnalysis(gpy_hess_magic) |
||
| 35 | |||
| 36 | e_ref = fetch_pivot_energy(analysis) |
||
| 37 | |||
| 38 | assert e_ref.value == 0.030128153004345924 |
||
| 39 |