Skip to content
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

BUG: recent numpy fails on non-int shape #5297

Merged
merged 2 commits into from Oct 22, 2015

Conversation

perimosocordiae
Copy link
Contributor

With the current numpy master branch, the WebAgg backend fails during the draw() method

 File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.5.0rc2+149.g50f373f-py2.7-linux-x86_64.egg/matplotlib/backends/backend_webagg_core.py", line 287, in handle_event
    self.draw()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.5.0rc2+149.g50f373f-py2.7-linux-x86_64.egg/matplotlib/backends/backend_webagg_core.py", line 181, in draw
    self.manager.refresh_all()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.5.0rc2+149.g50f373f-py2.7-linux-x86_64.egg/matplotlib/backends/backend_webagg_core.py", line 473, in refresh_all
    diff = self.canvas.get_diff_image()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.5.0rc2+149.g50f373f-py2.7-linux-x86_64.egg/matplotlib/backends/backend_webagg_core.py", line 211, in get_diff_image
    buff.shape = (renderer.height, renderer.width)
TypeError: 'numpy.float64' object cannot be interpreted as an index

This patch remedies the problem, though not at its source. It might be useful to track down what causes the width and height to be float64 in the first place.

@jenshnielsen jenshnielsen added this to the next point release (1.5.0) milestone Oct 21, 2015
@perimosocordiae
Copy link
Contributor Author

The Travis failures seem to be unrelated to this change.

@mdboom
Copy link
Member

mdboom commented Oct 21, 2015

Thanks for noticing and providing a fix. I wonder if we could track down why renderer.width and renderer.height are floats in the first place. It's kind of nonsensical for them to be that.

@mdboom mdboom self-assigned this Oct 22, 2015
@mdboom mdboom modified the milestones: next bug fix release (2.0.1), next point release (1.5.0) Oct 22, 2015
@mdboom
Copy link
Member

mdboom commented Oct 22, 2015

I'm remilestoning this -- as it doesn't affect released versions of numpy, I don't think we need to worry about it for 1.5.0

@efiring
Copy link
Member

efiring commented Oct 22, 2015

@mdboom, isn't this a time-bomb? If the root problem isn't apparent, I would be inclined to accept the patch with the addition of a comment as to its rationale. The requirement that indices be integers is already in effect; I see it in python 3.4 with numpy 1.10.1 at least.

@mdboom
Copy link
Member

mdboom commented Oct 22, 2015

No, I think we need to get to the root of the problem, not pave it over like this. I can't reproduce on 1.5.x with Python 2.7/3.4 or 3.5 with Numpy 1.10.1. That's what lead me to postpone this, given that 1.5.0 is already way overdue. Can you reproduce it with a released Numpy?

@efiring
Copy link
Member

efiring commented Oct 22, 2015

I don't even know how to to try to reproduce it. I'm OK with your decision.

@mdboom
Copy link
Member

mdboom commented Oct 22, 2015

I can't even get matplotlib to build with numpy master right now. @perimosocordiae: What was your last working Numpy git hash?

@perimosocordiae
Copy link
Contributor Author

Here's a script that reproduces the error for me:

import matplotlib
matplotlib.use('webagg')
from matplotlib import pyplot as plt
import numpy as np

print 'numpy:', np.__version__
print 'MPL:', matplotlib.__version__

plt.figure()
plt.plot([0,1,0.5,2,1,3])
plt.show()

The versions reported are:

numpy: 1.11.0.dev0+e24895c
MPL: 1.5.0rc2+149.g50f373f

I built matplotlib using that numpy version without issues on Ubuntu 14.10 with Python 2.7.8.

@perimosocordiae
Copy link
Contributor Author

I've tracked down where the floats are coming from: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_webagg_core.py#L251

The bbox object stores its data as numpy floats. I'll update the PR shortly.

@mdboom
Copy link
Member

mdboom commented Oct 22, 2015

Great. Thanks for tracking this down.

@mdboom mdboom modified the milestones: next point release (1.5.0), next bug fix release (2.0.1) Oct 22, 2015
mdboom added a commit that referenced this pull request Oct 22, 2015
BUG: recent numpy fails on non-int shape
@mdboom mdboom merged commit f184f2d into matplotlib:master Oct 22, 2015
mdboom added a commit that referenced this pull request Oct 22, 2015
BUG: recent numpy fails on non-int shape
@mdboom
Copy link
Member

mdboom commented Oct 22, 2015

Backported to v1.5.x as 921aa41

@perimosocordiae perimosocordiae deleted the patch-1 branch October 22, 2015 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants