Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
f1da6d6
Add conftest.py for dataset module
aknierim Jan 7, 2026
d30c6f9
Add refactored tests for pyvisgen.dataset module
aknierim Jan 7, 2026
73ef761
Remove unused fixture
aknierim Jan 7, 2026
e8041d3
Remove plugin manager gridder fallback
aknierim Jan 7, 2026
b5af89c
Add test inputs h5 file containing 10 images from radiosim
aknierim Jan 7, 2026
ccd3697
Remove writer context manager from num_images loop
aknierim Jan 7, 2026
d2086b0
Rename num_images to num_images_list for better readability
aknierim Jan 8, 2026
13e4e58
Return self.gridder, not gridder
aknierim Jan 8, 2026
abd7109
Fix dtypes
aknierim Jan 8, 2026
c51bf4d
Check for None when values could also be 0
aknierim Jan 8, 2026
e3a3d3b
Add missing dtype to config arg
aknierim Jan 8, 2026
360f4ee
Remove prints
aknierim Jan 8, 2026
775d4c3
Bugfix: Append vis data to sim_data list
aknierim Jan 8, 2026
b514e74
Remove obsolete _get_obs_test classmethod
aknierim Jan 8, 2026
92b605b
Use pytest-mock mocker to mock progress bars
aknierim Jan 8, 2026
c8776ca
Add remaining tests for dataset.py
aknierim Jan 8, 2026
bd47862
Refactor config tests
aknierim Jan 8, 2026
47d2adc
Add remaining tests for configs
aknierim Jan 9, 2026
779d8aa
Fix configs after test results
aknierim Jan 9, 2026
1419d29
Update tests group dependencies
aknierim Jan 9, 2026
89e501e
Fix type hint in observation
aknierim Jan 9, 2026
51b9964
Fix config and update tests
aknierim Jan 9, 2026
387bc09
Remove old writer tests
aknierim Jan 12, 2026
3a53be9
Add tests for WDSShardWriter and H5Writer
aknierim Jan 12, 2026
a2bc7ac
Ignore try: ... except ImportError: ... blocks in coverage
aknierim Jan 12, 2026
f0c5b28
Fix PTWriter output path and file contents
aknierim Jan 12, 2026
afa43a4
Add tests for PTWriter, DataWriter ABC
aknierim Jan 12, 2026
f8d0dc8
Use dataset_type kwarg instead of conf object in FITSWriter
aknierim Jan 12, 2026
a91d5ba
Add test for FITSWriter
aknierim Jan 12, 2026
18fc535
Add tests for dataset.utils
aknierim Jan 12, 2026
3967aaf
Add additional fixtures for dataset utils tests
aknierim Jan 12, 2026
bc5cc7c
Merge branch 'optimize_tests' of github.com:radionets-project/pyvisge…
aknierim Jan 13, 2026
2fef5f4
Add tests for Stations and get_array_layout
aknierim Jan 13, 2026
6371bfa
Add tests for get_array_layout and get_array_names
aknierim Jan 14, 2026
ff248aa
Remove unneccessary code complexity
aknierim Jan 20, 2026
f0535f8
Add tests for simulation.array
aknierim Jan 20, 2026
81cfbc6
Add tests for Baselines and ValidBaselineSubset dataclasses
aknierim Jan 20, 2026
0f51b89
Add conftest for simulation module tests
aknierim Jan 20, 2026
45240a4
Add more test cases for ValidBaselineSubset.get_unique_grid
aknierim Jan 22, 2026
24e8020
Add tests for _lexsort, Scan, Observation
aknierim Jan 22, 2026
0aea090
Fix type hints and docstrings
aknierim Jan 22, 2026
098ad6b
Return ValidBaselineSubset instead of tensor in __getitem__ method
aknierim Jan 22, 2026
d3f9663
Fix lexsort return
aknierim Jan 22, 2026
3d8703a
Return ValidBaselineSubset in get_unique_grid
aknierim Jan 22, 2026
44800ae
Add __post_init__ to Scan dataclass
aknierim Jan 22, 2026
c00d2f7
Return actual number of timesteps in Scan.get_num_timesteps
aknierim Jan 22, 2026
4fc8a46
Use correct property names of Array class
aknierim Jan 22, 2026
d40ef37
Remove exception handling for u,v,w shapes, ignore coverage for GHA s…
aknierim Jan 22, 2026
a8865bb
Fix angles in Observation.calc_feed_rotation
aknierim Jan 22, 2026
26e1834
Change test values for mock layout
aknierim Jan 22, 2026
7c9dc14
Add new fixtures for Scan and Observation
aknierim Jan 22, 2026
59d0327
Remove pragma: no cover from calc_dense_baselines, add to bin length …
aknierim Jan 23, 2026
ccc0755
Add test for empty baselines object
aknierim Jan 23, 2026
00074f7
Add test for Observation with device CUDA
aknierim Jan 23, 2026
fd34d89
Update calc_ref_elev test
aknierim Jan 23, 2026
24864b6
Rename var array_loc as mock_array_loc
aknierim Jan 23, 2026
3faf53a
Add missing tests for Observation methods
aknierim Jan 23, 2026
bf5522f
Fix type hints
aknierim Jan 23, 2026
70de30f
Update type hint and improve exception message
aknierim Jan 27, 2026
926d7af
Improve amp_ratio handling
aknierim Jan 27, 2026
323bc21
Improve baseline object usage with attributes instead of indexing
aknierim Jan 27, 2026
fb7f75c
Improve baseline object usage with attributes instead of indexing in …
aknierim Jan 27, 2026
e1ecba1
Update type hints
aknierim Jan 27, 2026
0493312
Add tests for Visibilities dataclass and first tests for Polarization…
aknierim Jan 27, 2026
6f21c41
Add fixtures for Polarization class testing
aknierim Jan 27, 2026
5136a03
Remove layout tests, simulation tests
aknierim Jan 27, 2026
8cc47fb
Merge branch 'main' into optimize_tests
aknierim Jan 27, 2026
6393c59
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 27, 2026
84b6c69
Shorten exception message string for assertion of DataWriter ABC exce…
aknierim Jan 27, 2026
6bd1f3b
Assign ValidBaselineSubset to dense_baselines_gpu attr
aknierim Jan 28, 2026
3443738
Update type hints and type checks
aknierim Jan 28, 2026
47f4124
Use torch.manual_seed instead of torch.random.manual_seed
aknierim Jan 28, 2026
6aca5b3
Update exception handling
aknierim Jan 28, 2026
23937f2
Bugfix: Apply mask to image instead of returning mask if threshold is…
aknierim Jan 28, 2026
f9e20d6
Add sky_dist fixture to simulation conftest
aknierim Jan 28, 2026
f4db7a3
Reduce image size
aknierim Jan 28, 2026
2d9c8c8
Change fixture scope to function for field_kwargs
aknierim Jan 28, 2026
0b6ef85
Update test for dense baselines in observation to check for ValidBase…
aknierim Jan 28, 2026
3b4fd17
Update mocker patches for test_linear and test_circular
aknierim Jan 28, 2026
0b66771
Import vis_loop and _batch_loop
aknierim Jan 28, 2026
68e2d08
Add vis_loop tests
aknierim Jan 28, 2026
2c059c1
Add fixtures for _batch_loop
aknierim Jan 29, 2026
eb9f413
Add tests for _batch_loop
aknierim Jan 29, 2026
d80f124
Add test for generate_noise
aknierim Jan 30, 2026
c390ab4
Move and update scan tests
aknierim Jan 30, 2026
6aa53cb
Update type hint for polarization in scan.rime
aknierim Jan 30, 2026
f8130d2
Add tests for simulation utils
aknierim Jan 30, 2026
5e19d8c
Add test for _reduce_batch_size
aknierim Jan 30, 2026
8ed6f0c
Fix factore not used in _reduce_batch_size
aknierim Jan 30, 2026
1eb0f31
Move carbontracker test
aknierim Jan 30, 2026
04e16b4
Remove obsolete test_utils.py
aknierim Jan 30, 2026
59270e4
Add tests for load_bundles, open_bundles
aknierim Jan 30, 2026
37b48a4
Remove unused files
aknierim Jan 30, 2026
6f41c8a
Add tests for dataset utils
aknierim Jan 30, 2026
e33f219
Change module level utils test file names
aknierim Jan 30, 2026
45a2942
Update type hint and remove no cover
aknierim Feb 3, 2026
afdf8e8
Update tests for plugin manager
aknierim Feb 3, 2026
5ece0b8
Remove debug prints
aknierim Feb 3, 2026
0a7d583
Add test root level conftest with mock torch compile func
aknierim Feb 3, 2026
00482d3
Add coverage source src
aknierim Feb 3, 2026
c8781bf
Remove disable_torch_compile fixture
aknierim Feb 3, 2026
0aa7085
Ignore type assignment for test image in test_scan
aknierim Feb 3, 2026
13825f2
Remove unused torch.compile decorator for rime func
aknierim Feb 3, 2026
2180533
Update click options for dataset converter
aknierim Feb 5, 2026
7ab185e
Update dataset_split handling, rename dataset_type to dataset_split
aknierim Feb 5, 2026
6cae6f2
Add CliRunner fixture
aknierim Feb 5, 2026
b94d43d
Add tests for main cli
aknierim Feb 5, 2026
89a00c6
Add tests for converter cli
aknierim Feb 5, 2026
817fb10
Add comment on module reload
aknierim Feb 6, 2026
1b29303
Use LOGGER.warning instead of LOGGER.warn
aknierim Feb 10, 2026
699794d
Remove unused fits.data submodule
aknierim Feb 10, 2026
4925836
Ignore coverage for quickstart CLI
aknierim Feb 10, 2026
8b7342e
Disable exception catching in CliRunner
aknierim Feb 10, 2026
07ae2e1
Add dataset creation cli tests
aknierim Feb 10, 2026
d10019f
Remove test for group commands
aknierim Feb 10, 2026
f09f8be
Delete data.rst
aknierim Feb 10, 2026
b99ff5c
Add tests for fits writer
aknierim Feb 12, 2026
75a2bb9
Add changelog fragment
aknierim Feb 12, 2026
12961c3
Merge branch 'main' into optimize_tests
aknierim Feb 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions docs/api-reference/fits/data.rst

This file was deleted.

13 changes: 13 additions & 0 deletions docs/changes/136.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Updated the entire test framework with unit tests that are more efficient than the old tests. The tests now consist of more unit tests and do not run the entire simulation pipeline every time.

Removed `tomli` from dependencies and test requirements in `pyproject.toml`, added `pytest-mock` as a new test dependency

Updated type hints across the codebase

Added `dataset_type` as an to `FITSWriter` for consistency with other writer classes

Removed unused submodule `pyvisgen.fits.data`

Updated `__getitem__` method of `ValidBaselineSubset` dataclass to return `ValidBaselinesSubset` object, similar to `Baselines` dataclass

`pyvisgen.simulation.array.Array` now has updated property names `relative_pos` and `antenna_pairs`. Removed `calc_relative_pos` method that would just get the `relative_pos` property.
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ docs = [
"sphinx-tippy>=0.4.3",
"sphinx-togglebutton>=0.3.2",
"sphinxcontrib-bibtex",
"tomli; python_version < '3.11'",
]
tests = [
"coverage!=6.3.0",
Expand All @@ -96,18 +95,18 @@ tests = [
"pytest-xdist",
"pytest >= 7.0",
"restructuredtext-lint",
"tomli",
"pytest-mock>=3.15.1",
]

[build-system]
requires = ["hatch-vcs", "hatchling"]
build-backend = "hatchling.build"

[tool.coverage.run]
source = ["src"]
omit = [
"docs/*",
"src/pyvisgen/_version.py",
"src/pyvisgen/gridding/alt_gridder.py",
"src/pyvisgen/version.py",
"tests/*"
]
Expand Down Expand Up @@ -144,7 +143,7 @@ include = ["src/pyvisgen"]
[tool.ruff]
target-version = "py311"
line-length = 88
extend-exclude = ["tests", "examples"]
extend-exclude = ["examples"]

[tool.ruff.lint]
extend-select = [
Expand Down
10 changes: 6 additions & 4 deletions src/pyvisgen/_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ def _get_avail_plugins(self, group: str) -> dict[str, Callable]:
try:
plugin_class = entry_point.load()
self.plugins[entry_point.name] = plugin_class
except ImportError as e: # pragma: no cover
LOGGER.warn(f"Failed to load plugin {entry_point.name} in {group}: {e}")
except ImportError as e:
LOGGER.warning(
f"Failed to load plugin {entry_point.name} in {group}: {e}"
)

return self.plugins

def _get_plugin(self, name, group):
plugins = self._get_avail_plugins(group=group)
if not list(plugins.keys()): # pragma: no cover
plugins: dict[str, Callable] = self._get_avail_plugins(group=group)
if not list(plugins.keys()):
raise ValueError(
f"No plugins available in entry point group '{group}'! "
"Make sure you have installed a package providing plugins compatible "
Expand Down
89 changes: 17 additions & 72 deletions src/pyvisgen/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self):
@classmethod
def from_config(
cls,
config: str | Path | dict,
config: str | Path | dict | Config,
/,
image_key: str = "y",
*,
Expand Down Expand Up @@ -153,12 +153,12 @@ def from_config(
"", total=len(cls.data_paths)
)

num_images = []
num_images_list = []
for bundle_id in range(len(cls.data_paths)):
num_images.append(len(cls.get_images(bundle_id)))
num_images_list.append(len(cls.get_images(bundle_id)))
counting_progress.update(counting_task_id, advance=1)

cls.num_images = int(np.sum(num_images))
cls.num_images = int(np.sum(num_images_list))
overall_progress.update(cls.overall_task_id, advance=1)

if cls.num_images == 0:
Expand Down Expand Up @@ -222,6 +222,8 @@ def _run(self) -> None:
).grid()

sim_data.append(np.array(grid_data.get_mask_real_imag()))
else:
sim_data.append(vis)

current_bundle_progress.update(current_bundle_task_id, advance=1)

Expand Down Expand Up @@ -296,11 +298,11 @@ def _get_gridder(self):
LOGGER.warning(e)
LOGGER.warning("Falling back to default gridder!")

gridder = Gridder
self.gridder = Gridder

return gridder
return self.gridder

def get_images(self, i: int) -> torch.tensor:
def get_images(self, i: int) -> torch.Tensor:
"""Opens bundle with index i and returns :func:`~torch.tensor`
of images.

Expand Down Expand Up @@ -489,12 +491,12 @@ def draw_sampling_opts(self, size: int) -> dict:
delta, amp_ratio, field_order, field_scale = np.full((4, size), np.nan)

if self.conf.polarization.mode:
if self.conf.polarization.delta:
if self.conf.polarization.delta is not None:
delta = np.repeat(self.conf.polarization.delta, size)
else:
delta = self.rng.uniform(0, 180, size)

if self.conf.polarization.amp_ratio:
if self.conf.polarization.amp_ratio is not None:
amp_ratio = np.repeat(self.conf.polarization.amp_ratio, size)
else:
amp_ratio = self.rng.uniform(0, 1, size)
Expand All @@ -513,7 +515,7 @@ def draw_sampling_opts(self, size: int) -> dict:
)
else:
a = self.rng.uniform(0, 1 - 1e-6, size)
b = np.repeat(1, size, dtype=float)
b = np.repeat(1, size)
field_scale = np.stack((a, b), axis=1)

samp_opts = dict(
Expand Down Expand Up @@ -631,8 +633,8 @@ def calc_time_steps(self, i: int) -> Time:
return Time(time_steps)

def _geocentric_to_spherical(
self, x: torch.tensor, y: torch.tensor, z: torch.tensor
) -> torch.tensor:
self, x: torch.Tensor, y: torch.Tensor, z: torch.Tensor
) -> tuple[torch.Tensor, torch.Tensor]:
"""Convert geocentric coordinates to lon/lat.

Parameters
Expand All @@ -654,8 +656,8 @@ def _geocentric_to_spherical(
return lat, lon

def _compute_altitude(
self, ra: torch.tensor, dec: torch.tensor, lst: torch.tensor
) -> torch.tensor:
self, ra: torch.Tensor, dec: torch.Tensor, lst: torch.Tensor
) -> torch.Tensor:
"""Computes altitude for a given RA/DEC, and local sidereal time (LST).

Parameters
Expand Down Expand Up @@ -686,62 +688,5 @@ def _compute_altitude(
# in the arcsin below
sin_alt = torch.clamp(sin_alt, -1, 1)
alt_rad = torch.arcsin(sin_alt)
return torch.rad2deg(alt_rad)

@classmethod
def _get_obs_test(
cls,
config: str | Path,
/,
image_key: str = "y",
*,
date_fmt: str = DATEFMT,
) -> tuple: # pragma: no cover
"""Creates an :class:`~pyvisgen.simulation.Observation` class
object for tests.

Parameters
----------
config : str or Path
Path to the config file.
image_key : str, optional
Key under which the true sky distributions are saved
in the HDF5 file. Default: ``'y'``
date_fmt : str, optional
Format string for datetime objects.
Default: ``'%d-%m-%Y %H:%M:%S'``

Returns
-------
self : SimulateDataSet
Class object.
obs : :class:`~pyvisgen.simulation.Observation`
:class:`~pyvisgen.simulation.Observation` class object.
"""
cls = cls()
cls.key = image_key
cls.date_fmt = date_fmt
cls.multiprocess = 1

if isinstance(config, (str, Path)):
cls.conf = Config.from_toml(config)
elif isinstance(config, Config):
cls.conf = config
elif isinstance(config, dict):
cls.conf = Config.model_validate(config)
else:
raise ValueError(
"Expected config to be one of str, Path, dict, or pyvisgen.io.Config!"
)

cls.device = cls.conf.sampling.device

cls.overall_task_id = overall_progress.add_task(
f"Simulating {cls.conf.bundle.dataset_type} dataset", total=3
)

cls.data_paths = load_bundles(cls.conf.bundle.in_path)[0]
cls.create_sampling_rc(1)
obs = cls.create_observation(0)

return cls, obs
return torch.rad2deg(alt_rad)
4 changes: 0 additions & 4 deletions src/pyvisgen/dataset/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import numpy as np

from pyvisgen.utils.logging import setup_logger

LOGGER = setup_logger()


def calc_truth_fft(sky_dist):
truth_fft = np.fft.fftshift(
Expand Down
2 changes: 0 additions & 2 deletions src/pyvisgen/fits/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .data import fits_data
from .writer import (
create_antenna_hdu,
create_frequency_hdu,
Expand All @@ -13,5 +12,4 @@
"create_hdu_list",
"create_time_hdu",
"create_vis_hdu",
"fits_data",
]
Loading
Loading