Ticket #3102 (closed defect: fixed)

Opened 7 months ago

Last modified 4 days ago

[with patch, positive review] debugging output in p-adics with print mode "digits"

Reported by: dmharvey Assigned to: somebody
Priority: major Milestone: sage-3.2.1
Component: basic arithmetic Keywords:
Cc:

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 (1.2 kB) - added by gfurnish on 09/07/2008 03:04:16 PM.
sage-3102.patch (1.1 kB) - added by was on 11/26/2008 11:01:34 PM.
followup -- apply the above patch *and* this one.

Change History

05/04/2008 02:54:19 PM changed by dmharvey

  • owner changed from mabshoff to somebody.
  • component changed from Cygwin to basic arithmetic.

05/05/2008 03:52:28 AM changed by mabshoff

  • milestone set to sage-3.0.2.

09/07/2008 03:04:16 PM changed by gfurnish

  • attachment trac_3102.patch added.

09/07/2008 03:04:30 PM changed 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".

09/08/2008 01:05:44 PM changed 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.

09/08/2008 05:16:18 PM changed 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.

(follow-up: ↓ 7 ) 09/09/2008 01:28:57 AM changed 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.

(in reply to: ↑ 6 ) 09/24/2008 10:35:52 AM changed 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.

11/26/2008 11:01:34 PM changed by was

  • attachment sage-3102.patch added.

followup -- apply the above patch *and* this one.

11/26/2008 11:03:04 PM changed 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.

11/26/2008 11:11:59 PM changed by craigcitro

Second patch looks good, too.

11/27/2008 11:31:58 PM changed by mabshoff

  • status changed from new to closed.
  • resolution set to fixed.

Merged both patches in Sage 3.2.1.rc0