Skip to content

Commit

Permalink
improved coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas.gehrig committed Mar 22, 2024
1 parent 173a74b commit ef59de9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion karabo/simulation/sky_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def extract_names_and_freqs(
for col in cols:
col_name = col.name
if not isinstance(col_name, str):
raise RuntimeError(
raise TypeError(

Check warning on line 371 in karabo/simulation/sky_model.py

View check run for this annotation

Codecov / codecov/patch

karabo/simulation/sky_model.py#L371

Added line #L371 was not covered by tests
f"`col_name` should be of type `str`, but is {type(col_name)=}"
)
match = pattern.match(string=col_name)
Expand Down
19 changes: 0 additions & 19 deletions karabo/test/test_data.py

This file was deleted.

21 changes: 21 additions & 0 deletions karabo/test/test_skymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
MIGHTEESurveyDownloadObject,
)
from karabo.simulation.sky_model import (
KaraboSkyModelError,
Polarisation,
SkyModel,
SkyPrefixMapping,
Expand All @@ -37,6 +38,26 @@ def gleam() -> SkyModel:
return SkyModel.get_GLEAM_Sky(min_freq=72e6, max_freq=80e6)


def test_download_gleam_and_make_sky_model():
sky = SkyModel.get_GLEAM_Sky(min_freq=72e6, max_freq=80e6)
sample_prefix_mapping = SkyPrefixMapping([], [], [])
number_of_sky_attributes = len(sample_prefix_mapping.__dict__)

assert sky.num_sources > 0

# -1 since we do not return the source ID
assert sky.to_np_array().shape == (sky.num_sources, number_of_sky_attributes - 1)
assert sky.source_ids["dim_0"].shape[0] == sky.shape[0] # checking source-ids


def test_mightee():
_ = SkyModel.get_MIGHTEE_Sky()
with pytest.raises(KaraboSkyModelError):
_ = SkyModel.get_MIGHTEE_Sky(min_freq=3e11)
_ = SkyModel.get_MIGHTEE_Sky(max_freq=3e11)
_ = SkyModel.get_MIGHTEE_Sky(min_freq=1.3e9, max_freq=1.4e9)


def test_filter_sky_model(gleam: SkyModel):
phase_center = [250, -80] # ra,dec
filtered_sky = gleam.filter_by_radius(0, 0.55, phase_center[0], phase_center[1])
Expand Down

0 comments on commit ef59de9

Please sign in to comment.