-
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
005cc12
commit b1f869b
Showing
4 changed files
with
74 additions
and
42 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
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
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
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,60 @@ | ||
import astropy.units as u | ||
import numpy as np | ||
import pytest | ||
|
||
from tardis.spectrum.luminosity import ( | ||
calculate_filtered_luminosity, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"packet_nu, packet_luminosity, luminosity_nu_start, luminosity_nu_end, expected", | ||
[ | ||
# All frequencies within the range | ||
( | ||
np.array([1, 2, 3]) * u.Hz, | ||
np.array([10, 20, 30]) * u.erg / u.s, | ||
0 * u.Hz, | ||
4 * u.Hz, | ||
60 * u.erg / u.s, | ||
), | ||
# All frequencies outside the range | ||
( | ||
np.array([1, 2, 3]) * u.Hz, | ||
np.array([10, 20, 30]) * u.erg / u.s, | ||
4 * u.Hz, | ||
5 * u.Hz, | ||
0 * u.erg / u.s, | ||
), | ||
# Mix of frequencies within and outside the range | ||
( | ||
np.array([1, 2, 3, 4]) * u.Hz, | ||
np.array([10, 20, 30, 40]) * u.erg / u.s, | ||
2 * u.Hz, | ||
4 * u.Hz, | ||
30 * u.erg / u.s, | ||
), | ||
# Edge case: Frequencies exactly on the boundary | ||
( | ||
np.array([1, 2, 3, 4]) * u.Hz, | ||
np.array([10, 20, 30, 40]) * u.erg / u.s, | ||
2 * u.Hz, | ||
3 * u.Hz, | ||
0 * u.erg / u.s, | ||
), | ||
], | ||
) | ||
def test_calculate_filtered_luminosity( | ||
packet_nu, | ||
packet_luminosity, | ||
luminosity_nu_start, | ||
luminosity_nu_end, | ||
expected, | ||
): | ||
result = calculate_filtered_luminosity( | ||
packet_nu, | ||
packet_luminosity, | ||
luminosity_nu_start, | ||
luminosity_nu_end, | ||
) | ||
assert result == expected |