Ticket #3102 (closed defect: fixed)
[with patch, positive review] debugging output in p-adics with print mode "digits"
| Reported by: | dmharvey | Owned by: | somebody |
|---|---|---|---|
| Priority: | major | Milestone: | sage-3.2.1 |
| Component: | basic arithmetic | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
Someone apparently forgot to uncomment some debugging code:
sage: K = Qp(7, print_mode="digits") sage: K(1/2) # ok ...33333333333333333334 sage: K(1/42) # hmmmmmmmm ['5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '6'] -1 ['5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5'] ['6'] ...5555555555555555555.6 sage:
Attachments
Change History
comment:1 Changed 5 years ago by dmharvey
- Owner changed from mabshoff to somebody
- Component changed from Cygwin to basic arithmetic
comment:3 Changed 5 years ago by gfurnish
- Summary changed from debugging output in p-adics with print mode "digits" to [with patch, needs review] debugging output in p-adics with print mode "digits"
comment:4 Changed 5 years ago by cremona
- Summary changed from [with patch, needs review] debugging output in p-adics with print mode "digits" to [with patch, with review, issue remains] debugging output in p-adics with print mode "digits"
Well, the patch applied fine and doctests pass. BUT when I manually type in
sage: K = Qp(7, print_mode="digits")
sage: repr(K(1/2))
I do NOT get what the doctest says I should:
'...3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|4'
but instead I get this:
'...33333333333333333334'
I don't know why the vertial lines a re missing, or whether they should be there; but I do know that the doctester ignores what comes after three dots ... so any p-adics print mode which includes the dots is going to be rather hard to doctest.
comment:5 Changed 5 years ago by gfurnish
- Summary changed from [with patch, with review, issue remains] debugging output in p-adics with print mode "digits" to [with patch, needs review] debugging output in p-adics with print mode "digits"
I think this is working as intended -- The other p-adic print statements also have the lines (see line 68). It seems to be something specific to testing the printer so that it generates different output in doctests and runtime. It looks like it may be enabling the bars global state early in the tests and never disabling it.
comment:6 follow-up: ↓ 7 Changed 5 years ago by cremona
But in line 68 you have just set the print-mode to "bars", while here you have set the mode to "digits".
I just don't understand the concept of output being different during doctests and runtime!
Regarding your last sentence: each test should be independent of earlier ones surely, starting in a separate Sage session? How can it be correct to explicitly set the print_mode to "digits" but have a doctest showing that apparantly "bars" is output?
I still find this too confusing.
comment:7 in reply to: ↑ 6 Changed 5 years ago by was
Replying to cremona:
But in line 68 you have just set the print-mode to "bars", while here you have set the mode to "digits".
I just don't understand the concept of output being different during doctests and runtime!
Regarding your last sentence: each test should be independent of earlier ones surely, starting in a separate Sage session? How can it be correct to explicitly set the print_mode to "digits" but have a doctest showing that apparantly "bars" is output?
I still find this too confusing.
John Cremona is definitely right here.
Changed 4 years ago by was
-
attachment
sage-3102.patch
added
followup -- apply the above patch *and* this one.
comment:8 Changed 4 years ago by was
- Summary changed from [with patch, needs review] debugging output in p-adics with print mode "digits" to [with patch, positive review] debugging output in p-adics with print mode "digits"
I attached a tiny patch that addresses and clarifies some of the issues discussed above. See #4637 for a ticket for the bug that the above exposes.
comment:10 Changed 4 years ago by mabshoff
- Status changed from new to closed
- Resolution set to fixed
Merged both patches in Sage 3.2.1.rc0
