Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wps2n committed Jan 21, 2025
1 parent 7d40e7d commit be6502c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
14 changes: 14 additions & 0 deletions tests/test_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,26 @@ def test_from_yaml(observatory):
with pytest.raises(ValueError, match="yaml_file must be a string filepath"):
Observation.from_yaml(3)

def test_huge_time_per_day_size(observatory: Observatory, wd):
tpd = 25 * units.hour if wd=="earth" else 682.5 * units.hour
with pytest.raises(ValueError, match="time_per_day should be between 0 and"):
Observation(observatory=observatory, time_per_day=tpd)

def test_huge_track_size(observatory: Observatory, wd):
tck = 25 * units.hour if wd=="earth" else 682.5 * units.hour
with pytest.raises(ValueError, match="track should be between 0 and"):
Observation(observatory=observatory, track=tck)


def test_huge_lst_bin_size(observatory: Observatory, wd):
lst = 23 * units.hour if wd=="earth" else 627.9 * units.hour
with pytest.raises(ValueError, match="lst_bin_size must be <= time_per_day"):
Observation(observatory=observatory, lst_bin_size=lst)

lst2 = 25 * units.hour if wd=="earth" else 682.5 * units.hour
with pytest.raises(ValueError, match="lst_bin_size should be between 0 and"):
Observation(observatory=observatory, lst_bin_size=lst2)


def test_huge_integration_time(observatory: Observatory):
with pytest.raises(ValueError, match="integration_time must be <= lst_bin_size"):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def test_sensitivity_optimistic(observation):
ps = PowerSpectrum(observation=observation, foreground_model="optimistic")
assert ps.horizon_limit(10.0) > ps.horizon_limit(5.0)

def test_sensitivity_foreground_free(observation):
ps = PowerSpectrum(observation=observation, foreground_model="foreground_free")
assert ps.horizon_limit(10.0) == 0

def test_infs_in_trms(observation):
# default dumb layout should have lots of infs..
Expand Down
15 changes: 14 additions & 1 deletion tests/test_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pytest

from py21cmsense.theory import EOS2021, EOS2016Bright, EOS2016Faint, Legacy21cmFAST
from py21cmsense.theory import EOS2021, EOS2016Bright, EOS2016Faint, Legacy21cmFAST, FarViewModel


def test_eos_extrapolation():
Expand Down Expand Up @@ -38,3 +38,16 @@ def test_eos_2016():
bright = EOS2016Bright()

assert faint.delta_squared(9.1, 1.0) != bright.delta_squared(9.1, 1.0)

def test_FarView():
theory = FarViewModel()
assert theory.delta_squared(29.6, 1.0) == theory.delta_squared(30.4, 1.0)

with pytest.warns(UserWarning, match="Theory power corresponds to z=30, not z"):
theory.delta_squared(1.0, 1.0)

with pytest.warns(UserWarning, match="Extrapolating above the simulated theoretical k"):
theory.delta_squared(30, np.array([0.1, 1e6]))

with pytest.warns(UserWarning, match="Extrapolating below the simulated theoretical k"):
theory.delta_squared(30, np.array([0.0001, 0.1]))

0 comments on commit be6502c

Please sign in to comment.