Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
30689: make tests compatible with multiple python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mwageringel committed Oct 1, 2020
1 parent 1da6df4 commit f5a4e3d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/sage/rings/complex_number.pyx
Expand Up @@ -567,18 +567,16 @@ cdef class ComplexNumber(sage.structure.element.FieldElement):
+ 0.142857142857142857142857142857142857142857142857142857142857*I'
Note that the general format does not exactly match the behaviour of
``float``::
``float``. Some Python versions do not implement the full spec
(see :trac:`30689`)::
sage: format(CC(3, 0), '.4g')
'3.000 + 0e-15*I'
sage: format(CC(3, 0), '#.4g')
Traceback (most recent call last):
...
ValueError: invalid format string
sage: format(CC(0, 0), '+#.4')
Traceback (most recent call last):
...
ValueError: invalid format string
sage: try:
....: assert format(CC(3, 0), '#.4g') == '3.000 + 0.e-15*I'
....: assert format(CC(0, 0), '+#.4') == '+0.E-15'
....: except ValueError:
....: pass
"""
return _format_complex_number(self.real(), self.imag(), format_spec)

Expand Down

0 comments on commit f5a4e3d

Please sign in to comment.