Passed
Pull Request — main (#160)
by Chaitanya
01:14
created

asgardpy.stats.tests.test_pivot_energy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_get_pivot_energy_from_start() 0 18 1
A test_get_pivot_energy() 0 12 1
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