-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Fractions functionality issue #395 #403
Conversation
I would remove the old methods. One plan for this was also that it is merged after #397, such that add mul etc have support for Union[int, Fraction]. |
That's fine. #397 is pretty much ready to go. I'm happy to come back to this when its merged. |
I had to modify a few different things so that Self in Unions was accepted. Currently running something like:
Works but running Returns the following error:
Is this an bug in uplc or have I made an error somewhere? |
There is a bug in OpShin, likely something we overlooked in #397. When something is a Union[x,y] it is PlutusData. However for int and other primitive types I usually assume they are unwrapped into builtin data. Here there must be some missing unwrapping of int after casting it via isinstance. Note that addition can not be done with PlutusData and requires unwrapping via UInt before. |
Try
|
There is likely also another edge case in #397
will likely crash |
Is CI not working at the moment? |
Great, thanks for the update. I think Travis is currently broken, I wanted to migrate to Github actions anyways and am preparing #406 for this. Will merge it into this branch to check that the tests are now still passing. |
It looks like Self is a 3.11 only feature of typing. In previous python versions this is instead solved using literal strings like "Fraction". |
Ah, I'll rewrite them all as literal strings then. |
Also check unwrapping for bytes type
The fraction code looks great now. Unfortunately I still found (and added) 2 failing cases for #397. |
I'll get to work on those |
Thank you for those test cases, the first one I really should have thought of myself but I wouldn't have thought of the test_Union_builtin_cast_direct. I had to modify them so that the tests were correct so It might be worth you checking to make sure I didn't break the test. |
Your modifications of if-expressions made me think... caught another bug :) |
These don't compile, which is not ideal but better than compiling and then crashing.
Sorry about the never ending new crashing examples... the last ones added are out of scope though (since not even properly implemented for unions of plutus data), I created #408 dedicated for them. also its not a problem if an expression does not compile. |
Any update on this? :) |
Apologies, I almost forgot I was supposed to be working on this. I've got the IfExp working now |
Great, thank you! This will be part of the next version 0.24.0. Please submit your wallet address for the bug bounty :) |
addr1q84dsy6ckn3gplf6kenwvr8mspecdlxu2mq3aj5kn02uthd93vtsr3yl4f3553sxfx7wzx58cx5pnhekvtlgqf55lw9sl4vwdy |
If this also signals the completion of #397 the same address can be used for the payout of that bounty too. |
Targetting issue #395.
Dunder methods for all Fractions functions.
The Fraction functions are still there, I don't know if you want to temporarily keep them for backwards compatibility or to be replaced entirely with dunder methods.
Also created
Fraction.norm
andFraction.ceil
class methods which could replaceceil_fraction
andnorm_fraction
.