[SciPy-Dev] Unexpected behaviour from timeseries.filled (in Python 2.7)
Åsmund Hjulstad
asmund.hjulstad@gmail....
Mon Sep 6 10:32:35 CDT 2010
2010/9/6 Åsmund Hjulstad <asmund.hjulstad@gmail.com>:
> It seems something in Python 2.7 / Numpy 1.5 (or my Python 2.7
> installation) is breaking scikits.timeseries.filled
>
> import scikits.timeseries
> from numpy import array
> t3 = scikits.timeseries.time_series(array([0.]),
> mask=[True],dates=['2010-Aug'],freq='M')
> t3.fill_value= 0.
> print(t3)
> print(t3.data)
> print(t3.fill_value)
> print(t3.filled()) # It seems it ignores the fill_value parameter
> print(t3.filled(0.))
> , but in Python 2.7 I get:
> c:\python27\python scikits_bug.py
> [--]
> [ 0.]
> 0.0
> [ 1.00000000e+20] # This must be wrong!
> [ 0.]
After some debugging, I found out the following:
the TimeSeries.filled() method does this:
result = self._series.filled(fill_value=fill_value).view(type(self))
somehow, the _series view does not retain the fill value.
replacing this with (around line 1217 in tseries.py)
result = MaskedArray.filled(self,fill_value=fill_value).view(type(self))
things work better (for me, at least)
Regards,
Åsmund Hjulstad
More information about the SciPy-Dev
mailing list