Skip to content

564 refactor image tests#569

Open
smcastro wants to merge 4 commits intomainfrom
564-refactor-image-tests
Open

564 refactor image tests#569
smcastro wants to merge 4 commits intomainfrom
564-refactor-image-tests

Conversation

@smcastro
Copy link
Copy Markdown
Contributor

@smcastro smcastro commented Apr 10, 2026

There is a more detailed explanation of what has changed in this branch in the GitHub issue #564

…module.

Refactored test cases and classes in the script to map the API of image.py.
Updated test_image_xds.py with new testing functionality.
Updated README.md.
@smcastro smcastro linked an issue Apr 10, 2026 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 98.63014% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/xradio/testing/image/io.py 95.83% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@smcastro smcastro requested a review from dmehring April 10, 2026 16:14
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@dmehring
Copy link
Copy Markdown
Collaborator

@smcastro I went ahead and added copilot as a reviewer since you seemed interested in doing that.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the image unit tests to remove duplicated helper code and centralize reusable image-test utilities under xradio.testing.image, aligning with the approach requested in Issue #564 for reuse across xradio and external repositories.

Changes:

  • Reworked tests/unit/image/test_image.py into pytest-style classes and replaced in-file helpers with imports from xradio.testing.image.
  • Simplified test_image_xds.py by reusing shared empty-image generation logic and improving parametrization.
  • Added a shared conftest.py fixture for the Dask client and introduced a new xradio.testing.image helper package (IO, generators, assertions) with documentation.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/image/test_image.py Converts to pytest classes and consumes newly centralized image test helpers.
tests/unit/image/test_image_xds.py Removes duplicated empty-image args; reuses shared generator and improves parametrized coverage.
tests/unit/image/conftest.py Adds module-scoped Dask client fixture shared by image tests.
src/xradio/testing/README.md Documents the new testing.image submodule and its public helper API.
src/xradio/testing/image/io.py Adds download/open/remove helpers for image test assets.
src/xradio/testing/image/generators.py Adds empty-image and FITS guard test generators.
src/xradio/testing/image/assertions.py Adds image-specific comparison helpers used by tests/benchmarks.
src/xradio/testing/image/init.py Re-exports the public API for xradio.testing.image.
src/xradio/testing/init.py Exposes xradio.testing.image at the package level.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +39 to +57
def download_and_open_image(fname: str, directory: str | Path = "."):
"""Download an image asset and return it as an opened ``xr.Dataset``.

Parameters
----------
fname : str
Name of the image asset to download.
directory : str or Path, optional
Target directory. Defaults to the current working directory.

Returns
-------
xr.Dataset
The opened image dataset.
"""
from xradio.image import open_image

path = download_image(fname, directory=directory)
return open_image(str(path))
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

download_and_open_image is part of the new public testing helpers but it lacks a return type annotation (unlike download_image / download_measurement_set). Adding -> xr.Dataset (possibly via a TYPE_CHECKING import to avoid importing xarray at module import time) would improve type-checking and API clarity.

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +13
__all__ = [
"assert_attrs_dicts_equal",
"assert_xarray_datasets_equal",
# image sub-package (imported by name so external projects can use it)
"image",
]

import xradio.testing.image # noqa: F401, E402 – register the sub-package
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xradio.testing.__all__ exports image, but the module uses import xradio.testing.image with noqa flags to make it available. This style is inconsistent with other package initializers in the repo (which use relative imports) and it also introduces a xradio name in this module’s namespace. Prefer from . import image # noqa: F401 (or similar) so the exported name is bound explicitly without needing E402 suppression.

Copilot uses AI. Check for mistakes.
@dmehring
Copy link
Copy Markdown
Collaborator

Hi @smcastro
copilot has finished its first round, so I'll let you make changes and keep iterating with copilot if you want. Let me know when you're done making mods after you've finished with copilot and I'll take a look.

smcastro and others added 2 commits April 10, 2026 22:18
Copilot review 1.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor image tests

4 participants