-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start testing suite (io.read_yaml and spectral module) * formatting and better asserting * fix assertion
- Loading branch information
1 parent
13afd29
commit f216460
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Testing suite for iact-estimator.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
def test_read_yaml(tmp_path): | ||
from ..io import read_yaml | ||
|
||
test_file = tmp_path / "test_file.yml" | ||
test_file.write_text( | ||
""" | ||
a: 1 | ||
b: | ||
c: 3 | ||
d: 4 | ||
""" | ||
) | ||
|
||
data = read_yaml(test_file) | ||
|
||
assert data["a"] == 1 | ||
assert data["b"]["c"] == 3 | ||
assert data["b"]["d"] == 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Test cases automatically generated by Pynguin (https://www.pynguin.eu). | ||
# Please check them before you use them. | ||
|
||
import astropy.units as u | ||
import numpy as np | ||
|
||
|
||
def test_crab_nebula_spectrum(): | ||
from ..spectral import crab_nebula_spectrum | ||
|
||
spectrum = crab_nebula_spectrum() | ||
|
||
assert spectrum.amplitude.unit == u.Unit("TeV^-1 s^-1 cm^-2") | ||
assert spectrum.reference.unit == u.TeV | ||
|
||
assert np.allclose( | ||
[ | ||
spectrum.alpha.value, | ||
spectrum.beta.value, | ||
spectrum.amplitude.value, | ||
spectrum.reference.value, | ||
], | ||
[2.51, 0.21 / np.log(10), 3.39e-11, 1.0], | ||
) |