some funny behavior on the trunk

On the trunk, the following script will show an image but will not rescale it:

im=imshow(rand(10,10))
im.set_clim(0,0.2)
draw()

It works on the maintenance branch.

I see that too -- and another image related bug:

In [177]: imshow(rand(10,10))
Out[177]: <matplotlib.image.AxesImage object at 0x1003acec>

In [178]: hot()

    Traceback (most recent call last):
      File "<ipython console>", line 1, in ?
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/pyplot.py",
line 2305, in hot
        draw_if_interactive()
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py",
line 58, in draw_if_interactive
        figManager.show()
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py",
line 338, in show
        self.canvas.draw()
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py",
line 191, in draw
        FigureCanvasAgg.draw(self)
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py",
line 255, in draw
        self.figure.draw(self.renderer)
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/figure.py",
line 792, in draw
        for a in self.axes: a.draw(renderer)
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/axes.py",
line 1394, in draw
        im.draw(renderer)
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/image.py",
line 226, in draw
        im = self.make_image(renderer.get_image_magnification())
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/image.py",
line 182, in make_image
        im.is_grayscale = self.cmap.is_gray()
      File "/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/colors.py",
line 504, in is_gray
        return (np.alltrue(self._lut[:,0] == self._lut[:,1])
    AttributeError: LinearSegmentedColormap instance has no attribute '_lut'

I thought at first all I would need to do is add an _init call in is_gray:

    def is_gray(self):
        if not self._isinit: self._init()
        return (np.alltrue(self._lut[:,0] == self._lut[:,1])
                    and np.alltrue(self._lut[:,0] == self._lut[:,2]))

which does indeed stop the exception but there is the same problem you
point to: the image is not updated. I don't have time to drill into
this one right now, but they are probably the same bug. I'm
committing the is_gray lut bugfix and punting on the deeper bug for
now.

···

On Tue, May 27, 2008 at 3:55 PM, Darren Dale <darren.dale@...143...> wrote:

On the trunk, the following script will show an image but will not rescale it:

im=imshow(rand(10,10))
im.set_clim(0,0.2)
draw()

> On the trunk, the following script will show an image but will not
> rescale it:
>
> im=imshow(rand(10,10))
> im.set_clim(0,0.2)
> draw()

I see that too -- and another image related bug:

[...]

which does indeed stop the exception but there is the same problem you
point to: the image is not updated. I don't have time to drill into
this one right now, but they are probably the same bug. I'm
committing the is_gray lut bugfix and punting on the deeper bug for
now.

It truns out this was introduced a while back, in commit 5042. Eric, according
to the changelog you were working on speeding up panning and zooming of dense
images, do you have time to revisit it?

Darren

···

On Tuesday 27 May 2008 5:22:00 pm John Hunter wrote:

On Tue, May 27, 2008 at 3:55 PM, Darren Dale <darren.dale@...143...> wrote:

> > On the trunk, the following script will show an image but will not
> > rescale it:
> >
> > im=imshow(rand(10,10))
> > im.set_clim(0,0.2)
> > draw()
>
> I see that too -- and another image related bug:
[...]
> which does indeed stop the exception but there is the same problem you
> point to: the image is not updated. I don't have time to drill into
> this one right now, but they are probably the same bug. I'm
> committing the is_gray lut bugfix and punting on the deeper bug for
> now.

It truns out this was introduced a while back, in commit 5042. Eric, according
to the changelog you were working on speeding up panning and zooming of dense
images, do you have time to revisit it?

If I fouled it up--as evidently I did--I would like to fix it. I will
take a first look at it this evening.

Eric

···

On Tue, 2008-05-27 at 18:44 -0400, Darren Dale wrote:

On Tuesday 27 May 2008 5:22:00 pm John Hunter wrote:
> On Tue, May 27, 2008 at 3:55 PM, Darren Dale <darren.dale@...143...> > wrote:

Darren

FYI, this bug is only exposed in interactive use since the caching is
triggered by the first draw.

The problem is with the image.AxesImage._rgbacache -- it is not being
cleared with a set_clim or a set_cmap. I am going to commit a
preliminary fix which simply resets this on any call to
image.AxesImage.changed and if there is a better place to do the reset
vis-a-vis the optimization you are trying to capture, please modify as
necessary.

JDH

···

On Tue, May 27, 2008 at 6:40 PM, Eric Firing <efiring@...229...> wrote:

If I fouled it up--as evidently I did--I would like to fix it. I will
take a first look at it this evening.

John Hunter wrote:

The problem is with the image.AxesImage._rgbacache -- it is not being
cleared with a set_clim or a set_cmap. I am going to commit a
preliminary fix which simply resets this on any call to
image.AxesImage.changed and if there is a better place to do the reset
vis-a-vis the optimization you are trying to capture, please modify as
necessary.

John,

As far as I can see, you found the right solution. I don't think it interferes in any way with the optimizations.

Thank you.

Eric

···

JDH