Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks of output to tests #231

Merged
merged 16 commits into from
Jul 1, 2024
Merged

Add checks of output to tests #231

merged 16 commits into from
Jul 1, 2024

Conversation

darafferty
Copy link
Collaborator

This PR adds checking of the outputs to the main test script (see RAP-694; it is also relevant to issue #227). The new tests compare the outputs to a reference set (stored in tests/reference_outputs). Currently, it is checked that:

  • all expected files are present
  • the noise in each output image agrees (within 1%) with that of the corresponding reference image

The contents of text files and catalogs are not currently checked, as the details of the fitting (e.g., Gaussian properties, number of Gaussians, their ordering, etc.) may vary due to differences in the libraries, etc. used between the test run and the run used to generate the reference outputs.

Some cleanup was also done, including the removal of old, unused test files.

@darafferty darafferty requested a review from gmloose June 20, 2024 14:38
@darafferty darafferty self-assigned this Jun 20, 2024
Copy link
Collaborator

@gmloose gmloose left a comment

Choose a reason for hiding this comment

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

Looks good to me, except for some minor things. See my comments.

bdsf/islands.py Outdated Show resolved Hide resolved
bdsf/islands.py Outdated Show resolved Hide resolved
with open(file1) as f1, open(file2) as f2:
diff = list(d.compare(f1.readlines(), f2.readlines()))
agree = True
for line in diff:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would filter diff already now, since you need it both directly below and in the log (line 77). Something like:

    # Only keep lines that start with diff markers and are not comment lines
    diff = [
        line for line in d.compare(f1.readlines(), f2.readlines()) 
        if line.startswith(('-','+')) and not line[2:].startswith('#')
    ] 

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good suggestion -- done.

return agree


class FITSImage(object):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a note that this class was copied (almost) verbatim from the Rapthor repository: rapthor/lib/fitsimage.py. Maybe add a hyperlink to this file on GitLab as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@gmloose
Copy link
Collaborator

gmloose commented Jun 28, 2024

One more thing. I see that the loglevel is set to DEBUG for the comparison in test_bdsf_process_image.py, which creates a lot of noise. Could the level be set to INFO or WARNING by default?

@gmloose
Copy link
Collaborator

gmloose commented Jun 28, 2024

O, and when I try to run the test it fails with the following error:

ERROR: The following files are present in 'reference_outputs/misc' but not in 'tbdsf_process_image.in_fits_pybdsf/misc': ['tbdsf_process_image.in_fits.pybdsf.atrous.w1.pybdsf_pyrank.fits', 'tbdsf_process_image.in_fits.pybdsf.atrous.w2.pybdsf_pyrank.fits', 'tbdsf_process_image.in_fits.pybdsf.atrous.w3.pybdsf_pyrank.fits', 'tbdsf_process_image.in_fits.pybdsf.atrous.w4.pybdsf_pyrank.fits', 'tbdsf_process_image.in_fits.pybdsf_pyrank.fits']

Which is kind of curious, because these files seem to be present. 🤔

@gmloose
Copy link
Collaborator

gmloose commented Jun 28, 2024

O, and when I try to run the test it fails with the following error:

ERROR: The following files are present in 'reference_outputs/misc' but not in 'tbdsf_process_image.in_fits_pybdsf/misc': ['tbdsf_process_image.in_fits.pybdsf.atrous.w1.pybdsf_pyrank.fits', 'tbdsf_process_image.in_fits.pybdsf.atrous.w2.pybdsf_pyrank.fits', 'tbdsf_process_image.in_fits.pybdsf.atrous.w3.pybdsf_pyrank.fits', 'tbdsf_process_image.in_fits.pybdsf.atrous.w4.pybdsf_pyrank.fits', 'tbdsf_process_image.in_fits.pybdsf_pyrank.fits']

Which is kind of curious, because these files seem to be present. 🤔

I already see what's the problem. The missing outputs are not in tbdsf_process_image.in_fits_pybdsf/misc, but in ..

@darafferty
Copy link
Collaborator Author

That's strange -- the files are in the right place (in misc/) for me (and in the CI pipeline as well I guess, since it passes the check). The output directory was changed to misc/ in commit dfe265a.

@darafferty
Copy link
Collaborator Author

Ah, I found the problem I think: it could write the pyrank images to the wrong directory in some cases. Should be fixed now.

@darafferty
Copy link
Collaborator Author

I think all comments have been addressed. I also reduced the verbosity of the comparison as requested.

Copy link
Collaborator

@gmloose gmloose left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@darafferty darafferty merged commit f0eaac8 into master Jul 1, 2024
2 checks passed
@darafferty darafferty deleted the RAP-694_unit_tests branch July 1, 2024 12:36
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