Repository navigation
feat: add arb.equal and acb.equal #444
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
Open
deftasparagusanaconda
wants to merge
1
commit into
flintlib:main
Choose a base branch
from
deftasparagusanaconda:add-equal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a possibility that the conversion to arb is not exact?
I think maybe this should only compare exact arbs aginst other numeric types exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arb_equalshould have the same behaviour asarb_containsandarb_overlapsbecause theyre closely related comparison predictes. if we change one, we should change the other two as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arb.contains()andarb.overlaps()useany_as_arb()to convertotherto an arb. if these two are allowed to do that, thenarb.equal()should also be allowed to do that. or ifarb.equal()is not allowed to do that, the other two shouldnt be allowed either. i think this is right, because they are all used to compare the ball representation of two arbs, and they also appear closely together in the FLINT docs. so they should all behave the same.IMHO none of them should use
any_as_arb()since it causes implicit type conversion, which isnt good for something as important as equality!im not familiar enough with
any_as_arb()to saylet me know again if im not clear!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is any_as_arb always exact or could it round the input number. I guess we could have an fmpq like 1/3 that cannot be converted to arb without some rounding errorand then we don't know it is contained:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think overlaps and equal probably need to special-case some types. There should perhaps be a method that specifically says "other is an arb and is exactly the same as this" as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate a little bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a method suitable for use in test code (perhaps there already is) that checks that other is an arb and that it has the exact same representation as self.
Separately I think it should be possible to call e.g. equal or overlaps with something like fmpq it should be able to report the correct answer without any issues due to rounding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if im not mistaken, that means
any_as_arbshould be changed to raise an error if the arb created is not exact, eliminating any implicit rounding.if it is so, then it should raise errors based on type, not on value.
in my experience, conversion functions that raise on invalid values will raise runtime errors which are hard to anticipate. its better to raise on types that might potentially be inexact, and be compile-time errors instead. the user would instead convert type manually which is inconvenient but safer and explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think it just means that
any_as_arbshould not always be used everywhere.