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

Integrate numerary to gain support for numeric tower #179

Merged
merged 2 commits into from Jan 22, 2022

Conversation

antonagestam
Copy link
Owner

Closes #34.

@posita Thanks for pointing me towards your library, it seems to work like a charm! 🙏

A question: is it correctly interpreted that the type argument to RealLike is whatever the type returns for round() and abs()? Does it make sense to use RealLike[IntegralLike[int]] like I've done?

I ran into one issue in that I get metaclass conflicts when using RealLike as a bound for a python type, but it should be possible to resolve that (I think). It's been brought up here earlier that it could be nice to provide helper functions for resolving metaclass conflicts, I'm now leaning towards going in that direction.

@codecov-commenter
Copy link

codecov-commenter commented Jan 22, 2022

Codecov Report

Merging #179 (b00c84a) into main (02cabe9) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #179   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines          710       714    +4     
  Branches        82        82           
=========================================
+ Hits           710       714    +4     
Impacted Files Coverage Δ
src/phantom/interval.py 100.00% <100.00%> (ø)
src/phantom/predicates/interval.py 100.00% <100.00%> (ø)
src/phantom/predicates/numeric.py 100.00% <100.00%> (ø)
src/phantom/sized.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02cabe9...b00c84a. Read the comment docs.

@posita
Copy link

posita commented Jan 22, 2022

@posita Thanks for pointing me towards your library, it seems to work like a charm! 🙏

Nice! I'm glad it was (or at least shows promise of being) helpful!

A question: is it correctly interpreted that the type argument to RealLike is whatever the type returns for round() and abs()? Does it make sense to use RealLike[IntegralLike[int]] like I've done?

Ah! This is interesting, and probably something I overlooked. I think (at least originally), I hadn't considered subscripting RealLike anywhere. (That may be an embarrassing admission, but my own use cases haven't demanded that…yet.) The fact that it's generic sort of derives from an attempt to aggregate standard library protocols like SupportsAbs, as you discovered. (numerary's basically a crutch for simple(ish) cases until a real fix for python/mypy#3186 emerges.)

But I take your point about bumping up against that particular limitation. (I'm pretty sure we're talking about this, but I want to make sure I'm looking at the right thing.)

I opened beartype/numerary#10 to track this. Can you do me a huge favor? Do you think you could you reduce the problem you encountered down to a smaller example? I would love to be able to see if I can address it with something more intuitive.

@antonagestam
Copy link
Owner Author

@posita Absolutely, I'll try to provide something graspable. The reason I filled in the type argument is that I got type errors when I didn't, I'll need to give a closer look to understand why though.

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.

Support numeric tower in phantom.numeric
3 participants