XanaduAI / MrMustard

A differentiable bridge between phase space and Fock space
https://mrmustard.readthedocs.io/
Apache License 2.0
78 stars 27 forks source link

silenced complex det warnings #377

Closed ziofil closed 7 months ago

ziofil commented 7 months ago

Context: Numpy now raises warnings when the determinant of a complex matrix is calculated. We silence the warnings only when those determinants are calculated.

Description of the Change: Wrap det calls in a numpy context

Benefits: No more warnings

Possible Drawbacks: Warnings may be legit

Related GitHub Issues:

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.30%. Comparing base (85e8cb8) to head (ef8fc4d).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #377 +/- ## =========================================== + Coverage 87.08% 87.30% +0.22% =========================================== Files 80 80 Lines 5978 5980 +2 =========================================== + Hits 5206 5221 +15 + Misses 772 759 -13 ``` | [Files](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/377?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI) | Coverage Δ | | |---|---|---| | [mrmustard/math/backend\_numpy.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/377?src=pr&el=tree&filepath=mrmustard%2Fmath%2Fbackend_numpy.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL21hdGgvYmFja2VuZF9udW1weS5weQ==) | `100.00% <ø> (ø)` | | | [mrmustard/physics/bargmann.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/377?src=pr&el=tree&filepath=mrmustard%2Fphysics%2Fbargmann.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL3BoeXNpY3MvYmFyZ21hbm4ucHk=) | `100.00% <100.00%> (ø)` | | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/377/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/377?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/377?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). Last update [85e8cb8...ef8fc4d](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/377?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI).
SamFerracin commented 7 months ago

Cool. Just a question: We have a class to silence warnings, that lets you un-silence them if you want to (may be useful for users to debug). It's in utils/filters.py. Do we want to use that, as THE way of silencing warnings?

ziofil commented 7 months ago

I forgot we had that! But I don't like that we would silence numerical warnings for the whole kernel session. They may be relevant. Check the current solution: it's only when we compute the det in the numpy backend and a test will fail in the future when there's no need for the filter.

ziofil commented 7 months ago

The tests fail here and pass on my machine. I think it's only my problem then? 🤔

ziofil commented 7 months ago

closed by mistake