Skip to content

Update reference outputs and make output comparison stricter - #565

Merged
gmloose merged 2 commits into
combined-reference-updatesfrom
update-reference-outputs
Nov 9, 2026
Merged

gmloose merged 2 commits into
combined-reference-updatesfrom
update-reference-outputs

Conversation

@gmloose

@gmloose gmloose commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

The reference outputs of test/tbdsf_process_image.py had drifted from what master produces, and the comparison didn't check all outputs. This PR is meant to be merged before #564 (replace _cbdsm), so that #564 can be checked against up-to-date references.

Changes

  • Regenerated test/reference_outputs with the current master (4fc79a2) on x86-64 Linux, with Python 3.12, NumPy 2.4.6, SciPy 1.18.1 and Astropy 8.0.2 (_cbdsm from a cibuildwheel build). Compared with the old references:
    • residual/resid_gaus.fits differed by +2.9%, just under the CI tolerance of 3%.
    • The wavelet images differed by 1–2%, and wavelet/model/*model*.fits by -12.7%.
  • compare_results now recurses into subdirectories. Before, it only compared the files one level down. The 15 images in wavelet/model, wavelet/residual and wavelet/background, and the top-level ch0_* images, were never compared. With the old references, the recursive comparison fails even at 3%, on the wavelet model images.
  • A missing or extra output file now makes the comparison fail. Before, the result of check_all_files_present was ignored, so it was only logged.
  • tbdsf_process_image.py takes the tolerance as --rtol. The default is 0.001, for runs on the same kind of system as the one that generated the references. CI (ci.yml) and the cibuildwheel test-command use --rtol 0.03, as before. A tighter CI tolerance would be fragile: some fits in this test are ill-conditioned, so last-bit rounding differences (another architecture such as macOS arm64, other library versions) can change the PSF-variation maps by tens of percent.

Verification

All on the machine that generated the references:

Run Tolerance Result
master default 0.001 passes
master 0 passes
#564 (pure-Python _cbdsm replacement) 0 passes
An earlier, non-exact version of #564 0.03 fails (PSF-variation maps)

The last row shows the test still detects real changes.

Not changed: the image comparison uses np.isclose with its default absolute tolerance (1e-8). For near-empty images, such as some wavelet background maps, that tolerance dominates, so those images are hardly checked.

🤖 Generated with Claude Code

- Regenerate `test/reference_outputs` with the current master. The old
  ones had drifted: `resid_gaus.fits` differed by 2.9% (close to the CI
  tolerance of 3%), and the wavelet model images by 12.7%.
- `compare_results` now compares all subdirectories recursively (the
  images in `wavelet/model`, `wavelet/residual` and `wavelet/background`,
  and the top-level `ch0_*` images, were not compared), and fails if a file
  is missing in one of the runs (this was only logged).
- `tbdsf_process_image.py` takes the tolerance as `--rtol`, with a default
  of 0.001 for runs on the same kind of system as the one that generated
  the reference outputs (x86-64 Linux). CI and cibuildwheel use 0.03.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gmloose gmloose self-assigned this Nov 7, 2026
@gmloose
gmloose requested a review from darafferty November 7, 2026 00:39
@gmloose

gmloose commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T00:47:04.936989Z 47450dd Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 47450dd4e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@darafferty darafferty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There are a couple of other PRs that also update of the reference files (e.g., #535 and #548) — would it be good to update the files just once (with all the changes together) or is it not worth the trouble?

Otherwise, looks good!

@gmloose

gmloose commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

There are a couple of other PRs that also update of the reference files (e.g., #535 and #548) — would it be good to update the files just once (with all the changes together) or is it not worth the trouble?

Yes, definitely. I will try to make sure we update those files only once. But that will require me to bypass the "pipelines must succeed" rule.

@gmloose
gmloose changed the base branch from master to combined-reference-updates November 9, 2026 13:46
@gmloose
gmloose merged commit 8f08362 into combined-reference-updates Nov 9, 2026
1 check failed
gmloose added a commit that referenced this pull request Nov 9, 2026
* Fix `inigaus_fbdsm` PA (#535)

`fit_island()` converts the beam PA to the convention used by `gaus_2d()` by adding 90 deg. That beam is passed to `get_maxima()` and then to `mclean()`, which adds another 90 deg. The clean model is therefore rotated by 90 deg.

* Fix wavelet output files (#548)

**Bugs**
The wavelet module incorrectly generated the `model_wavelets.fits` and `resid_wavelets.fits`. After Gaussian fitting, the residual image is further processed by wavelet Gaussian fitting. However, the implementation did not correctly account for the standard Gaussian model when saving the final outputs.

- `model_wavelets.fits` contained only the additional model contributed by wavelet Gaussian fitting, rather than the complete source model.

- `resid_wavelets.fits` contained the original image with only the wavelet model subtracted. So the standard Gaussian model was still present in this image, meaning it was not the actual residual.

- This also caused incorrect results when wavelet Gaussian fitting was disabled (atrous_bdsm_do = False): the model image was 0 and the residual image was identical to the input image.

**Fixed**
- `model_wavelets.fits` contain the complete model (both standard and wavelet Gaussian components).

- `resid_wavelets.fits` contain the final residual after subtraction of both model components.

**Added**
- `model_wavelets_component.fits` to preserve the wavelet-only model.

Also updated the wavelet image filenames to distinguish wavelet components from remaining scale images when `atrous_sum = True`.

* Update reference outputs and make output comparison stricter (#565)

* Update reference outputs and make output comparison stricter

- Regenerate `test/reference_outputs` with the current master. The old
  ones had drifted: `resid_gaus.fits` differed by 2.9% (close to the CI
  tolerance of 3%), and the wavelet model images by 12.7%.
- `compare_results` now compares all subdirectories recursively (the
  images in `wavelet/model`, `wavelet/residual` and `wavelet/background`,
  and the top-level `ch0_*` images, were not compared), and fails if a file
  is missing in one of the runs (this was only logged).
- `tbdsf_process_image.py` takes the tolerance as `--rtol`, with a default
  of 0.001 for runs on the same kind of system as the one that generated
  the reference outputs (x86-64 Linux). CI and cibuildwheel use 0.03.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Restore reference outputs from master

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Update reference outputs

---------

Co-authored-by: Aleksander Kurek <aleksander.kurek@uj.edu.pl>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@gmloose
gmloose deleted the update-reference-outputs branch November 9, 2026 14:52
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.

2 participants