Fix comparison for divisors of curves (and FormalSum commutativity)#37972
Fix comparison for divisors of curves (and FormalSum commutativity)#37972vbraun merged 22 commits intosagemath:developfrom
Conversation
|
Thank you for submitting the PR. First, you should not be changing the Second, as far as I can tell, this is just reimplementing one part of the try:
self._data = [(c, x) for (x, c) in sorted(new.items()) if c]
except (TypeError, ValueError):
self._data = [(c, x) for (x, c) in sorted(new.items(), key=str) if c] |
The change to the
I looked at You're right that there is an issue where Either way, I think that overriding the Here's an example of what I mean, which I think is a bug with comparison of divisors: C = EllipticCurve([2, 1])
R = C(1, 2)
E = EllipticCurve([1, 2])
Q = E(1, 2)
R == Q # Evaluates to False, which is correct
E.divisor(Q) == C.divisor(R) # Evaluates to True, which I think is incorrect |
|
Some additional code showing that C = EllipticCurve([2, 1])
R = C(1, 2)
E = EllipticCurve([1, 2])
Q = E(1, 2)
Qd = E.divisor(Q)
Rd = C.divisor(R)
Qd == Rd # Evaluates to True, which as I said above I think is incorrect
Qd.support() == Rd.support() # Evaluates to False, which I think is correct but doesn't make sense if Qd == Rd is evaluating to True. |
|
Yes, the changes are out of scope. It's (very) bad practice to hide such changes in unrelated PRs. You can just remove those files yourself anyways; bootstrap is only run sparingly. Okay, the The formal sum does also compare by parents. The subtlety is that there is a coercion map: So the comparison is done after coercing both into a common parent (here, that is def _coerce_map_from_(self, other):
return (isinstance(other, type(self))
and self._scheme == other._scheme
and super()._coerce_map_from_(other)) |
Strange, I get Alternatively, I could do a larger rewrite of the That would involve making |
|
No, there's no reason for the element class to not inherit from |
|
To make sure I'm understanding before I go and implement your suggestions, you're suggesting that I make the following 3 changes?
Is that correct? |
|
Yes, that's correct. Either 2 or the richcmp should convert the data to a dict for comparisons. Although I think the normalization of the representative is better for doctors output. |
|
Documentation preview for this PR (built with commit ce4b05c; changes) is ready! 🎉 |
|
Okay, I made those changes. The build will fail because this test is failing: sage: C = EllipticCurve([2, 1])
sage: R = C(1, 2)
sage: E = EllipticCurve([1, 2])
sage: Q = E(1, 2)
sage: Qd = E.divisor(Q)
sage: Rd = C.divisor(R)
sage: Qd == Rd
FalseFor some reason Any ideas? |
|
The Also, I don't think it is worthwhile for |
|
Hopefully that fixes everything. I think this is a bit cleaner because now tests aren't reliant on the arbitrary string ordering I had for comparison purposes. Instead terms are in the order the you enter them in, which makes sense. I didn't cache the results of sorting the |
tscrim
left a comment
There was a problem hiding this comment.
I feel like not normalizing the print representation is a small step backwards. It also means that we have to sort on every comparison (instead of just when calling reduce()). Although I don't know how these are used, so I don't know which could affect speed more. Well, I understand making a minimal change. I just want to mention that the fact that some are genuinely different might be exposing bugs. That might warrant further investigation later.
Co-authored-by: Travis Scrimshaw <clfrngrown@aol.com>
Co-authored-by: Travis Scrimshaw <clfrngrown@aol.com>
I agree and I think |
|
I wouldn't call the sorting as part of the |
Co-authored-by: Travis Scrimshaw <clfrngrown@aol.com>
|
The commit I just pushed updated the warning in The build from yesterday failed. For |
|
Yea, our CI testing is currently massively broken... |
tscrim
left a comment
There was a problem hiding this comment.
Okay, let's get this in.
sagemathgh-37972: Fix comparison for divisors of curves (and FormalSum commutativity) Fixes sagemath#37966. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. URL: sagemath#37972 Reported by: Vincent Macri Reviewer(s): Travis Scrimshaw, Vincent Macri
sagemathgh-37972: Fix comparison for divisors of curves (and FormalSum commutativity) Fixes sagemath#37966. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. URL: sagemath#37972 Reported by: Vincent Macri Reviewer(s): Travis Scrimshaw, Vincent Macri
Fixes #37966.
📝 Checklist