f-dangel / curvlinops

scipy linear operators for the Hessian, Fisher/GGN, and more in PyTorch
https://curvlinops.readthedocs.io/en/latest/
MIT License
17 stars 5 forks source link

[FIX] Checks if `Enum` contains string #119

Closed runame closed 3 months ago

runame commented 3 months ago

Fixes #118.

Also, I have added the FisherType and KFACType Enums to __init__ to make them easy to import.

coveralls commented 3 months ago

Pull Request Test Coverage Report for Build 9489624969

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
curvlinops/kfac.py 8 10 80.0%
<!-- Total: 9 11 81.82% -->
Totals Coverage Status
Change from base Build 9488896670: -0.08%
Covered Lines: 1333
Relevant Lines: 1500

💛 - Coveralls
coveralls commented 3 months ago

Pull Request Test Coverage Report for Build 9489631898

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
curvlinops/kfac.py 8 10 80.0%
<!-- Total: 9 11 81.82% -->
Totals Coverage Status
Change from base Build 9488896670: -0.08%
Covered Lines: 1333
Relevant Lines: 1500

💛 - Coveralls
wiseodd commented 3 months ago

Seems like the issue is actually because of a newer version of Python. Your check works in Python 3.8, but fails in Python 3.9 (the default of laplace-torch).

This works in Python 3.9:

In [5]: [v.value for  v in FisherType]
Out[5]: ['type-2', 'mc', 'empirical', 'forward-only']
wiseodd commented 3 months ago

PS. Python 3.8 will be deprecated soon https://devguide.python.org/versions/.

runame commented 3 months ago

@wiseodd Have you tried the fix in this PR? I also tested it with Python 3.11 and it worked.

coveralls commented 3 months ago

Pull Request Test Coverage Report for Build 9489716093

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
curvlinops/kfac.py 8 10 80.0%
<!-- Total: 9 11 81.82% -->
Totals Coverage Status
Change from base Build 9488896670: -0.08%
Covered Lines: 1333
Relevant Lines: 1500

💛 - Coveralls
wiseodd commented 3 months ago

Yes, the fix here works.

Can't wait to finally free from the shackles of Python < 3.10. Pattern matching, StrEnum, Rust/cargo-like compiler messages... 🤤