Skip to content

error checking should be performed as early as possible (here: non-ASCII str's in e.g. ylabel()) #2560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hmeine opened this issue Oct 30, 2013 · 10 comments
Labels
MEP: MEP13 artist properties New feature
Milestone

Comments

@hmeine
Copy link
Contributor

hmeine commented Oct 30, 2013

When using set_ylabel('Täst') in the ipython notebook, there will not be any plot, but also no error message visible. The real problem is that the notebook does not show exceptions that happen in draw(), but also in the console ipython, an exception raised by set_ylabel() itself would be rendered much better than the one coming asynchroneously from draw().

If possible, an exception like this one:

  File "/usr/lib/pymodules/python2.7/matplotlib/cbook.py", line 1797, in is_math_text
    "matplotlib display text must have all code points < 128 or use "
ValueError: matplotlib display text must have all code points < 128 or use Unicode strings

should already be raised in the Text() constructor (or whereever appropriate).

@hmeine
Copy link
Contributor Author

hmeine commented Oct 30, 2013

ipython/ipython#3922 is related, but I would like to see this tackled in MPL, too.

@mdboom
Copy link
Member

mdboom commented Oct 30, 2013

MEP13 is related to this.

@hmeine
Copy link
Contributor Author

hmeine commented Oct 30, 2013

MEP13 is about using properties; I guess you meant MEP14 ("… improving the text handling …"):
https://github.com/matplotlib/matplotlib/wiki/Mep14

@mdboom
Copy link
Member

mdboom commented Oct 30, 2013

Nope -- by using properties as in MEP13, we will be performing error checking of values much earlier than we are now.

@hmeine
Copy link
Contributor Author

hmeine commented Oct 30, 2013

I considered that interpretation, too, but properties would just be a syntactic change, no? I mean - the same check could be in the setter today?!

If you want to introduce something like traits, that'd be something different, but MEP13 did not seem to discuss traits, but just the leaving-out-the-parentheses part?

@mdboom
Copy link
Member

mdboom commented Oct 30, 2013

That's true -- I just meant to link this issue as one of many that we have that would benefit from more consistent use of setters/properties/traits. You're right that the underlying technology barely matters -- it's a matter of checking in a single place as early as possible.

@tacaswell tacaswell added this to the v1.5.x milestone Aug 17, 2014
@petehuang
Copy link
Contributor

What's the exact action for MPL for this issue?

@WeatherGod
Copy link
Member

WeatherGod commented Jan 6, 2017 via email

@petehuang
Copy link
Contributor

For visitor reference, traitlets discussion/work sitting in #4762.

Guess we can leave this open (...ugh) but need to remember to come back to this once traitlets work is complete

@anntzer
Copy link
Contributor

anntzer commented Aug 31, 2017

set_ylabel raises an exception now

$ python2 -c 'from pylab import *; gca().set_ylabel("Täst")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 254, in set_ylabel
    return self.yaxis.set_label_text(ylabel, fontdict, **kwargs)
  File "/usr/lib/python2.7/site-packages/matplotlib/axis.py", line 1505, in set_label_text
    self.label.set_text(label)
  File "/usr/lib/python2.7/site-packages/matplotlib/text.py", line 1212, in set_text
    self._text = '%s' % (s,)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

so closing (unless I'm mistaken?). The traitlets work is tracked in a number of other issues.

@anntzer anntzer closed this as completed Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MEP: MEP13 artist properties New feature
Projects
None yet
Development

No branches or pull requests

6 participants