Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions src/sage/rings/padics/padic_printing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class pAdicPrinterDefaults(SageObject):
``mode=None`` returns the current value.

The allowed values for mode are: ``'val-unit'``, ``'series'``,
``'terse'``, ``'digits'`` and ``'bars'``.
``'terse'``, ``'digits'``, ``'digits-unicode'`` and ``'bars'``.

EXAMPLES::

Expand All @@ -136,12 +136,14 @@ class pAdicPrinterDefaults(SageObject):
13 * 10 + O(13^21)
sage: padic_printing.mode('digits')
sage: repr(Qp(17)(100))
'...5F'
'...0000000000000000005F'
sage: repr(Qp(17)(1000))
'...37E'
Comment thread
gulshan-123 marked this conversation as resolved.
'...0000000000000000037E'
sage: padic_printing.mode('digits-unicode')
sage: repr(Qp(17)(100))
'…0000000000000000005F'
sage: repr(Qp(17)(1000))
'…0000000000000000037E'
sage: padic_printing.mode('bars')
sage: repr(Qp(19)(1000))
'...2|14|12'
Expand Down Expand Up @@ -181,7 +183,7 @@ class pAdicPrinterDefaults(SageObject):
def max_series_terms(self, max=None):
r"""
Controls the maximum number of terms shown when printing in
``'series'``, ``'digits'`` or ``'bars'`` mode.
``'series'``, ``'digits'``, ``'digits-unicode'`` or ``'bars'`` mode.

``max=None`` returns the current value.

Expand Down Expand Up @@ -280,7 +282,8 @@ class pAdicPrinterDefaults(SageObject):
def alphabet(self, alphabet=None):
r"""
Controls the alphabet used to translate `p`-adic digits into
strings (so that no separator need be used in ``'digits'`` mode).
strings (so that no separator need be used in ``'digits'``
or ``'digits-unicode'`` mode).

``alphabet`` should be passed in as a list or tuple.

Expand All @@ -289,9 +292,9 @@ class pAdicPrinterDefaults(SageObject):
EXAMPLES::

sage: padic_printing.alphabet("abc")
sage: padic_printing.mode('digits')
sage: padic_printing.mode('digits-unicode')
sage: repr(Qp(3)(1234))
'...bcaacab'
'…aaaaaaaaaaaaabcaacab'

sage: padic_printing.mode('series')
sage: padic_printing.alphabet(('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'))
Expand Down Expand Up @@ -321,7 +324,8 @@ cdef class pAdicPrinter_class(SageObject):
attached

- ``mode`` -- the allowed values for mode are: ``'val-unit'``,
``'series'``, ``'terse'``, ``'digits'`` and ``'bars'``:
``'series'``, ``'terse'``, ``'digits'``, ``'digits-unicode'``
and ``'bars'``:

- ``'val-unit'`` -- elements are displayed as a power of the
uniformizer times a unit, which is displayed in terse mode
Expand All @@ -338,6 +342,9 @@ cdef class pAdicPrinter_class(SageObject):
extensions (or trivial extensions), elements are displayed as just
a string of `p`-adic digits, encoded using the 'alphabet' parameter

- ``'digits-unicode'`` -- like ``'digits'``, but uses the unicode
ellipsis character to indicate omitted leading digits

- ``'bars'`` -- like ``'digits'``, but uses a separator in order to
print a more canonical representation for each digit. This change
allows the use of this printing mode for unramified extensions and
Expand All @@ -355,7 +362,8 @@ cdef class pAdicPrinter_class(SageObject):
generator of this extension ring or field

- ``max_ram_terms`` -- controls the maximum number of terms shown when
printing in ``'series'``, ``'digits'`` or ``'bars'`` mode
printing in ``'series'``, ``'digits'``, ``'digits-unicode'`` or
``'bars'`` mode

- ``max_unram_terms`` -- for rings with non-prime residue fields,
controls how many terms appear in the coefficient of each pi^n when
Expand All @@ -368,7 +376,8 @@ cdef class pAdicPrinter_class(SageObject):
- ``sep`` -- controls the separator used in ``'bars'`` mode

- ``alphabet`` -- controls the alphabet used to translate `p`-adic digits
into strings (so that no separator need be used in ``'digits'`` mode)
into strings (so that no separator need be used in ``'digits'``
or ``'digits-unicode'`` mode)

- ``show_prec`` -- Specify how the precision is printed; it can be
``'none'``, ``'bigoh'`` or ``'dots'`` (the latter being not available
Expand Down Expand Up @@ -417,7 +426,7 @@ cdef class pAdicPrinter_class(SageObject):
elif mode == 'bars':
self.mode = bars
else:
raise ValueError("printing mode must be one of 'val-unit', 'series', 'terse', 'digits' or 'bars'")
raise ValueError("printing mode must be one of 'val-unit', 'series', 'terse', 'digits', 'digits-unicode' or 'bars'")
if ram_name is None:
self.ram_name = ring._uniformizer_print()
else:
Expand Down Expand Up @@ -912,11 +921,11 @@ cdef class pAdicPrinter_class(SageObject):
sage: print(a.str('series'))
3*7 + 7^3 + O(7^5)
sage: padic_printing.sep('')
sage: K = Qp(7, print_mode='digits')
sage: K = Qp(7, print_mode='digits-unicode')
sage: repr(K(1/2))
'...33333333333333333334'
'33333333333333333334'
sage: repr(K(1/42))
'...5555555555555555555.6'
'5555555555555555555.6'
sage: padic_printing.sep('|')
sage: repr(Qp(97, print_mode='bars')(1/13))
'...29|82|7|44|74|59|67|14|89|52|22|37|29|82|7|44|74|59|67|15'
Expand All @@ -925,9 +934,9 @@ cdef class pAdicPrinter_class(SageObject):

Check that :issue:`24843` is resolved::

sage: R = Zp(2, print_mode='digits', show_prec=True)
sage: R = Zp(2, print_mode='digits-unicode', show_prec=True)
sage: repr(R(0,10))
'...0000000000'
'0000000000'
"""
s = ""
if self.show_prec == "dots":
Expand Down
Loading