Ticket #3102 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

[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

trac_3102.patch Download (1.2 KB) - added by gfurnish 5 years ago.
sage-3102.patch Download (1.1 KB) - added by was 4 years ago.
followup -- apply the above patch *and* this one.

Change History

comment:1 Changed 5 years ago by dmharvey

  • Owner changed from mabshoff to somebody
  • Component changed from Cygwin to basic arithmetic

comment:2 Changed 5 years ago by mabshoff

  • Milestone set to sage-3.0.2

Changed 5 years ago by gfurnish

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

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:9 Changed 4 years ago by craigcitro

Second patch looks good, too.

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

Note: See TracTickets for help on using tickets.