Ticket #5756 (closed enhancement: fixed)
[with patch; positive review] improve coverage of rings/morphism.pyx (and fix 5 bugs in morphism.pyx)
| Reported by: | was | Owned by: | mabshoff |
|---|---|---|---|
| Priority: | major | Milestone: | sage-3.4.1 |
| Component: | doctest coverage | Keywords: | |
| Cc: | robertwb | Work issues: | |
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description (last modified by was) (diff)
Fix the coverage of morphism.pyx, which is bad.
Attachments
Change History
comment:2 Changed 4 years ago by was
- Description modified (diff)
BUGS FOUND:
- bug in cmp
10:56 < wstein-5756> Wow, I was reading the __cmp__ for ring lifting maps. 10:56 < wstein-5756> Check out this bug: 10:56 < wstein-5756> Zmod(8).lift() == Zmod(10).lift() 10:56 < wstein-5756> True 10:56 < wstein-5756> Any two lifting maps are always equal. 10:56 < wstein-5756> Ouch.
- Another bug related to cmp: #5758 (weird "hello")
- nonzero is wrong for ring morphisms, since Sage does have the 0 ring where 0 == 1, so this code was wrong:
def __nonzero__(self): return True
- Calling .lift() on a morphism returns None. This is a bug that was caused by cythonizing morphism.pyx:
sage: R.<x,y> = QQ[]; R.hom([x,x]).lift() is None True
comment:3 Changed 4 years ago by was
- Summary changed from improve coverage of rings/morphism.pyx to [with patch; needs review] improve coverage of rings/morphism.pyx (and fix 5 bugs in morphism.pyx)
BUGS FOUND:
- im_gens() returns a mutable list, which makes it trivial to *break* a morphism after it is created:
sage: R.<x,y> = QQ[] sage: f = R.hom([x,x+y]) sage: f(x) x sage: f.im_gens()[0] = 5 sage: f.im_gens() [5, x + y] sage: f(x) 5
comment:4 Changed 4 years ago by cremona
Starting to review this, which is in itself non-trivial!
There is some strange terminology here. I'm not sure what a "Set-theoretic ring endomorphism of Integer Ring" is meant to be, let alone a "set-theoretic ring". I think that what is meant is (in the first case) a map between rings which is not a ring homomorphism, such as a section of a surjective map.
Also the term "lift" is used for such a section, i.e. if f:R-->S is the surjective ring hom and h:S-->R is a section (so f(h(s))==s for all s in S) then the map h is being called a lift, where I would say that the element h(s) is a lift of s. And "cover"? Here R is being called a cover of S?
I think it would be helpful if somewhere in this file this terminology is defined since not all of it is so standard...
A more proper review will follow.
comment:5 Changed 4 years ago by mabshoff
- Cc robertwb added
Robert: In case you are reviewing this - all doctest in my rc3 merge tree with this patch applied pass.
Cheers,
Michael
comment:6 follow-up: ↓ 7 Changed 4 years ago by robertwb
- Summary changed from [with patch; needs review] improve coverage of rings/morphism.pyx (and fix 5 bugs in morphism.pyx) to [with patch; positive review] improve coverage of rings/morphism.pyx (and fix 5 bugs in morphism.pyx)
I agree that the notation could be made more consistent, but this patch simply documents what is there (which is good) and fixes some bugs.
One thing I noticed, which is not just common to this patch, is that when we return a list that we don't want people to change (e.g. im_gens) we (hopefully) make a copy. This is why tuples were invited, shouldn't we just be using those instead?
comment:7 in reply to: ↑ 6 Changed 4 years ago by mabshoff
Replying to robertwb:
I agree that the notation could be made more consistent, but this patch simply documents what is there (which is good) and fixes some bugs.
Yeah, getting it in should be the main goal here and now.
One thing I noticed, which is not just common to this patch, is that when we return a list that we don't want people to change (e.g. im_gens) we (hopefully) make a copy. This is why tuples were invited, shouldn't we just be using those instead?
implemented instead of invited I assume?
Either way, can you please open a followup ticket so that this doesn't get lost.
Cheers,
Michael

