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

725 integration tests of metrics #750

Merged
merged 19 commits into from
May 9, 2023

Conversation

aakashdp6548
Copy link
Collaborator

Added tests for comparing BLISS catalog to DECaLS and SDSS catalogs. Fixes #725.

  • Added new tests to tests/test_metrics.py and restructured as class. Data loading is done as class-level fixture to avoid repeated processing.
  • Modified DecalsFullCatalog.from_file to take optional RA and DEC limits instead of required pixel coord limits and WCS. get_plocs_from_ra_dec handles the conversion to pixel coordinates. Added tests for this functionality in tests/test_catalogs.py.
  • Added to_dict() and to() methods to FullCatalog to move entire catalog to device, similar to TileFullCatalog.
  • Added case study with plotting sources in all three catalogs and computing metrics

@aakashdp6548 aakashdp6548 linked an issue May 9, 2023 that may be closed by this pull request
5 tasks
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@aakashdp6548
Copy link
Collaborator Author

I pulled the changes to metrics from 288718d, so most of the changes in this PR are from there. I didn't realize they would also show up on the diffs here - let me know if there's a better way to handle that, like closing this and making a new PR after that one's been merged maybe?

@codecov
Copy link

codecov bot commented May 9, 2023

Codecov Report

Merging #750 (8c6a439) into master (6d43f0e) will increase coverage by 8.85%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #750      +/-   ##
==========================================
+ Coverage   79.48%   88.33%   +8.85%     
==========================================
  Files          13       13              
  Lines        1121     1132      +11     
==========================================
+ Hits          891     1000     +109     
+ Misses        230      132      -98     
Flag Coverage Δ
unittests 88.33% <100.00%> (+8.85%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
bliss/catalog.py 81.22% <100.00%> (+1.12%) ⬆️
bliss/metrics.py 100.00% <100.00%> (ø)
bliss/predict.py 100.00% <100.00%> (ø)
bliss/surveys/decals.py 100.00% <100.00%> (+100.00%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

min_sources: 0
prob_galaxy: 0.72
star_flux_min: 622.0
star_flux_min: 1e5
Copy link
Contributor

Choose a reason for hiding this comment

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

622 is more realistic. Can you override this constant in a case study-specific config file rather than changing it throughout?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed this accidentally, reverted to previous value.

@@ -32,10 +33,10 @@ simulator:
n_bands: 1
batch_size: 64
max_sources: 1
mean_sources: 0.2
mean_sources: 0.03
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to modify not to change this project-wide. Can you override this constant in a case study-specific config file rather than changing it throughout?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

sample_file = Path(cfg.paths.decals).joinpath("tractor-3366m010.fits")
decals_cat = DecalsFullCatalog.from_file(sample_file)

assert not torch.all(decals_cat.plocs) # all plocs should be 0 by default
Copy link
Contributor

Choose a reason for hiding this comment

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

Is plocs a floating point value? If so, it's probably better not to check for exact equality

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we expect this assertion might fail in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

plocs is manually set to torch.zeros in DecalsFullCatalog.from_file, so the assertion itself shouldn't fail. But there isn't really a need to test this, so I removed the check.

@aakashdp6548
Copy link
Collaborator Author

I think the metrics bug is actually more complicated than just adding a null check. We need to check all the combinations of the tensors being empty and update the false positives / false negatives accordingly, so I created #752 to handle it separately.

Copy link
Contributor

@jeff-regier jeff-regier 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!

Copy link
Contributor

@jeff-regier jeff-regier 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!

@jeff-regier jeff-regier merged commit afafb02 into master May 9, 2023
@jeff-regier jeff-regier deleted the 725-integration-tests-of-metrics branch May 9, 2023 20:19
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.

integration tests of metrics.py and various FullCatalog subclasses
2 participants