[SciPy-User] [scikits-timeseries] Some problems with inheritance (begginer's question, long)

Paweł Rumian gorkypl@gmail....
Sat Oct 2 08:39:12 CDT 2010


hello,

I'm using Python to do scientfic research - most of the time I'm
analysing meteorogical data (mainly from gas chromatographs).
I'm not an experienced programmer. I learned C and Pascal quite a long
time ago, and then discovered Python, which quickly became my main
tool to do day-to-day tasks, but I never went 'deeper'. I've also
never touched object-oriented programming.

Last year I've written a bunch of programs using scikits-timeseries -
it's certainly one of the most important modules I use. Everything
works flawlessly, but the demands are increasing and currently I have
to add some kind of GUI and web interface to my tools. So I recently
decided to rewrite my code using object-oriented approach - which
means that I needed to learn OOP, which I have never tried before.

After some reading I decided to extend TimeSeries class with a few
methods that are specific to chomatographic data.
The problem is that some of my methods work, but some not. I suspect
that it is somehow connected with inheritance, but so far I cannot
resolve it on my own...

I define the class like this:

class ChromaData(ts.TimeSeries):
    u"""Represents chromatographic timeseries data, inherits from TimeSeries."""

    def __init__(self,data,dates):
        super(ChromaData, self).__init__()

and initialize the instance with something like:

data_to_be_analyzed=
ChromaData(retrieved_timeseries.data,retrieved_timeseries.dates)

where retrived_timeseries is a TimeSeries instance, initialised using tsfromtxt.

Then I define methods inside the ChromaData. Some of them (the simpler
ones) work, but some don't. An example of such not working method is
the one that I used to retrieve the lower envelope of data:

    def daily_bottom(self):
        u"""Returns bottom envelope of input data, optimised for data
with daily frequency."""

        daily_interpolated= ipl.interp_masked1d(self, kind='linear')
        minima_of_daily_interpolated= mvf.mov_min(daily_interpolated,span=8)
        minima_of_daily_minima= mvf.mov_min(minima_of_daily_interpolated,span=8)

        return minima_of_daily_minima

what I get is:

Traceback (most recent call last):
  File "process.py", line 118, in <module>
    dbottom= test_data.daily_bottom()
  File "process.py", line 75, in daily_bottom
    daily_interpolated= ipl.interp_masked1d(self, kind='linear')
  File "/usr/lib/python2.6/site-packages/scikits/timeseries/lib/interpolate.py",
line 125, in interp_masked1d
    marr = marray(marr, copy=True)
  File "/usr/lib/python2.6/site-packages/numpy/ma/core.py", line 5491, in array
    fill_value=fill_value, ndmin=ndmin, shrink=shrink)
TypeError: __init__() got an unexpected keyword argument 'fill_value'

Does it mean that I need to pass every possible argument of TimeSeries
in __init__?
Like def __init__(self,data,dates, fill_value=None, dtype=None,...........) ?
Or am I doing something completely wrong?

Like I've written - I'm completely new to object-oriented programming,
so excuse me if the problem is really trivial...

greetings,
Paweł


More information about the SciPy-User mailing list