[SciPy-User] [scikits-timeseries] Some problems with inheritance (begginer's question, long)
Sat Oct 2 19:44:30 CDT 2010
Great, it works!
I've checked all methods, but somehow missed passing those
'additionalArgs=None' to __init__ - I probably thought it would make
no sense to initialize an instance with empty data and dates...
Anyway, thank you for the patience.
2010/10/3 J. David Lee <email@example.com>:
> It looks to me like ipl.interp_masked1d is calling the constructor of
> the ChromaData class. If this is the case, you'll have to make sure that
> the ChromaData constructor has the same signature as the TimeSeries
> constructor. You can pass `data' and `dates' as keyword arguments:
> class ChromaData(ts.TimeSeries):
> u"""Represents chromatographic timeseries data, inherits from TimeSeries."""
> def __init__(self, *args, data = None, dates = None, **kwargs):
> super(ChromaData, self).__init__(*args, **kwargs)
> Just be sure that you don't have problems when `data' and `dates' are
> This way when another part of the code tries to create a ChromaData
> object in place of a TimeSeries object it will work properly.
> On Sun, 2010-10-03 at 02:14 +0200, Paweł Rumian wrote:
>> Thank you J. David - your mail was a significant help. I've read about
>> *args and *kwargs, and they indeed seem to be important in such cases.
>> However I still cannot solve the problem... For me it seems that the
>> function interp_masked1d from scikits.timeseries.lib.interpolate won't
>> work with anything else than TimeSeries instance - or is it still me
>> doing something wrong, maybe with initializing the instance of
>> I'm trying to do is as simple as it could be - I stripped the whole
>> ChromaData Class to single __init__ method, like this:
>> class ChromaData(ts.TimeSeries):
>> u"""Represents chromatographic timeseries data, inherits from TimeSeries."""
>> def __init__(self,data,dates,*args,**kwargs):
>> super(ChromaData, self).__init__(*args,**kwargs)
>> Then I create a TimeSeries instance, loading it from file
>> (get_data_from_file is just a wrapper to ts.tsfromtxt), and a
>> ChromaData instance:
>> timeseries_instance= get_data_from_file('testdata.dat')
>> For certainity:
>> print (timeseries_instance.__class__)
>> <class 'scikits.timeseries.tseries.TimeSeries'>
>> print (chromadata_instance.__class__)
>> <class '__main__.ChromaData'>
>> And then I run
>> (everything is OK here)
>> and I get:
>> Traceback (most recent call last):
>> File "testcase.py", line 39, in <module>
>> 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__() takes at least 3 non-keyword arguments (2 given)
>> The whole code can be found at: http://pastebin.com/Vd3mCr8M
>> I've tried converting ChromaData instance to TimeSeries before feeding
>> interp_masked1d with it, like
>> chromadata_instance.dates), kind='linear')
>> and it works, but it's just a workaround...
>> Thank you for all possible help,
>> SciPy-User mailing list
> SciPy-User mailing list
More information about the SciPy-User