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
py3: change semantics of equality for real and complex interval fields #22549
Comments
Branch: u/chapoton/22549 |
comment:1
Work in progress. In particular doc still needs to be adapted. New commits:
|
Commit: |
Replying to @fchapoton:
Please elaborate. |
Replying to @fchapoton:
Why the change in the behavior of == required when switching to Python3? |
comment:5
For these interval-numbers, we absolutely need to get rid of the incompatible double comparison (cmp on one hand (currently lexicographic), and rich comparison (<,>,==,!=,<=,=>, currently with the semantics "all elements are related to all elements") on the other hand). Right now "cmp" is used very deeply to make sure that objects have UniqueRepresentation or can be pickled correctly. In order for all this to work, we need to relax the richcmp behaviour of equality to match the current behaviour of equality with cmp. An illustrating problem is the following : take an interval say (0.1,0.2). Pickle it. Load it again. According to the current rich comparison, it will not be equal to itself. This breaks many things. If one of you think he can get quickly an alternative easy solution, I engage him or her to try. I can tell you that I did. IMHO, the current proposal is the least invasive solution. |
comment:6
Replying to @fchapoton:
I agree. However, I would rather keep the current rich comparison and drop the old-style
How does pickling involve
Feature, not a bug.
Like what? |
comment:7
Just look at the patchbot reports of #22257 |
comment:8
Replying to @fchapoton:
That just shows that #22257 should be fixed. I don't see why it would require to change the semantics of |
comment:9
#22257 tells you what happens if you replace current cmp behaviour by current richcmp behaviour. If you think you can repair all the breaking doctests there by doing something else, please try. I have not found any other solution. The solution proposed here almost passes all tests. The few failing doctests are mostly expected due to the change of behaviour, and do no harm. There is one more complex failure related to composite of number fields. I would like to have the opinion of a number theorist on this one. |
comment:10
This is really involved in unique representation and ComparisonById, because Number Fields (which are Parent) have embeddings (which are interval-numbers) that need to compare equal to themselves for the number fields to do the same. For some triggered failures by using the current richcmp, see precisely this report: |
comment:11
Replying to @fchapoton:
Tons of external code might be broken by this change of behaviour. Changing the semantics of |
comment:12
Replying to @fchapoton:
Here is a constructive suggestion: essentially, what
by
For |
comment:13
Replying to @cheuberg:
+1 |
comment:14
Replying to @fchapoton:
Could we replace checking for equality to checking for non-inequality instead? |
comment:15
Yes, guys, I understand your issues. Nevertheless, I have worked hard on the question, and this really stands in our way to python3. I do not think that this proposal is such a big change of behaviour. Maybe most equality tests between elements of RIF should involve an exact element, no ? Transition to python3 is going to be painful, but you really appreciate that when spending a lot of time on this transition, as I did. |
comment:16
If I read the code correctly, the proposed behaviour is the same as the current behaviour for real and complex ball fields, so it should not be so bad. |
comment:17
Replying to @fchapoton:
So far, I totally agree.
I think it's a massive change of behaviour which really should not be done unless you have very good reasons (so far, I haven't seen such a reason).
Probably yes.
Again, I totally agree. Still, the fact that it's painful does not mean that we should go ahead with what you propose here. |
comment:18
Replying to @fchapoton:
This is simply not true:
|
comment:19
Replying to @jdemeyer:
I'd suggest calling it |
comment:20
Indeed, I was wrong on that point. The doc of ball fields says
so that
Replying to @jdemeyer:
|
comment:23
Ok. It seems that the solution proposed here will not be accepted. I will now try to go back to #22257 and propose there another fix with no change to the == semantics. |
comment:24
I would say what needs to be fixed is what is stored as the caching key for number fields. In this case, it looks like the construction of said key, when given an element of RIF/RBF, should instead store the endpoints. The parent is reconstructible from that data and it doesn't involve the |
Changed author from Frédéric Chapoton to none |
Reviewer: Frédéric Chapoton |
comment:27
yes, I agree, you can close as wontfix |
comment:28
Replying to @jdemeyer:
Note however that we have:
IMO this is a bug or at least a misfeature of the current |
comment:29
Closing tickets in the sage-duplicate/invalid/wontfix module with positive_review (i.e. someone has confirmed they should be closed). |
The change is required for the transition to Python3.
Before (now), == means that both interval-numbers are exact and equal.
After, == means that both interval numbers have the same bounds.
In both cases, equality with an exact number holds only for another exact number.
CC: @tscrim @jdemeyer @a-andre @dkrenn @cheuberg @behackl
Component: python3
Branch/Commit: u/chapoton/22549 @
fd2e363
Reviewer: Frédéric Chapoton
Issue created by migration from https://trac.sagemath.org/ticket/22549
The text was updated successfully, but these errors were encountered: