Opened 21 months ago
Closed 19 months ago
#26279 closed enhancement (fixed)
Improve comparisons of PolyDicts
Reported by: | embray | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | sage-8.5 |
Component: | refactoring | Keywords: | |
Cc: | Merged in: | ||
Authors: | Erik Bray | Reviewers: | Frédéric Chapoton |
Report Upstream: | N/A | Work issues: | |
Branch: | 1cfdd4c (Commits) | Commit: | 1cfdd4cb6b6fdf80b74fb905339027955cd5d7c2 |
Dependencies: | Stopgaps: |
Description
The PolyDict
class has a __richcmp__
method which just implements the default rich comparison between the underlying dicts of the PolyDict
s being compared, which in of itself is not terrible useful, especially given that it's not a meaningful comparison for relational operators.
However there is also an undocumented PolyDict.rich_compare
method which i the same as __richcmp__
but takes a key
argument (previously required, but I made it optional and renamed it to sortkey
) which can be used to provide meaningful ordering between polynomials. This is used currently in Sage in exactly one place. But this ticket shows one other example where it was useful to have. We've also polished up the documentation just a little bit.
Change History (8)
comment:1 Changed 21 months ago by
- Status changed from new to needs_review
comment:2 Changed 20 months ago by
- Status changed from needs_review to needs_work
comment:3 Changed 19 months ago by
- Milestone changed from sage-8.4 to sage-8.5
comment:4 Changed 19 months ago by
- Commit changed from 3edaefa0608c9bd36efa1a0e223da8b5d83edd2c to 5fb5c762830796187163fb00dab42c80803e1950
comment:5 Changed 19 months ago by
- Status changed from needs_work to needs_review
Trivial rebase at first. But I also fixed a test that was failing on Python 2 (the p1 < p2
test) due to the differences in default comparison behavior between Python 2 and 3. Not 100% satisfied with that, and wondering if we should instead explicitly enforce ==
and !=
only.
comment:6 Changed 19 months ago by
- Branch changed from u/embray/polydict/richcmp to public/26279
- Commit changed from 5fb5c762830796187163fb00dab42c80803e1950 to 1cfdd4cb6b6fdf80b74fb905339027955cd5d7c2
- Reviewers set to Frédéric Chapoton
- Status changed from needs_review to positive_review
comment:7 Changed 19 months ago by
Thanks!
comment:8 Changed 19 months ago by
- Branch changed from public/26279 to 1cfdd4cb6b6fdf80b74fb905339027955cd5d7c2
- Resolution set to fixed
- Status changed from positive_review to closed
branch is red