Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix a warning when the aspect is a number#6279

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
kkdd wants to merge2 commits intomatplotlib:masterfromkkdd:master

Conversation

kkdd
Copy link

@kkddkkdd commentedApr 7, 2016

This PR fixes the following warning when usingplt.axes().set_aspect(1):

/usr/local/lib/python2.7/site-packages/matplotlib/axes/_base.py:1215: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal  if aspect == 'normal':/usr/local/lib/python2.7/site-packages/matplotlib/axes/_base.py:1220: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal  elif aspect in ('equal', 'auto'):

@mdboommdboom changed the titlefix a warning when the aspect is a numberfix a warning when the aspect is a numberApr 7, 2016
'1.2', name='normal', alternative='auto', obj_type='aspect')
self._aspect = 'auto'
else:
raise ValueError("error in aspect")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Needs a better error message, but otherwise, this makes sense to me.

@jenshnielsen
Copy link
Member

We don't see that warning in the tests. That probably means that there is no tests with aspect as a number. It would be good to add such a test

@QuLogic
Copy link
Member

Please reword your commit messages so that they indicate what you're actually doing instead of a generic "Update filename".

@tacaswell
Copy link
Member

I can not get this warning locally

In [47]:importmatplotlib.pyplotaspltIn [48]:plt.axes().set_aspect(1)In [49]:

@tacaswell
Copy link
Member

It looks like this is a python2 only issue and just a warning.

@tacaswelltacaswell added this to theunassigned milestoneApr 8, 2016
@tacaswell
Copy link
Member

I am 👎 on merging this.

@WeatherGod
Copy link
Member

how about a warning filter instead?

On Fri, Apr 8, 2016 at 12:10 AM, Thomas A Caswellnotifications@github.com
wrote:

I am [image: 👎] on merging this.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#6279 (comment)

@kkdd
Copy link
Author

kkdd commentedApr 9, 2016

Sorry.plt.axes().set_aspect(1) doesn't raise the unicodewarnings, butplt.axes().set_aspect(np.float64(1)) andplt.axes().set_aspect(scipy.sqrt(1)) do.

@kkdd
Copy link
Author

kkdd commentedApr 9, 2016

It seems to be a side effect offrom __future__ import unicode_literals, observed as follows:

$ python -c "from __future__ import unicode_literals;import numpy;print numpy.float64(1) == 'normal'"-c:1: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequalFalse$ pythonPython 2.7.11 (default, Dec  5 2015, 22:44:43) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwinType "help", "copyright", "credits" or "license" for more information.

@jenshnielsen
Copy link
Member

It will happen when ever you try to compare a numpy type to a unicode string. I.e.import numpy;print numpy.float64(1) == u'normal' also produces the warning.
One possbile way around it could be to verify that the aspect is a string before doing the comparison i.e. replace:
if aspect == 'normal':
with:
if isinstance(aspect, six.string_types) and aspect == 'normal':

it's not the cleanest and goes breaks normal python ducktypeing but gets the python2 behaviour closer to the python3 one.

@anntzer
Copy link
Contributor

Closed by#7658.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

7 participants
@kkdd@jenshnielsen@QuLogic@tacaswell@WeatherGod@anntzer@mdboom

[8]ページ先頭

©2009-2025 Movatter.jp