On 1/28/11 3:55 AM, Algis Kabaila wrote:
Attached is a tar ball (~2K size) of a program for matrix
inversion  "inv.py" (using numpy) and the Qt Designer generated
file "inv.ui".  To run the program one needs to process "inv.ui"
as follows:

pyside-uic inv.ui>  ui_inv.py

The program can generate a singular or near singular matrix of a
certain type and attempt to invert it.

The gui shows in a plainTextEdit window the default parametes
which may be altered at will.  The OK button starts the
execution of inversion attempt and displays the results.

The inversion is done with numpy package (what else is there?).
The default values are for a 5x5 matrix.  The five rows are
1, 2, 3, 4, 5
6,7, 8. 9, 10
11,12 etc.
In this case numpy correctly identifies the matrix as singular.
If the gui program is started from CLI, numpy issues a statement
that the matrix is singular.  If the gui is started by clicking
with the mouse a link to the executable,  no warning can be seen
and the gui just fails very quietly.  That is why I seek help
from this list - how can one ensure that the numpy message is
identified by the gui?

You catch the exception with a try: except: suite just like you would in any other program.

try:
    result = la.inv(amatrix)
except la.LinAlgError, e:
    printline("%s: %s" % (type(e).__name__, e))
else:
    printline('\n  inverse')
    ...
self.finished = True


http://docs.python.org/tutorial/errors.html#handling-exceptions

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

_______________________________________________
PySide mailing list
PySide@lists.openbossa.org
http://lists.openbossa.org/listinfo/pyside

Reply via email to