abstraction and interfaces

Hello there, I use NumPy/SciPy to process telemetry, producing some metrics that I plot with matplotlib. Well, I want to package my scripts into a sort of all-wrapping application, i.e, the user just calls the app, selects which metrics to produce and waits to obtain the plots, without being exposed to anything more dangerous than a zoom button.. The scripts that produce these metrics use Scipy/Numpy functions that operate on data conveniently converted to numpy arrays. They're quite specific, and I tend to produce/tweak a lot of them. So, to fit in this application someone suggested I programmed 'interfaces' (in java jargon) to them - that way I could develop the whole wrapper application without giving much thought to the actual number-crunching bits. Problem is, I learnt numerics using Fortran, and though I understand the idea of objects, I have quite some difficulty imagining the 'patterns' that allow OO to be so flexible. So I was wondering if anyone experienced with OO Numerical computing could provide some pointers. For context, here are my thoughts: 1. the core of the application is responsible for interaction with the outside world. Crunching blocks are provided data and return matplotlib objects that go into GTK. To write procedures that abide to these parameters is my first (fortranic) impulse. But then I need to change the core everytime I add a procedure, and I'm limited to numpy-IN/matplolib-OUT. 2. if I could force every analysis procedure to be a class that implements its own data retrieval and outputs matplolib objects, my core no longer controls the whole communication with the outside world. And i still have to edit the core everytime a new analysis is required. A very interesting thing is that with these classes I could create new objects with different attributes, rather than pass a host of parameters to a procedure.. So, I'm a bit at odds with this brave new world I discovered. I'd be quite grateful for pointers on literature or examples that more or less lead to a solution. So far my searches have justified the need for objects, but not helped address this modularity requirement... Cheers, Renato

On Fri, 12 Oct 2007, Renato Serodio apparently wrote:
The scripts that produce these metrics use Scipy/Numpy functions that operate on data conveniently converted to numpy arrays. They're quite specific, and I tend to produce/tweak a lot of them. So, to fit in this application someone suggested I programmed 'interfaces' (in java jargon) to them - that way I could develop the whole wrapper application without giving much thought to the actual number-crunching bits.
That sounds quite right. Check out <URL:https://projects.scipy.org/scipy/scikits/browser/trunk/openopt/scikits/openo...> <URL:http://svn.scipy.org/svn/scipy/trunk/scipy/stats/models/> for examples that may be relevant to your project. Python does not have interfaces per se, but that does not stop you from designing interface-like classes and inheriting from them. fwiw, Alan Isaac

Hello there, thanks to your pointer, I've progressed further on the OO concept, and am currently building analysis, inputData and outputResults interfaces that should add some flexibility to my program. On the other hand, pulling the OO and interfaces string opened a box full of little critters, and now I'm learning about UML, some advanced class usage and so on. My brain hurts.. Cheers, Renato On 12/10/2007, Alan G Isaac <aisaac@american.edu> wrote:
On Fri, 12 Oct 2007, Renato Serodio apparently wrote:
The scripts that produce these metrics use Scipy/Numpy functions that operate on data conveniently converted to numpy arrays. They're quite specific, and I tend to produce/tweak a lot of them. So, to fit in this application someone suggested I programmed 'interfaces' (in java jargon) to them - that way I could develop the whole wrapper application without giving much thought to the actual number-crunching bits.
That sounds quite right. Check out <URL:https://projects.scipy.org/scipy/scikits/browser/trunk/openopt/scikits/openo...> <URL:http://svn.scipy.org/svn/scipy/trunk/scipy/stats/models/> for examples that may be relevant to your project.
Python does not have interfaces per se, but that does not stop you from designing interface-like classes and inheriting from them.
fwiw, Alan Isaac
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

What is more, with the concept of duck-typing, you just have to provide the interface without inheriting from a mother class (which is what I do for the optimizer framework, the other sub-modules do not derive from a common ancestor). Matthieu 2007/10/17, Renato Serodio <renato.serodio@gmail.com>:
Hello there,
thanks to your pointer, I've progressed further on the OO concept, and am currently building analysis, inputData and outputResults interfaces that should add some flexibility to my program.
On the other hand, pulling the OO and interfaces string opened a box full of little critters, and now I'm learning about UML, some advanced class usage and so on. My brain hurts..
Cheers,
Renato
On 12/10/2007, Alan G Isaac <aisaac@american.edu> wrote:
On Fri, 12 Oct 2007, Renato Serodio apparently wrote:
The scripts that produce these metrics use Scipy/Numpy functions that operate on data conveniently converted to numpy arrays. They're quite specific, and I tend to produce/tweak a lot of them. So, to fit in this application someone suggested I programmed 'interfaces' (in java jargon) to them - that way I could develop the whole wrapper application without giving much thought to the actual number-crunching bits.
That sounds quite right. Check out <URL: https://projects.scipy.org/scipy/scikits/browser/trunk/openopt/scikits/openo...
<URL:http://svn.scipy.org/svn/scipy/trunk/scipy/stats/models/> for examples that may be relevant to your project.
Python does not have interfaces per se, but that does not stop you from designing interface-like classes and inheriting from them.
fwiw, Alan Isaac
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
participants (3)
-
Alan G Isaac
-
Matthieu Brucher
-
Renato Serodio