Broken qt backend.

Hi,

Using pylab svn, the qt backend is broken.

import pylab fails :

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_qtagg.py
     11
     12 from backend_agg import FigureCanvasAgg
---> 13 from backend_qt import qt, FigureManagerQT, FigureCanvasQT,\
     14 show, draw_if_interactive, backend_version, \
     15 NavigationToolbar2QT

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_qt.py
     15 from matplotlib.widgets import SubplotTool
     16
---> 17 import qt
     18
     19 backend_version = "0.9.1"

ImportError: No module named qt

If I replace import qt by import PyQt4, I get another error :
/usr/lib/python2.4/site-packages/matplotlib/backends/backend_qt.py
     22 DEBUG = False
     23
---> 24 cursord = {
     25 cursors.MOVE : qt.Qt.PointingHandCursor,
     26 cursors.HAND : qt.Qt.WaitCursor,

It is a well known problem ?
What could I do to help to debug that?

Xavier

···

--
############################################
Xavier Gnata
CRAL - Observatoire de Lyon
9, avenue Charles Andr�
69561 Saint Genis Laval cedex
Phone: +33 4 78 86 85 28
Fax: +33 4 78 86 83 86
E-mail: gnata@...419...
############################################

Hi,

Using pylab svn, the qt backend is broken.

import pylab fails :

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_qtagg.py
     11
     12 from backend_agg import FigureCanvasAgg
---> 13 from backend_qt import qt, FigureManagerQT, FigureCanvasQT,\
     14 show, draw_if_interactive, backend_version, \
     15 NavigationToolbar2QT

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_qt.py
     15 from matplotlib.widgets import SubplotTool
     16
---> 17 import qt
     18
     19 backend_version = "0.9.1"

ImportError: No module named qt

That means you dont have PyQt-3 installed on your machine.

If I replace import qt by import PyQt4

dont!

, I get another error :

If you want to use PyQt4, you should set your backend to qt4agg instead of
qtagg.

···

On Saturday 11 August 2007 8:15:41 am Xavier Gnata wrote:

Darren Dale wrote:

  

Hi,

Using pylab svn, the qt backend is broken.

import pylab fails :

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_qtagg.py
     11
     12 from backend_agg import FigureCanvasAgg
---> 13 from backend_qt import qt, FigureManagerQT, FigureCanvasQT,\
     14 show, draw_if_interactive, backend_version, \
     15 NavigationToolbar2QT

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_qt.py
     15 from matplotlib.widgets import SubplotTool
     16
---> 17 import qt
     18
     19 backend_version = "0.9.1"

ImportError: No module named qt
    
That means you dont have PyQt-3 installed on your machine.

If I replace import qt by import PyQt4
    
dont!

, I get another error :
    
If you want to use PyQt4, you should set your backend to qt4agg instead of qtagg.
  

OK my matplotlibrc was out of date. Now it works but I have found another but playing with the sliders of the backend:
As the log is quite long, here are only the most relevant parts :

imshow(a)
Out[7]: <matplotlib.image.AxesImage instance at 0xb262a8cc>

(play with the sliders of the qt4agg backend)

In [8]:

···

On Saturday 11 August 2007 8:15:41 am Xavier Gnata wrote:

---------------------------------------------------------------------------
exceptions.ValueError Python 2.4.4: /usr/bin/python
                                                   Mon Aug 13 00:58:56 2007
A problem occured executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_qt4.py in funcleft(self=<matplotlib.backends.backend_qt4.SubplotToolQt object>, val=900)

/usr/lib/python2.4/site-packages/matplotlib/figure.py in update(self=<matplotlib.figure.SubplotParams instance>, left=0.90000000000000002, bottom=None, right=None, top=None, wspace=None, hspace=None)
     71 self._update_this('top', top)
     72 self._update_this('wspace', wspace)
     73 self._update_this('hspace', hspace)
     74
     75 def reset():
     76 self.left = thisleft
     77 self.right = thisright
     78 self.top = thistop
     79 self.bottom = thisbottom
     80 self.wspace = thiswspace
     81 self.hspace = thishspace
     82
     83 if self.validate:
     84 if self.left>=self.right:
     85 reset()
---> 86 raise ValueError('left cannot be >= right')
        global ValueError = undefined
     87
     88 if self.bottom>=self.top:
     89 reset()
     90 raise ValueError('bottom cannot be >= top')
     91
     92
     93
     94 def _update_this(self, s, val):
     95 if val is None:
     96 val = getattr(self, s, None)
     97 if val is None:
     98 key = 'figure.subplot.' + s
     99 val = rcParams[key]
    100
    101 setattr(self, s, val)

ValueError: left cannot be >= right

**********************************************************************

Oops, IPython crashed. We do our best to make it stable, but...

It looks like that the ranges of the sliders are checked in a wrong way. It may be due to numerical rounding issues.

Xavier
....

OK my matplotlibrc was out of date. Now it works but I have found
another but playing with the sliders of the backend:
As the log is quite long, here are only the most relevant parts :

[...]

It looks like that the ranges of the sliders are checked in a wrong way.
It may be due to numerical rounding issues.

Unfortunately I have my hands full at work, so I don't know when I will be
able to look into this. I would need more information before I could start
anyway: a simple script and a list of steps that reproduces the problem, and
does it only occur with the qt4 backend.

Darren

···

On Sunday 12 August 2007 07:05:38 pm Xavier Gnata wrote:

Darren Dale wrote:

  

OK my matplotlibrc was out of date. Now it works but I have found
another but playing with the sliders of the backend:
As the log is quite long, here are only the most relevant parts :
    

[...]
  

It looks like that the ranges of the sliders are checked in a wrong way.
It may be due to numerical rounding issues.
    
Unfortunately I have my hands full at work, so I don't know when I will be able to look into this. I would need more information before I could start anyway: a simple script and a list of steps that reproduces the problem, and does it only occur with the qt4 backend.

Darren
  

Using Qt4Agg as backend :
import pylab
pylab.plot([1,2])
Then click on the "subplot configuration tool"
Move the "left" slider to the right end on the slider.
Python crashes because :

ValueError: left cannot be >= right

Using the TkAgg backend, I'm not able to reporduce the bug because it is not possbile to move the sliders to get left>=right (so there is no bug here :))

I had a quick look to the code and it looks like it is quite simple to fix that adding in backend_qt4.py a logic like:
if left>=right: left=right-right/1000.

The main problem is that I'm not sure to add this fix at the best place in the code.

Could someone else have a look?

Xavier

···

On Sunday 12 August 2007 07:05:38 pm Xavier Gnata wrote:

--
############################################
Xavier Gnata
CRAL - Observatoire de Lyon
9, avenue Charles Andr�
69561 Saint Genis Laval cedex
Phone: +33 4 78 86 85 28
Fax: +33 4 78 86 83 86
E-mail: gnata@...419...
############################################

This should be fixed in svn 3709. Thank you for the report and the suggested
fix. In the future, please try to provide a little more context for your
patch, the file is 550 lines long.

Darren

···

On Tuesday 14 August 2007 09:14:54 am Xavier Gnata wrote:

Darren Dale wrote:
> On Sunday 12 August 2007 07:05:38 pm Xavier Gnata wrote:
>> OK my matplotlibrc was out of date. Now it works but I have found
>> another but playing with the sliders of the backend:
>> As the log is quite long, here are only the most relevant parts :
>
> [...]
>
>> It looks like that the ranges of the sliders are checked in a wrong way.
>> It may be due to numerical rounding issues.
>
> Unfortunately I have my hands full at work, so I don't know when I will
> be able to look into this. I would need more information before I could
> start anyway: a simple script and a list of steps that reproduces the
> problem, and does it only occur with the qt4 backend.
>
> Darren

Using Qt4Agg as backend :
import pylab
pylab.plot([1,2])
Then click on the "subplot configuration tool"
Move the "left" slider to the right end on the slider.
Python crashes because :

ValueError: left cannot be >= right

Using the TkAgg backend, I'm not able to reporduce the bug because it is
not possbile to move the sliders to get left>=right (so there is no bug
here :))

I had a quick look to the code and it looks like it is quite simple to
fix that adding in backend_qt4.py a logic like:
if left>=right: left=right-right/1000.

The main problem is that I'm not sure to add this fix at the best place
in the code.

Darren Dale wrote:

···

On Tuesday 14 August 2007 09:14:54 am Xavier Gnata wrote:
  

Darren Dale wrote:
    

On Sunday 12 August 2007 07:05:38 pm Xavier Gnata wrote:
      

OK my matplotlibrc was out of date. Now it works but I have found
another but playing with the sliders of the backend:
As the log is quite long, here are only the most relevant parts :
        

[...]

It looks like that the ranges of the sliders are checked in a wrong way.
It may be due to numerical rounding issues.
        

Unfortunately I have my hands full at work, so I don't know when I will
be able to look into this. I would need more information before I could
start anyway: a simple script and a list of steps that reproduces the
problem, and does it only occur with the qt4 backend.

Darren
      

Using Qt4Agg as backend :
import pylab
pylab.plot([1,2])
Then click on the "subplot configuration tool"
Move the "left" slider to the right end on the slider.
Python crashes because :

ValueError: left cannot be >= right

Using the TkAgg backend, I'm not able to reporduce the bug because it is
not possbile to move the sliders to get left>=right (so there is no bug
here :))

I had a quick look to the code and it looks like it is quite simple to
fix that adding in backend_qt4.py a logic like:
if left>=right: left=right-right/1000.

The main problem is that I'm not sure to add this fix at the best place
in the code.
    
This should be fixed in svn 3709. Thank you for the report and the suggested fix. In the future, please try to provide a little more context for your patch, the file is 550 lines long.

Darren
  

It is fixed. Thanks.

Xavier
ps : I only provide developers with real unified diffs when I'm able to produce them :wink:

--
############################################
Xavier Gnata
CRAL - Observatoire de Lyon
9, avenue Charles Andr�
69561 Saint Genis Laval cedex
Phone: +33 4 78 86 85 28
Fax: +33 4 78 86 83 86
E-mail: gnata@...419...
############################################