#13161: Fix unicode issue in axes labels
----------------------------+-----------------------------------------------
Reporter: kcrisman | Owner: jason, was
Type: defect | Status: new
Priority: major | Milestone: sage-5.2
Component: graphics | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
----------------------------+-----------------------------------------------
Comment (by slabbe):
I came up with this bug yesterday. Here are the notes I took :
The following works:
{{{
sage: c = circle((0,0), 1)
sage: c.axes_labels(['X', 'Y'])
sage: c
}}}
Accent in normal string gets a !ValueError:
{{{
sage: c.axes_labels(['an accent : é', 'Y'])
sage: c
Traceback (most recent call last):
...
ValueError: matplotlib display text must have all code points < 128 or use
Unicode strings
}}}
Accent in unicode string gets translated to str which yields a
!UnicodeError :
{{{
sage: c.axes_labels([u'an accent : é', 'Y'])
Traceback (most recent call last):
...
--> 634 self.__axes_labels = (str(l[0]), str(l[1]))
...
UnicodeEncodeError: 'ascii' codec can't encode characters in position
12-13: ordinal not in range(128)
}}}
Not declaring the unicode for command {{{text}}} also gives a !ValueError:
{{{
sage: text('an accent : é', (0,0))
Traceback (most recent call last):
...
ValueError: matplotlib display text must have all code points < 128 or use
Unicode strings
}}}
But declaring unicode works for command {{{text}}}. Although, no error are
raised, the result is not good : the "é" gets printed as the two
characters "~A commercial c" :
{{{
sage: text(u'an accent : é', (0,0))
}}}
Strangely it gets printed correctly if the command is written in a file
(without declaring encoding) and then attached :
{{{
# file.sage
t = text(u'an accent : é', (0,0))
}}}
and then
{{{
sage: attach file.sage
sage: t
}}}
is perfect! This shows that somehow matplotlib is able to work with
unicode strings. We just have to make it work properly.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13161#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.