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

23 tests for hot swappable numpy backends demo use #24

Merged
merged 10 commits into from
Aug 16, 2024

Conversation

kenjim21
Copy link
Collaborator

added jax backend compatibility for mueler functions and corresponding testing

@kenjim21 kenjim21 linked an issue Aug 16, 2024 that may be closed by this pull request
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 38.70968% with 76 lines in your changes missing coverage. Please review.

Project coverage is 74.35%. Comparing base (3b8fdc3) to head (b6797eb).

Files Patch % Lines
tests/test_mueller.py 37.83% 69 Missing ⚠️
tests/test_katsu_math.py 46.15% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #24       +/-   ##
===========================================
- Coverage   98.38%   74.35%   -24.04%     
===========================================
  Files           3        3               
  Lines         186      308      +122     
===========================================
+ Hits          183      229       +46     
- Misses          3       79       +76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Jashcraf
Copy link
Owner

Ah looks like adding Jax as an optional dependency and not explicitly testing it hurts code coverage. I think that's fine for now, but just writing a note here to consider a way of structuring a test file to maintain the code coverage. Maybe removing it from the automated codecov reporting or just configuring the tests on the remote machine

katsu/mueller.py Outdated

D = np.sqrt(np.sum(diattenuation_vector * diattenuation_vector, axis=-1))
mD = np.sqrt(1 - D**2)
D = np.sqrt(np.sum(np.matmul(diattenuation_vector, diattenuation_vector), axis=-1))
Copy link
Owner

Choose a reason for hiding this comment

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

It looks like an element wise multiplication was replaced with a matmul. Does this end up doing a dot product because it does so in the last axis?

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah I think this might need to be reverted to an element-wise multiplication, but let me check the source material first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just tried reverting the change and uncommenting the test for it. still getting a failure unfortunately (though this could still be because of the eigen values thing)

Copy link
Owner

Choose a reason for hiding this comment

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

So decompose_diattenuator doesn’t rely on eigenvalue computation, which suggests that maybe its something significant

Copy link
Owner

Choose a reason for hiding this comment

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

i’ll try poke around on my machine

Copy link
Owner

Choose a reason for hiding this comment

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

If I did it right I think i just commited the change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay, let me push uncommenting the test and see if it passes on the workflow

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah for decompose_diattenuator, not for decompose_depolarizer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wait we still have it not required so it won't check it regardless. can you test on your computer if the tests work now?

Copy link
Owner

Choose a reason for hiding this comment

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

decompose_depolarizer fails if I uncomment it

@kenjim21
Copy link
Collaborator Author

For the codecov we can def look at adding all the possible autodiff libraries that are being supported to a special designation for testing so that while it's not on the requirements.txt, it'll be install for the automated testing

@Jashcraf
Copy link
Owner

Oh man did it run with the test uncommented?

@kenjim21
Copy link
Collaborator Author

Screenshot 2024-08-16 180213

This is the margin of difference between the matrices when I print them

@Jashcraf
Copy link
Owner

So that value in the lower-left is concerning, but not huge - can you make an issue to investigate this difference? For now I think this is fine for the PR

@Jashcraf
Copy link
Owner

3…2…1…

LGTM!

@kenjim21
Copy link
Collaborator Author

Ya i'll add an issue. it looks like for any of the non zero values minus the top row there's its almost consistently off at around the 6th decimal or further

@Jashcraf Jashcraf merged commit ba07c1e into main Aug 16, 2024
2 checks passed
@kenjim21 kenjim21 deleted the 23-tests-for-hot-swappable-numpy-backends-demo-use branch August 16, 2024 23:14
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.

Tests for hot-swappable numpy backends, demo use
3 participants