[Scipy-svn] r2488 - trunk/Lib/sandbox/timeseries/mtimeseries
scipy-svn at scipy.org
scipy-svn at scipy.org
Thu Jan 4 11:42:33 EST 2007
Author: pierregm
Date: 2007-01-04 10:42:30 -0600 (Thu, 04 Jan 2007)
New Revision: 2488
Modified:
trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG
trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py
trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py
Log:
Modified: trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG
===================================================================
--- trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG 2007-01-04 16:09:52 UTC (rev 2487)
+++ trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG 2007-01-04 16:42:30 UTC (rev 2488)
@@ -1,3 +1,5 @@
+#2007-01-04 : tsdate
+# : - Corrected a bug w/ Date.__init__ and 'B' freq
#2007-01-03 : tseries
# : - Allowed endpoints adjustment after convert
# : - Put the estimation of the data length in its own function.
Modified: trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py
===================================================================
--- trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-04 16:09:52 UTC (rev 2487)
+++ trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-04 16:42:30 UTC (rev 2488)
@@ -123,7 +123,7 @@
if self.freq == 'A':
self.mxDate = mxD.Date(value, -1, -1)
elif self.freq == 'B':
- value -= 1
+ value = value - 1
self.mxDate = mxD.DateTimeFromAbsDays(value + (value//5)*7 - (value//5)*5)
elif self.freq in ['D','U']:
self.mxDate = mxD.DateTimeFromAbsDays(value-1)
@@ -744,6 +744,17 @@
if fromnumeric.size(c) == 0:
raise ValueError, "Date out of bounds!"
return c
+# def find_dates_alt(self, *dates):
+# "Returns the indices corresponding to given dates, as an array."
+# ifreq = self.freq
+# c = numpy.zeros(self.shape, bool_)
+# dates = date_array([d for d in corelib.flatargs(*dates)]).asfreq(ifreq)
+# for d in numeric.asarray(dates):
+# c += (self == d)
+# c = c.nonzero()
+# if fromnumeric.size(c) == 0:
+# raise ValueError, "Date out of bounds!"
+# return c
def date_to_index(self, date):
"Returns the index corresponding to one given date, as an integer."
if self.isvalid():
Modified: trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py
===================================================================
--- trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-04 16:09:52 UTC (rev 2487)
+++ trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-04 16:42:30 UTC (rev 2488)
@@ -1002,7 +1002,7 @@
end_date = min(end_date, dend) + 1
newseries[start_date:end_date] = a[start_date:end_date]
return newseries
-#..........................................................
+#....................................................................
def align_series(*series, **kwargs):
"""Aligns several TimeSeries, so that their starting and ending dates match.
Series are resized and filled with mased values accordingly.
@@ -1038,8 +1038,7 @@
return [adjust_endpoints(x, start_date, end_date) for x in series]
aligned = align_series
-
-
+#....................................................................
def convert(series, freq, func='auto', position='END', interp=None):
"""Converts a series to a frequency
@@ -1103,7 +1102,7 @@
start_date=newStart)
return adjust_endpoints(newseries, end_date=newEnd)
TimeSeries.convert = convert
-
+#....................................................................
def fill_missing_dates(data, dates=None, freq=None,fill_value=None):
"""Finds and fills the missing dates in a time series.
The data corresponding to the initially missing dates are masked, or filled to
@@ -1120,9 +1119,9 @@
Default value for missing data. If None, the data are just masked.
"""
freq = corelib.fmtFreq(freq)
-# if freq == 'U':
-# raise ValueError,\
-# "Unable to define a proper date resolution (found %s)." % freq
+ if freq == 'U':
+ raise ValueError,\
+ "Unable to define a proper date resolution (found %s)." % freq
if dates is None:
if not isTimeSeries(data):
raise InsufficientDateError
@@ -1150,7 +1149,7 @@
newdates = date_array(start_date=tstart, end_date=tend, include_last=True)
nsize = newdates.size
#.............................
- # Get the steps between consecutive data. We need relativedelta to deal w/ months
+ # Get the steps between consecutive data.
delta = dflat.get_steps()-1
gap = delta.nonzero()
slcid = numpy.r_[[0,], numpy.arange(1,n)[gap], [n,]]
More information about the Scipy-svn
mailing list