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

Change unit test response file to dense #287

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

israelmcmc
Copy link
Collaborator

We have moved from a sparse to a dense response. It was not that sparse, and it ended up being slower than a dense matrix. The unit test now reflects what we actually use.

I created the dense response with:

from cosipy.response import FullDetectorResponse
from cosipy import test_data
from histpy import Histogram

dr = FullDetectorResponse.open(test_data.path/'test_full_detector_response.h5')

dr_new = Histogram.concatenate(dr.axes['NuLambda'], list(dr))
dr_new = dr_new.project(['Ei', 'NuLambda', 'Em', 'Phi', 'PsiChi'])
dr_new = dr_new.todense()

FullDetectorResponse._write_h5(dr_new, test_data.path/'test_full_detector_response_dense.h5')

In order to make things easier I moved the code that writes an HDF5 response file from a Histogram from _open_rsp to its own function, _write_h5. I added a unit test for this specific function.

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

Attention: Patch coverage is 35.48387% with 20 lines in your changes missing coverage. Please review.

Project coverage is 79.58%. Comparing base (aea580b) to head (382a503).

Files with missing lines Patch % Lines
cosipy/response/FullDetectorResponse.py 35.48% 20 Missing ⚠️

❌ Your patch check has failed because the patch coverage (35.48%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Files with missing lines Coverage Δ
cosipy/response/FullDetectorResponse.py 45.99% <35.48%> (+6.70%) ⬆️

@israelmcmc
Copy link
Collaborator Author

I need to create a fake .rsp to fix the test coverage. @augustus-thomas I think at some point you were working on this, did you get to create one? Or maybe it was for the PSR, I don't remember exactly.

tmp_dir = tmp_path / "tmp"
tmp_dir.mkdir()

tmp_rsp = test_data.path / 'tmp_rsp.h5'
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe, should it be tmp_path.path / 'tmp_rsp.h5'? Currently, the file will be saved in the test data directory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the catch. Indeed it was the wrong path. I fixed it in my latest commit.

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