Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#15 more duck typing

Improvement
open
Core (6)
5
2007-01-31
2007-01-28
Jan Strube
No

I noticed that at least in the CloudXD classes, PAIDA uses the types library.
This is very inconvenient for use with numpy arrays.
For example, the following diff shows how to make use of duck typing in Cloud1D.
Index: paida/paida_core/ICloud1D.py
===================================================================
RCS file: /cvsroot/paida/paida/paida/paida_core/ICloud1D.py,v
retrieving revision 1.15
diff -r1.15 ICloud1D.py
89c89
< if isinstance(data1, types.ListType) and (data2 == None) and (data3 == None):
---
> if hasattr(data1, '__iter__') and (data2 == None) and (data3 == None):

This can easily be extended to the other methods as well. The reason is that it will be easier to integrate with numpy/scipy.

Oh, and something else:
Maybe I'm the only one who thinks so, but could the creation of threads and the gui initialization be moved to the PlotterFactory? Or at least out of the default library.
I use paida mainly for histogramming of data, and hardly use the plotting at all. In fact, most of the time I work remotely.
So I have to import the guiselector and choose the batch backend to prevent paida from opening a window every time I want to inspect a file.

Discussion

  • Koji Kishimoto
    Koji Kishimoto
    2007-01-31

    Logged In: YES
    user_id=734761
    Originator: NO

    Thanks for your patch!
    I've checked new files into CVS.

    When you work remotely, simply passing "--gui=batch" argument to command line has any trouble?

     
  • Koji Kishimoto
    Koji Kishimoto
    2007-01-31

    • labels: --> Core
    • milestone: --> Improvement
    • assigned_to: nobody --> korry
     
  • Jan Strube
    Jan Strube
    2007-01-31

    Logged In: YES
    user_id=1366327
    Originator: YES

    Thanks for the update.
    There's no problem in principle with --gui=batch, but I would have to do it _every_ time.
    Maybe it's not a big deal. I can just import the gui selector before importing paida.

    I'm really doing most of the plotting in matplotlib at the moment.
    That isn't really paida's fault, but the AIDA API for plotting is way too verbose for my taste. I think it shows its Java background.
    Maybe paida could get a better API added, something more pythonic, like matplotlib that supports the shorthand pylab interface, but underneath everything is done OO.
    That way people with AIDA background could still use it and interoperate with the AIDA file format, but people with a preference for Python don't have to be so verbose.

    Well, don't worry. I'm not suggesting anything here, just thinking out loud. I'm sure I'll send more patches as my analysis (hopefully) progresses.

    Cheers,
    Jan