[Scipy-svn] r3595 - in branches/scipy.scons: . scipy/sandbox/timeseries scipy/sandbox/timeseries/src scipy/sandbox/timeseries/tests

scipy-svn@scip... scipy-svn@scip...
Sun Nov 25 23:33:45 CST 2007


Author: cdavid
Date: 2007-11-25 23:33:22 -0600 (Sun, 25 Nov 2007)
New Revision: 3595

Modified:
   branches/scipy.scons/
   branches/scipy.scons/scipy/sandbox/timeseries/dates.py
   branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py
   branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c
   branches/scipy.scons/scipy/sandbox/timeseries/src/c_tseries.c
   branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py
   branches/scipy.scons/scipy/sandbox/timeseries/tests/test_timeseries.py
   branches/scipy.scons/scipy/sandbox/timeseries/tseries.py
Log:
Merged revisions 3583-3593 via svnmerge from 
http://svn.scipy.org/svn/scipy/trunk

........
  r3589 | pierregm | 2007-11-25 02:43:31 +0900 (Sun, 25 Nov 2007) | 1 line
  
  plotlib : fixed a bug in _daily_finder and _annual_finder
........
  r3591 | mattknox_ca | 2007-11-26 02:47:23 +0900 (Mon, 26 Nov 2007) | 2 lines
  
  - changed relation parameter of asfreq functions/methods to accept 'START'/'END' ('BEFORE'/'AFTER' are now deprecated, but still work for now)
  - enhanced documentation for several functions
........



Property changes on: branches/scipy.scons
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk:1-3582
   + /trunk:1-3593

Modified: branches/scipy.scons/scipy/sandbox/timeseries/dates.py
===================================================================
--- branches/scipy.scons/scipy/sandbox/timeseries/dates.py	2007-11-26 05:32:08 UTC (rev 3594)
+++ branches/scipy.scons/scipy/sandbox/timeseries/dates.py	2007-11-26 05:33:22 UTC (rev 3595)
@@ -392,15 +392,35 @@
             self._cachedinfo['tostr'] = tostr
         return self._cachedinfo['tostr']
     #
-    def asfreq(self, freq=None, relation="AFTER"):
-        "Converts the dates to another frequency."
+    def asfreq(self, freq=None, relation="END"):
+        """Converts the dates to another frequency.
+
+*Parameters*:
+    freq : {freq_spec}
+        Frequency to convert the DateArray to. Accepts any valid frequency
+        specification (string or integer)
+    relation : {"END", "START"} (optional)
+        Applies only when converting a lower frequency Date to a higher
+        frequency Date, or when converting a weekend Date to a business
+        frequency Date. Valid values are 'START' and 'END'.
+       
+        For example, if converting a monthly date to a daily date, specifying
+        'START' ('END') would result in the first (last) day in the month.
+"""
         # Note: As we define a new object, we don't need caching
         if freq is None or freq == _c.FR_UND:
             return self
         tofreq = check_freq(freq)
         if tofreq == self.freq:
             return self
+
         _rel = relation.upper()[0]
+        
+        # support for deprecated values of relation parameter ('BEFORE' and
+        # 'AFTER')
+        if _rel == 'A': _rel = 'E'
+        if _rel == 'B': _rel = 'S'
+        
         fromfreq = self.freq
         if fromfreq == _c.FR_UND:
             fromfreq = _c.FR_DAY

Modified: branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py
===================================================================
--- branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py	2007-11-26 05:32:08 UTC (rev 3594)
+++ branches/scipy.scons/scipy/sandbox/timeseries/plotlib.py	2007-11-26 05:33:22 UTC (rev 3595)
@@ -223,7 +223,7 @@
                     info['fmt'][first_label(month_start)] = '%d\n%b\n%Y'
     # Case 2. Less than three months
     elif span <= periodsperyear//4:
-        month_start = period_break(dates,'month')
+        month_start = period_break(dates_,'month')
         info['maj'][month_start] = True
         info['min'] = True
         if asformatter:
@@ -287,7 +287,7 @@
             info['fmt'][year_start] = '%Y'
     # Case 6. More than 12 years ................
     else:
-        year_start = period_break(dates,'year')
+        year_start = period_break(dates_,'year')
         year_break = dates_[year_start].years
         nyears = span/periodsperyear
         (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears)

Modified: branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c
===================================================================
--- branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c	2007-11-26 05:32:08 UTC (rev 3594)
+++ branches/scipy.scons/scipy/sandbox/timeseries/src/c_dates.c	2007-11-26 05:33:22 UTC (rev 3595)
@@ -427,7 +427,7 @@
 ///////////////////////////////////////////////
 
 // frequency specifc conversion routines
-// each function must take an integer fromDate and a char relation ('B' or 'A' for 'BEFORE' or 'AFTER')
+// each function must take an integer fromDate and a char relation ('S' or 'E' for 'START' or 'END')
 
 //************ FROM DAILY ***************
 
@@ -487,7 +487,7 @@
     if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate,
                     GREGORIAN_CALENDAR)) return INT_ERR_CODE;
 
-    if (relation == 'B') {
+    if (relation == 'S') {
         return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week);
     } else {
         return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week);
@@ -512,7 +512,7 @@
 
 static long asfreq_DtoHIGHFREQ(long fromDate, char relation, long periodsPerDay) {
     if (fromDate >= HIGHFREQ_ORIG) {
-        if (relation == 'B') { return (fromDate - HIGHFREQ_ORIG)*(periodsPerDay) + 1; }
+        if (relation == 'S') { return (fromDate - HIGHFREQ_ORIG)*(periodsPerDay) + 1; }
         else                 { return (fromDate - HIGHFREQ_ORIG + 1)*(periodsPerDay); }
     } else { return -1; }
 }
@@ -568,7 +568,7 @@
 static long asfreq_TtoH(long fromDate, char relation, asfreq_info *af_info)
     { return (fromDate - 1)/60 + 1; }
 static long asfreq_TtoS(long fromDate, char relation, asfreq_info *af_info) {
-    if (relation == 'B') {  return fromDate*60 - 59; }
+    if (relation == 'S') {  return fromDate*60 - 59; }
     else                 {  return fromDate*60;      }}
 
 //************ FROM HOURLY ***************
@@ -593,7 +593,7 @@
 static long asfreq_HtoT(long fromDate, char relation, asfreq_info *af_info)
     { return asfreq_TtoS(fromDate, relation, &NULL_AF_INFO); }
 static long asfreq_HtoS(long fromDate, char relation, asfreq_info *af_info) {
-    if (relation == 'B') {  return fromDate*60*60 - 60*60 + 1; }
+    if (relation == 'S') {  return fromDate*60*60 - 60*60 + 1; }
     else                 {  return fromDate*60*60;             }}
 
 //************ FROM BUSINESS ***************
@@ -625,16 +625,16 @@
 //************ FROM WEEKLY ***************
 
 static long asfreq_WtoD(long fromDate, char relation, asfreq_info *af_info) {
-    if (relation == 'B') { return fromDate * 7 - 6 + af_info->from_week_end;}
+    if (relation == 'S') { return fromDate * 7 - 6 + af_info->from_week_end;}
     else                 { return fromDate * 7 + af_info->from_week_end; }
 }
 
 static long asfreq_WtoA(long fromDate, char relation, asfreq_info *af_info) {
-    return asfreq_DtoA(asfreq_WtoD(fromDate, 'A', af_info), relation, af_info); }
+    return asfreq_DtoA(asfreq_WtoD(fromDate, 'E', af_info), relation, af_info); }
 static long asfreq_WtoQ(long fromDate, char relation, asfreq_info *af_info) {
-    return asfreq_DtoQ(asfreq_WtoD(fromDate, 'A', af_info), relation, af_info); }
+    return asfreq_DtoQ(asfreq_WtoD(fromDate, 'E', af_info), relation, af_info); }
 static long asfreq_WtoM(long fromDate, char relation, asfreq_info *af_info) {
-    return asfreq_DtoM(asfreq_WtoD(fromDate, 'A', af_info), relation, &NULL_AF_INFO); }
+    return asfreq_DtoM(asfreq_WtoD(fromDate, 'E', af_info), relation, &NULL_AF_INFO); }
 
 static long asfreq_WtoW(long fromDate, char relation, asfreq_info *af_info)
     { return asfreq_DtoW(asfreq_WtoD(fromDate, relation, af_info), relation, af_info); }
@@ -645,7 +645,7 @@
     if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_WtoD(fromDate, relation, af_info),
                     GREGORIAN_CALENDAR)) return INT_ERR_CODE;
 
-    if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); }
+    if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); }
     else                 { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); }
 }
 
@@ -667,7 +667,7 @@
 
     long y, m, absdate;
 
-    if (relation == 'B') {
+    if (relation == 'S') {
         MtoD_ym(fromDate, &y, &m);
         if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE;
         return absdate;
@@ -679,10 +679,10 @@
 }
 
 static long asfreq_MtoA(long fromDate, char relation, asfreq_info *af_info) {
-    return asfreq_DtoA(asfreq_MtoD(fromDate, 'A', &NULL_AF_INFO), relation, af_info); }
+    return asfreq_DtoA(asfreq_MtoD(fromDate, 'E', &NULL_AF_INFO), relation, af_info); }
 
 static long asfreq_MtoQ(long fromDate, char relation, asfreq_info *af_info) {
-    return asfreq_DtoQ(asfreq_MtoD(fromDate, 'A', &NULL_AF_INFO), relation, af_info); }
+    return asfreq_DtoQ(asfreq_MtoD(fromDate, 'E', &NULL_AF_INFO), relation, af_info); }
 
 static long asfreq_MtoW(long fromDate, char relation, asfreq_info *af_info)
     { return asfreq_DtoW(asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); }
@@ -693,7 +693,7 @@
     if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_MtoD(fromDate, relation, &NULL_AF_INFO),
                     GREGORIAN_CALENDAR)) return INT_ERR_CODE;
 
-    if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); }
+    if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); }
     else                 { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); }
 }
 
@@ -722,7 +722,7 @@
 
     long y, m, absdate;
 
-    if (relation == 'B') {
+    if (relation == 'S') {
         QtoD_ym(fromDate, &y, &m, af_info);
         if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE;
         return absdate;
@@ -751,7 +751,7 @@
     if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation, af_info),
                     GREGORIAN_CALENDAR)) return INT_ERR_CODE;
 
-    if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); }
+    if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); }
     else                 { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); }
 }
 
@@ -773,7 +773,7 @@
     if (month == 0) { month = 1; }
     else { month += 1; }
 
-    if (relation == 'B') {
+    if (relation == 'S') {
         if (af_info->from_a_year_end == 12) {year = fromDate;}
         else {year = fromDate - 1;}
         final_adj = 0;
@@ -805,7 +805,7 @@
     if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_AtoD(fromDate, relation, af_info),
                     GREGORIAN_CALENDAR)) return INT_ERR_CODE;
 
-    if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); }
+    if (relation == 'S') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); }
     else                 { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); }
 }
 
@@ -1034,7 +1034,7 @@
             return 24*60*60 - 1;
     }
 
-    startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'B', periodsPerDay);
+    startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'S', periodsPerDay);
     return (24*60*60)*((double)(originalDate - startOfDay))/((double)periodsPerDay);
 }
 
@@ -1569,20 +1569,20 @@
         toDaily = get_asfreq_func(self->freq, FR_DAY, 0);
         get_asfreq_info(self->freq, FR_DAY, &af_info);
 
-        return PyInt_FromLong(toDaily(self->value, 'A', &af_info));
+        return PyInt_FromLong(toDaily(self->value, 'E', &af_info));
     }
 }
 
 static char DateObject_asfreq_doc[] =
 "Returns a date converted to a specified frequency.\n\n"
-":Parameters:\n"
-"   - freq : string/int\n"
-"       Frequency to convert the Date to. Accepts any valid frequency\n"
-"       specification (string or integer)\n"
-"   - relation :string *['After']*\n"
-"       Applies only when converting a lower frequency Date to a higher\n"
-"       frequency Date, or when converting a weekend Date to a business\n"
-"       frequency Date. Valid values are 'before', 'after', 'b', and 'a'.";
+"*Parameters*:\n"
+"    freq : {freq_spec}\n"
+"        Frequency to convert the Date to. Accepts any valid frequency\n"
+"        specification (string or integer)\n"
+"    relation : {'END', 'START'} (optional)\n"
+"        Applies only when converting a lower frequency Date to a higher\n"
+"        frequency Date, or when converting a weekend Date to a business\n"
+"        frequency Date. Valid values are 'START' and 'END'.";
 static PyObject *
 DateObject_asfreq(DateObject *self, PyObject *args, PyObject *kwds)
 {
@@ -1609,12 +1609,17 @@
             if((relation_uc = str_uppercase(relation_raw)) == NULL)
             {return PyErr_NoMemory();}
 
-            if (strcmp(relation_uc, "BEFORE") == 0 ||
+			// 'BEFORE' and 'AFTER' values for this parameter are deprecated
+            if (strcmp(relation_uc, "END") == 0 ||
+                strcmp(relation_uc, "E") == 0 ||
+                strcmp(relation_uc, "START") == 0 ||
+                strcmp(relation_uc, "S") == 0 ||
+                strcmp(relation_uc, "BEFORE") == 0 ||
                 strcmp(relation_uc, "B") == 0 ||
                 strcmp(relation_uc, "AFTER") == 0 ||
                 strcmp(relation_uc, "A") == 0) {
-                 if(relation_uc[0] == 'A') { relation = 'A'; }
-                 else { relation = 'B'; }
+                 if(relation_uc[0] == 'E' || relation_uc[0] == 'A') { relation = 'E'; }
+                 else { relation = 'S'; }
 
             } else { invalid_relation=1; }
 
@@ -1629,7 +1634,7 @@
             return NULL;
         }
     } else {
-        relation = 'A';
+        relation = 'E';
     }
 
     if ((toFreq = check_freq(freq)) == INT_ERR_CODE) return NULL;
@@ -1697,7 +1702,7 @@
     toDaily = get_asfreq_func(self->freq, FR_DAY, 0);
     get_asfreq_info(self->freq, FR_DAY, &af_info);
 
-    absdate = toDaily(self->value, 'A', &af_info);
+    absdate = toDaily(self->value, 'E', &af_info);
     abstime = getAbsTime(self->freq, absdate, self->value);
 
     if(dInfoCalc_SetFromAbsDateTime(&tempDate, absdate, abstime,
@@ -2384,7 +2389,7 @@
         get_asfreq_info(FR_SEC, freq_val, &af_info);
         asfreq_func = get_asfreq_func(FR_SEC, freq_val, 0);
 
-        date_val = asfreq_func(secondly_date->value, 'B', &af_info);
+        date_val = asfreq_func(secondly_date->value, 'S', &af_info);
 
         Py_DECREF(secondly_date);
 

Modified: branches/scipy.scons/scipy/sandbox/timeseries/src/c_tseries.c
===================================================================
--- branches/scipy.scons/scipy/sandbox/timeseries/src/c_tseries.c	2007-11-26 05:32:08 UTC (rev 3594)
+++ branches/scipy.scons/scipy/sandbox/timeseries/src/c_tseries.c	2007-11-26 05:33:22 UTC (rev 3595)
@@ -167,11 +167,11 @@
     {
         case 'S':
             // start -> before
-            relation = 'B';
+            relation = 'S';
             break;
         case 'E':
             // end -> after
-            relation = 'A';
+            relation = 'E';
             break;
         default:
             return NULL;
@@ -184,16 +184,16 @@
     asfreq_endpoints = get_asfreq_func(fromFreq, toFreq, 0);
 
     //convert start index to new frequency
-    CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'B', &af_info));
+    CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'S', &af_info));
     if (newStartTemp < 1) {
-        CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'A', &af_info));
+        CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'E', &af_info));
     }
     else { newStart = newStartTemp; }
 
     //convert end index to new frequency
-    CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A', &af_info));
+    CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'E', &af_info));
     if (newEndTemp < 1) {
-        CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B', &af_info));
+        CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'S', &af_info));
     }
     else { newEnd = newEndTemp; }
 
@@ -212,7 +212,7 @@
         get_asfreq_info(toFreq, fromFreq, &af_info_rev);
         asfreq_reverse = get_asfreq_func(toFreq, fromFreq, 0);
 
-        CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'B', &af_info_rev));
+        CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'S', &af_info_rev));
         currPerLen = startIndex - tempval;
 
         nd = 2;

Modified: branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py
===================================================================
--- branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py	2007-11-26 05:32:08 UTC (rev 3594)
+++ branches/scipy.scons/scipy/sandbox/timeseries/tests/test_dates.py	2007-11-26 05:33:22 UTC (rev 3595)
@@ -263,61 +263,61 @@
             date_AJUN = dWrap(Date(freq=C.FR_ANNJUN, year=2007))
             date_ANOV = dWrap(Date(freq=C.FR_ANNNOV, year=2007))
 
-            date_A_to_Q_before = dWrap(Date(freq='Q', year=2007, quarter=1))
-            date_A_to_Q_after = dWrap(Date(freq='Q', year=2007, quarter=4))
-            date_A_to_M_before = dWrap(Date(freq='M', year=2007, month=1))
-            date_A_to_M_after = dWrap(Date(freq='M', year=2007, month=12))
-            date_A_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1))
-            date_A_to_W_after = dWrap(Date(freq='W', year=2007, month=12, day=31))
-            date_A_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1))
-            date_A_to_B_after = dWrap(Date(freq='B', year=2007, month=12, day=31))
-            date_A_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1))
-            date_A_to_D_after = dWrap(Date(freq='D', year=2007, month=12, day=31))
-            date_A_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1,
+            date_A_to_Q_start = dWrap(Date(freq='Q', year=2007, quarter=1))
+            date_A_to_Q_end = dWrap(Date(freq='Q', year=2007, quarter=4))
+            date_A_to_M_start = dWrap(Date(freq='M', year=2007, month=1))
+            date_A_to_M_end = dWrap(Date(freq='M', year=2007, month=12))
+            date_A_to_W_start = dWrap(Date(freq='W', year=2007, month=1, day=1))
+            date_A_to_W_end = dWrap(Date(freq='W', year=2007, month=12, day=31))
+            date_A_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1))
+            date_A_to_B_end = dWrap(Date(freq='B', year=2007, month=12, day=31))
+            date_A_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1))
+            date_A_to_D_end = dWrap(Date(freq='D', year=2007, month=12, day=31))
+            date_A_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1,
                                       hour=0))
-            date_A_to_H_after = dWrap(Date(freq='H', year=2007, month=12, day=31,
+            date_A_to_H_end = dWrap(Date(freq='H', year=2007, month=12, day=31,
                                      hour=23))
-            date_A_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_A_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                       hour=0, minute=0))
-            date_A_to_T_after = dWrap(Date(freq='T', year=2007, month=12, day=31,
+            date_A_to_T_end = dWrap(Date(freq='T', year=2007, month=12, day=31,
                                      hour=23, minute=59))
-            date_A_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_A_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                       hour=0, minute=0, second=0))
-            date_A_to_S_after = dWrap(Date(freq='S', year=2007, month=12, day=31,
+            date_A_to_S_end = dWrap(Date(freq='S', year=2007, month=12, day=31,
                                      hour=23, minute=59, second=59))
 
-            date_AJAN_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=31))
-            date_AJAN_to_D_before = dWrap(Date(freq='D', year=2006, month=2, day=1))
-            date_AJUN_to_D_after = dWrap(Date(freq='D', year=2007, month=6, day=30))
-            date_AJUN_to_D_before = dWrap(Date(freq='D', year=2006, month=7, day=1))
-            date_ANOV_to_D_after = dWrap(Date(freq='D', year=2007, month=11, day=30))
-            date_ANOV_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=1))
+            date_AJAN_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=31))
+            date_AJAN_to_D_start = dWrap(Date(freq='D', year=2006, month=2, day=1))
+            date_AJUN_to_D_end = dWrap(Date(freq='D', year=2007, month=6, day=30))
+            date_AJUN_to_D_start = dWrap(Date(freq='D', year=2006, month=7, day=1))
+            date_ANOV_to_D_end = dWrap(Date(freq='D', year=2007, month=11, day=30))
+            date_ANOV_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=1))
 
-            assert_func(date_A.asfreq('Q', "BEFORE"), date_A_to_Q_before)
-            assert_func(date_A.asfreq('Q', "AFTER"), date_A_to_Q_after)
-            assert_func(date_A.asfreq('M', "BEFORE"), date_A_to_M_before)
-            assert_func(date_A.asfreq('M', "AFTER"), date_A_to_M_after)
-            assert_func(date_A.asfreq('W', "BEFORE"), date_A_to_W_before)
-            assert_func(date_A.asfreq('W', "AFTER"), date_A_to_W_after)
-            assert_func(date_A.asfreq('B', "BEFORE"), date_A_to_B_before)
-            assert_func(date_A.asfreq('B', "AFTER"), date_A_to_B_after)
-            assert_func(date_A.asfreq('D', "BEFORE"), date_A_to_D_before)
-            assert_func(date_A.asfreq('D', "AFTER"), date_A_to_D_after)
-            assert_func(date_A.asfreq('H', "BEFORE"), date_A_to_H_before)
-            assert_func(date_A.asfreq('H', "AFTER"), date_A_to_H_after)
-            assert_func(date_A.asfreq('T', "BEFORE"), date_A_to_T_before)
-            assert_func(date_A.asfreq('T', "AFTER"), date_A_to_T_after)
-            assert_func(date_A.asfreq('S', "BEFORE"), date_A_to_S_before)
-            assert_func(date_A.asfreq('S', "AFTER"), date_A_to_S_after)
+            assert_func(date_A.asfreq('Q', "START"), date_A_to_Q_start)
+            assert_func(date_A.asfreq('Q', "END"), date_A_to_Q_end)
+            assert_func(date_A.asfreq('M', "START"), date_A_to_M_start)
+            assert_func(date_A.asfreq('M', "END"), date_A_to_M_end)
+            assert_func(date_A.asfreq('W', "START"), date_A_to_W_start)
+            assert_func(date_A.asfreq('W', "END"), date_A_to_W_end)
+            assert_func(date_A.asfreq('B', "START"), date_A_to_B_start)
+            assert_func(date_A.asfreq('B', "END"), date_A_to_B_end)
+            assert_func(date_A.asfreq('D', "START"), date_A_to_D_start)
+            assert_func(date_A.asfreq('D', "END"), date_A_to_D_end)
+            assert_func(date_A.asfreq('H', "START"), date_A_to_H_start)
+            assert_func(date_A.asfreq('H', "END"), date_A_to_H_end)
+            assert_func(date_A.asfreq('T', "START"), date_A_to_T_start)
+            assert_func(date_A.asfreq('T', "END"), date_A_to_T_end)
+            assert_func(date_A.asfreq('S', "START"), date_A_to_S_start)
+            assert_func(date_A.asfreq('S', "END"), date_A_to_S_end)
 
-            assert_func(date_AJAN.asfreq('D', "BEFORE"), date_AJAN_to_D_before)
-            assert_func(date_AJAN.asfreq('D', "AFTER"), date_AJAN_to_D_after)
+            assert_func(date_AJAN.asfreq('D', "START"), date_AJAN_to_D_start)
+            assert_func(date_AJAN.asfreq('D', "END"), date_AJAN_to_D_end)
 
-            assert_func(date_AJUN.asfreq('D', "BEFORE"), date_AJUN_to_D_before)
-            assert_func(date_AJUN.asfreq('D', "AFTER"), date_AJUN_to_D_after)
+            assert_func(date_AJUN.asfreq('D', "START"), date_AJUN_to_D_start)
+            assert_func(date_AJUN.asfreq('D', "END"), date_AJUN_to_D_end)
 
-            assert_func(date_ANOV.asfreq('D', "BEFORE"), date_ANOV_to_D_before)
-            assert_func(date_ANOV.asfreq('D', "AFTER"), date_ANOV_to_D_after)
+            assert_func(date_ANOV.asfreq('D', "START"), date_ANOV_to_D_start)
+            assert_func(date_ANOV.asfreq('D', "END"), date_ANOV_to_D_end)
 
     def test_conv_quarterly(self):
         "frequency conversion tests: from Quarterly Frequency"
@@ -334,71 +334,71 @@
             date_QSDEC = dWrap(Date(freq=C.FR_QTRSDEC, year=2007, quarter=1))
 
             date_Q_to_A = dWrap(Date(freq='A', year=2007))
-            date_Q_to_M_before = dWrap(Date(freq='M', year=2007, month=1))
-            date_Q_to_M_after = dWrap(Date(freq='M', year=2007, month=3))
-            date_Q_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1))
-            date_Q_to_W_after = dWrap(Date(freq='W', year=2007, month=3, day=31))
-            date_Q_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1))
-            date_Q_to_B_after = dWrap(Date(freq='B', year=2007, month=3, day=30))
-            date_Q_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1))
-            date_Q_to_D_after = dWrap(Date(freq='D', year=2007, month=3, day=31))
-            date_Q_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1,
+            date_Q_to_M_start = dWrap(Date(freq='M', year=2007, month=1))
+            date_Q_to_M_end = dWrap(Date(freq='M', year=2007, month=3))
+            date_Q_to_W_start = dWrap(Date(freq='W', year=2007, month=1, day=1))
+            date_Q_to_W_end = dWrap(Date(freq='W', year=2007, month=3, day=31))
+            date_Q_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1))
+            date_Q_to_B_end = dWrap(Date(freq='B', year=2007, month=3, day=30))
+            date_Q_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1))
+            date_Q_to_D_end = dWrap(Date(freq='D', year=2007, month=3, day=31))
+            date_Q_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1,
                                       hour=0))
-            date_Q_to_H_after = dWrap(Date(freq='H', year=2007, month=3, day=31,
+            date_Q_to_H_end = dWrap(Date(freq='H', year=2007, month=3, day=31,
                                      hour=23))
-            date_Q_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_Q_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                       hour=0, minute=0))
-            date_Q_to_T_after = dWrap(Date(freq='T', year=2007, month=3, day=31,
+            date_Q_to_T_end = dWrap(Date(freq='T', year=2007, month=3, day=31,
                                      hour=23, minute=59))
-            date_Q_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_Q_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                       hour=0, minute=0, second=0))
-            date_Q_to_S_after = dWrap(Date(freq='S', year=2007, month=3, day=31,
+            date_Q_to_S_end = dWrap(Date(freq='S', year=2007, month=3, day=31,
                                      hour=23, minute=59, second=59))
 
-            date_QEJAN_to_D_before = dWrap(Date(freq='D', year=2006, month=2, day=1))
-            date_QEJAN_to_D_after = dWrap(Date(freq='D', year=2006, month=4, day=30))
+            date_QEJAN_to_D_start = dWrap(Date(freq='D', year=2006, month=2, day=1))
+            date_QEJAN_to_D_end = dWrap(Date(freq='D', year=2006, month=4, day=30))
 
-            date_QEJUN_to_D_before = dWrap(Date(freq='D', year=2006, month=7, day=1))
-            date_QEJUN_to_D_after = dWrap(Date(freq='D', year=2006, month=9, day=30))
+            date_QEJUN_to_D_start = dWrap(Date(freq='D', year=2006, month=7, day=1))
+            date_QEJUN_to_D_end = dWrap(Date(freq='D', year=2006, month=9, day=30))
 
-            date_QSJAN_to_D_before = dWrap(Date(freq='D', year=2007, month=2, day=1))
-            date_QSJAN_to_D_after = dWrap(Date(freq='D', year=2007, month=4, day=30))
+            date_QSJAN_to_D_start = dWrap(Date(freq='D', year=2007, month=2, day=1))
+            date_QSJAN_to_D_end = dWrap(Date(freq='D', year=2007, month=4, day=30))
 
-            date_QSJUN_to_D_before = dWrap(Date(freq='D', year=2007, month=7, day=1))
-            date_QSJUN_to_D_after = dWrap(Date(freq='D', year=2007, month=9, day=30))
+            date_QSJUN_to_D_start = dWrap(Date(freq='D', year=2007, month=7, day=1))
+            date_QSJUN_to_D_end = dWrap(Date(freq='D', year=2007, month=9, day=30))
 
-            date_QSDEC_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1))
-            date_QSDEC_to_D_after = dWrap(Date(freq='D', year=2007, month=3, day=31))
+            date_QSDEC_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1))
+            date_QSDEC_to_D_end = dWrap(Date(freq='D', year=2007, month=3, day=31))
 
             assert_func(date_Q.asfreq('A'), date_Q_to_A)
             assert_func(date_Q_end_of_year.asfreq('A'), date_Q_to_A)
 
-            assert_func(date_Q.asfreq('M', "BEFORE"), date_Q_to_M_before)
-            assert_func(date_Q.asfreq('M', "AFTER"), date_Q_to_M_after)
-            assert_func(date_Q.asfreq('W', "BEFORE"), date_Q_to_W_before)
-            assert_func(date_Q.asfreq('W', "AFTER"), date_Q_to_W_after)
-            assert_func(date_Q.asfreq('B', "BEFORE"), date_Q_to_B_before)
-            assert_func(date_Q.asfreq('B', "AFTER"), date_Q_to_B_after)
-            assert_func(date_Q.asfreq('D', "BEFORE"), date_Q_to_D_before)
-            assert_func(date_Q.asfreq('D', "AFTER"), date_Q_to_D_after)
-            assert_func(date_Q.asfreq('H', "BEFORE"), date_Q_to_H_before)
-            assert_func(date_Q.asfreq('H', "AFTER"), date_Q_to_H_after)
-            assert_func(date_Q.asfreq('T', "BEFORE"), date_Q_to_T_before)
-            assert_func(date_Q.asfreq('T', "AFTER"), date_Q_to_T_after)
-            assert_func(date_Q.asfreq('S', "BEFORE"), date_Q_to_S_before)
-            assert_func(date_Q.asfreq('S', "AFTER"), date_Q_to_S_after)
+            assert_func(date_Q.asfreq('M', "START"), date_Q_to_M_start)
+            assert_func(date_Q.asfreq('M', "END"), date_Q_to_M_end)
+            assert_func(date_Q.asfreq('W', "START"), date_Q_to_W_start)
+            assert_func(date_Q.asfreq('W', "END"), date_Q_to_W_end)
+            assert_func(date_Q.asfreq('B', "START"), date_Q_to_B_start)
+            assert_func(date_Q.asfreq('B', "END"), date_Q_to_B_end)
+            assert_func(date_Q.asfreq('D', "START"), date_Q_to_D_start)
+            assert_func(date_Q.asfreq('D', "END"), date_Q_to_D_end)
+            assert_func(date_Q.asfreq('H', "START"), date_Q_to_H_start)
+            assert_func(date_Q.asfreq('H', "END"), date_Q_to_H_end)
+            assert_func(date_Q.asfreq('T', "START"), date_Q_to_T_start)
+            assert_func(date_Q.asfreq('T', "END"), date_Q_to_T_end)
+            assert_func(date_Q.asfreq('S', "START"), date_Q_to_S_start)
+            assert_func(date_Q.asfreq('S', "END"), date_Q_to_S_end)
 
-            assert_func(date_QEJAN.asfreq('D', "BEFORE"), date_QEJAN_to_D_before)
-            assert_func(date_QEJAN.asfreq('D', "AFTER"), date_QEJAN_to_D_after)
-            assert_func(date_QEJUN.asfreq('D', "BEFORE"), date_QEJUN_to_D_before)
-            assert_func(date_QEJUN.asfreq('D', "AFTER"), date_QEJUN_to_D_after)
+            assert_func(date_QEJAN.asfreq('D', "START"), date_QEJAN_to_D_start)
+            assert_func(date_QEJAN.asfreq('D', "END"), date_QEJAN_to_D_end)
+            assert_func(date_QEJUN.asfreq('D', "START"), date_QEJUN_to_D_start)
+            assert_func(date_QEJUN.asfreq('D', "END"), date_QEJUN_to_D_end)
 
-            assert_func(date_QSJAN.asfreq('D', "BEFORE"), date_QSJAN_to_D_before)
-            assert_func(date_QSJAN.asfreq('D', "AFTER"), date_QSJAN_to_D_after)
-            assert_func(date_QSJUN.asfreq('D', "BEFORE"), date_QSJUN_to_D_before)
-            assert_func(date_QSJUN.asfreq('D', "AFTER"), date_QSJUN_to_D_after)
-            assert_func(date_QSDEC.asfreq('D', "BEFORE"), date_QSDEC_to_D_before)
-            assert_func(date_QSDEC.asfreq('D', "AFTER"), date_QSDEC_to_D_after)
+            assert_func(date_QSJAN.asfreq('D', "START"), date_QSJAN_to_D_start)
+            assert_func(date_QSJAN.asfreq('D', "END"), date_QSJAN_to_D_end)
+            assert_func(date_QSJUN.asfreq('D', "START"), date_QSJUN_to_D_start)
+            assert_func(date_QSJUN.asfreq('D', "END"), date_QSJUN_to_D_end)
+            assert_func(date_QSDEC.asfreq('D', "START"), date_QSDEC_to_D_start)
+            assert_func(date_QSDEC.asfreq('D', "END"), date_QSDEC_to_D_end)
 
     def test_conv_monthly(self):
         "frequency conversion tests: from Monthly Frequency"
@@ -409,23 +409,23 @@
             date_M_end_of_quarter = dWrap(Date(freq='M', year=2007, month=3))
             date_M_to_A = dWrap(Date(freq='A', year=2007))
             date_M_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1))
-            date_M_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1))
-            date_M_to_W_after = dWrap(Date(freq='W', year=2007, month=1, day=31))
-            date_M_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1))
-            date_M_to_B_after = dWrap(Date(freq='B', year=2007, month=1, day=31))
-            date_M_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1))
-            date_M_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=31))
-            date_M_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1,
+            date_M_to_W_start = dWrap(Date(freq='W', year=2007, month=1, day=1))
+            date_M_to_W_end = dWrap(Date(freq='W', year=2007, month=1, day=31))
+            date_M_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1))
+            date_M_to_B_end = dWrap(Date(freq='B', year=2007, month=1, day=31))
+            date_M_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1))
+            date_M_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=31))
+            date_M_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1,
                                       hour=0))
-            date_M_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=31,
+            date_M_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=31,
                                      hour=23))
-            date_M_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_M_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                       hour=0, minute=0))
-            date_M_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=31,
+            date_M_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=31,
                                      hour=23, minute=59))
-            date_M_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_M_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                       hour=0, minute=0, second=0))
-            date_M_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=31,
+            date_M_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=31,
                                      hour=23, minute=59, second=59))
 
             assert_func(date_M.asfreq('A'), date_M_to_A)
@@ -433,18 +433,18 @@
             assert_func(date_M.asfreq('Q'), date_M_to_Q)
             assert_func(date_M_end_of_quarter.asfreq('Q'), date_M_to_Q)
 
-            assert_func(date_M.asfreq('W', "BEFORE"), date_M_to_W_before)
-            assert_func(date_M.asfreq('W', "AFTER"), date_M_to_W_after)
-            assert_func(date_M.asfreq('B', "BEFORE"), date_M_to_B_before)
-            assert_func(date_M.asfreq('B', "AFTER"), date_M_to_B_after)
-            assert_func(date_M.asfreq('D', "BEFORE"), date_M_to_D_before)
-            assert_func(date_M.asfreq('D', "AFTER"), date_M_to_D_after)
-            assert_func(date_M.asfreq('H', "BEFORE"), date_M_to_H_before)
-            assert_func(date_M.asfreq('H', "AFTER"), date_M_to_H_after)
-            assert_func(date_M.asfreq('T', "BEFORE"), date_M_to_T_before)
-            assert_func(date_M.asfreq('T', "AFTER"), date_M_to_T_after)
-            assert_func(date_M.asfreq('S', "BEFORE"), date_M_to_S_before)
-            assert_func(date_M.asfreq('S', "AFTER"), date_M_to_S_after)
+            assert_func(date_M.asfreq('W', "START"), date_M_to_W_start)
+            assert_func(date_M.asfreq('W', "END"), date_M_to_W_end)
+            assert_func(date_M.asfreq('B', "START"), date_M_to_B_start)
+            assert_func(date_M.asfreq('B', "END"), date_M_to_B_end)
+            assert_func(date_M.asfreq('D', "START"), date_M_to_D_start)
+            assert_func(date_M.asfreq('D', "END"), date_M_to_D_end)
+            assert_func(date_M.asfreq('H', "START"), date_M_to_H_start)
+            assert_func(date_M.asfreq('H', "END"), date_M_to_H_end)
+            assert_func(date_M.asfreq('T', "START"), date_M_to_T_start)
+            assert_func(date_M.asfreq('T', "END"), date_M_to_T_end)
+            assert_func(date_M.asfreq('S', "START"), date_M_to_S_start)
+            assert_func(date_M.asfreq('S', "END"), date_M_to_S_end)
 
 
     def test_conv_weekly(self):
@@ -461,20 +461,20 @@
             date_WTUE = dWrap(Date(freq='W-TUE', year=2007, month=1, day=2))
             date_WMON = dWrap(Date(freq='W-MON', year=2007, month=1, day=1))
 
-            date_WSUN_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1))
-            date_WSUN_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=7))
-            date_WSAT_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=31))
-            date_WSAT_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=6))
-            date_WFRI_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=30))
-            date_WFRI_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=5))
-            date_WTHU_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=29))
-            date_WTHU_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=4))
-            date_WWED_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=28))
-            date_WWED_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=3))
-            date_WTUE_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=27))
-            date_WTUE_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=2))
-            date_WMON_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=26))
-            date_WMON_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=1))
+            date_WSUN_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1))
+            date_WSUN_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=7))
+            date_WSAT_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=31))
+            date_WSAT_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=6))
+            date_WFRI_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=30))
+            date_WFRI_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=5))
+            date_WTHU_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=29))
+            date_WTHU_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=4))
+            date_WWED_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=28))
+            date_WWED_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=3))
+            date_WTUE_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=27))
+            date_WTUE_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=2))
+            date_WMON_to_D_start = dWrap(Date(freq='D', year=2006, month=12, day=26))
+            date_WMON_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=1))
 
             date_W_end_of_year = dWrap(Date(freq='W', year=2007, month=12, day=31))
             date_W_end_of_quarter = dWrap(Date(freq='W', year=2007, month=3, day=31))
@@ -498,21 +498,21 @@
             else:
                 date_W_to_M_end_of_month = dWrap(Date(freq='M', year=2007, month=2))
 
-            date_W_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1))
-            date_W_to_B_after = dWrap(Date(freq='B', year=2007, month=1, day=5))
-            date_W_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1))
-            date_W_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=7))
-            date_W_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1,
+            date_W_to_B_start = dWrap(Date(freq='B', year=2007, month=1, day=1))
+            date_W_to_B_end = dWrap(Date(freq='B', year=2007, month=1, day=5))
+            date_W_to_D_start = dWrap(Date(freq='D', year=2007, month=1, day=1))
+            date_W_to_D_end = dWrap(Date(freq='D', year=2007, month=1, day=7))
+            date_W_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1,
                                       hour=0))
-            date_W_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=7,
+            date_W_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=7,
                                      hour=23))
-            date_W_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_W_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                       hour=0, minute=0))
-            date_W_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=7,
+            date_W_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=7,
                                      hour=23, minute=59))
-            date_W_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_W_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                       hour=0, minute=0, second=0))
-            date_W_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=7,
+            date_W_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=7,
                                      hour=23, minute=59, second=59))
 
             assert_func(date_W.asfreq('A'), date_W_to_A)
@@ -522,33 +522,33 @@
             assert_func(date_W.asfreq('M'), date_W_to_M)
             assert_func(date_W_end_of_month.asfreq('M'), date_W_to_M_end_of_month)
 
-            assert_func(date_W.asfreq('B', "BEFORE"), date_W_to_B_before)
-            assert_func(date_W.asfreq('B', "AFTER"), date_W_to_B_after)
+            assert_func(date_W.asfreq('B', "START"), date_W_to_B_start)
+            assert_func(date_W.asfreq('B', "END"), date_W_to_B_end)
 
-            assert_func(date_W.asfreq('D', "BEFORE"), date_W_to_D_before)
-            assert_func(date_W.asfreq('D', "AFTER"), date_W_to_D_after)
+            assert_func(date_W.asfreq('D', "START"), date_W_to_D_start)
+            assert_func(date_W.asfreq('D', "END"), date_W_to_D_end)
 
-            assert_func(date_WSUN.asfreq('D', "BEFORE"), date_WSUN_to_D_before)
-            assert_func(date_WSUN.asfreq('D', "AFTER"), date_WSUN_to_D_after)
-            assert_func(date_WSAT.asfreq('D', "BEFORE"), date_WSAT_to_D_before)
-            assert_func(date_WSAT.asfreq('D', "AFTER"), date_WSAT_to_D_after)
-            assert_func(date_WFRI.asfreq('D', "BEFORE"), date_WFRI_to_D_before)
-            assert_func(date_WFRI.asfreq('D', "AFTER"), date_WFRI_to_D_after)
-            assert_func(date_WTHU.asfreq('D', "BEFORE"), date_WTHU_to_D_before)
-            assert_func(date_WTHU.asfreq('D', "AFTER"), date_WTHU_to_D_after)
-            assert_func(date_WWED.asfreq('D', "BEFORE"), date_WWED_to_D_before)
-            assert_func(date_WWED.asfreq('D', "AFTER"), date_WWED_to_D_after)
-            assert_func(date_WTUE.asfreq('D', "BEFORE"), date_WTUE_to_D_before)
-            assert_func(date_WTUE.asfreq('D', "AFTER"), date_WTUE_to_D_after)
-            assert_func(date_WMON.asfreq('D', "BEFORE"), date_WMON_to_D_before)
-            assert_func(date_WMON.asfreq('D', "AFTER"), date_WMON_to_D_after)
+            assert_func(date_WSUN.asfreq('D', "START"), date_WSUN_to_D_start)
+            assert_func(date_WSUN.asfreq('D', "END"), date_WSUN_to_D_end)
+            assert_func(date_WSAT.asfreq('D', "START"), date_WSAT_to_D_start)
+            assert_func(date_WSAT.asfreq('D', "END"), date_WSAT_to_D_end)
+            assert_func(date_WFRI.asfreq('D', "START"), date_WFRI_to_D_start)
+            assert_func(date_WFRI.asfreq('D', "END"), date_WFRI_to_D_end)
+            assert_func(date_WTHU.asfreq('D', "START"), date_WTHU_to_D_start)
+            assert_func(date_WTHU.asfreq('D', "END"), date_WTHU_to_D_end)
+            assert_func(date_WWED.asfreq('D', "START"), date_WWED_to_D_start)
+            assert_func(date_WWED.asfreq('D', "END"), date_WWED_to_D_end)
+            assert_func(date_WTUE.asfreq('D', "START"), date_WTUE_to_D_start)
+            assert_func(date_WTUE.asfreq('D', "END"), date_WTUE_to_D_end)
+            assert_func(date_WMON.asfreq('D', "START"), date_WMON_to_D_start)
+            assert_func(date_WMON.asfreq('D', "END"), date_WMON_to_D_end)
 
-            assert_func(date_W.asfreq('H', "BEFORE"), date_W_to_H_before)
-            assert_func(date_W.asfreq('H', "AFTER"), date_W_to_H_after)
-            assert_func(date_W.asfreq('T', "BEFORE"), date_W_to_T_before)
-            assert_func(date_W.asfreq('T', "AFTER"), date_W_to_T_after)
-            assert_func(date_W.asfreq('S', "BEFORE"), date_W_to_S_before)
-            assert_func(date_W.asfreq('S', "AFTER"), date_W_to_S_after)
+            assert_func(date_W.asfreq('H', "START"), date_W_to_H_start)
+            assert_func(date_W.asfreq('H', "END"), date_W_to_H_end)
+            assert_func(date_W.asfreq('T', "START"), date_W_to_T_start)
+            assert_func(date_W.asfreq('T', "END"), date_W_to_T_end)
+            assert_func(date_W.asfreq('S', "START"), date_W_to_S_start)
+            assert_func(date_W.asfreq('S', "END"), date_W_to_S_end)
 
     def test_conv_business(self):
         "frequency conversion tests: from Business Frequency"
@@ -565,17 +565,17 @@
             date_B_to_M = dWrap(Date(freq='M', year=2007, month=1))
             date_B_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7))
             date_B_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1))
-            date_B_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1,
+            date_B_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1,
                                       hour=0))
-            date_B_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1,
+            date_B_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=1,
                                      hour=23))
-            date_B_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_B_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                       hour=0, minute=0))
-            date_B_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_B_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                      hour=23, minute=59))
-            date_B_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_B_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                       hour=0, minute=0, second=0))
-            date_B_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_B_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                      hour=23, minute=59, second=59))
 
             assert_func(date_B.asfreq('A'), date_B_to_A)
@@ -589,12 +589,12 @@
 
             assert_func(date_B.asfreq('D'), date_B_to_D)
 
-            assert_func(date_B.asfreq('H', "BEFORE"), date_B_to_H_before)
-            assert_func(date_B.asfreq('H', "AFTER"), date_B_to_H_after)
-            assert_func(date_B.asfreq('T', "BEFORE"), date_B_to_T_before)
-            assert_func(date_B.asfreq('T', "AFTER"), date_B_to_T_after)
-            assert_func(date_B.asfreq('S', "BEFORE"), date_B_to_S_before)
-            assert_func(date_B.asfreq('S', "AFTER"), date_B_to_S_after)
+            assert_func(date_B.asfreq('H', "START"), date_B_to_H_start)
+            assert_func(date_B.asfreq('H', "END"), date_B_to_H_end)
+            assert_func(date_B.asfreq('T', "START"), date_B_to_T_start)
+            assert_func(date_B.asfreq('T', "END"), date_B_to_T_end)
+            assert_func(date_B.asfreq('S', "START"), date_B_to_S_start)
+            assert_func(date_B.asfreq('S', "END"), date_B_to_S_end)
 
     def test_conv_daily(self):
         "frequency conversion tests: from Business Frequency"
@@ -631,17 +631,17 @@
             date_D_to_M = dWrap(Date(freq='M', year=2007, month=1))
             date_D_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7))
 
-            date_D_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1,
+            date_D_to_H_start = dWrap(Date(freq='H', year=2007, month=1, day=1,
                                       hour=0))
-            date_D_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1,
+            date_D_to_H_end = dWrap(Date(freq='H', year=2007, month=1, day=1,
                                      hour=23))
-            date_D_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_D_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                       hour=0, minute=0))
-            date_D_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_D_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                      hour=23, minute=59))
-            date_D_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_D_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                       hour=0, minute=0, second=0))
-            date_D_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_D_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                      hour=23, minute=59, second=59))
 
             assert_func(date_D.asfreq('A'), date_D_to_A)
@@ -664,17 +664,17 @@
             assert_func(date_D_end_of_week.asfreq('W'), date_D_to_W)
 
             assert_func(date_D_friday.asfreq('B'), date_B_friday)
-            assert_func(date_D_saturday.asfreq('B', "BEFORE"), date_B_friday)
-            assert_func(date_D_saturday.asfreq('B', "AFTER"), date_B_monday)
-            assert_func(date_D_sunday.asfreq('B', "BEFORE"), date_B_friday)
-            assert_func(date_D_sunday.asfreq('B', "AFTER"), date_B_monday)
+            assert_func(date_D_saturday.asfreq('B', "START"), date_B_friday)
+            assert_func(date_D_saturday.asfreq('B', "END"), date_B_monday)
+            assert_func(date_D_sunday.asfreq('B', "START"), date_B_friday)
+            assert_func(date_D_sunday.asfreq('B', "END"), date_B_monday)
 
-            assert_func(date_D.asfreq('H', "BEFORE"), date_D_to_H_before)
-            assert_func(date_D.asfreq('H', "AFTER"), date_D_to_H_after)
-            assert_func(date_D.asfreq('T', "BEFORE"), date_D_to_T_before)
-            assert_func(date_D.asfreq('T', "AFTER"), date_D_to_T_after)
-            assert_func(date_D.asfreq('S', "BEFORE"), date_D_to_S_before)
-            assert_func(date_D.asfreq('S', "AFTER"), date_D_to_S_after)
+            assert_func(date_D.asfreq('H', "START"), date_D_to_H_start)
+            assert_func(date_D.asfreq('H', "END"), date_D_to_H_end)
+            assert_func(date_D.asfreq('T', "START"), date_D_to_T_start)
+            assert_func(date_D.asfreq('T', "END"), date_D_to_T_end)
+            assert_func(date_D.asfreq('S', "START"), date_D_to_S_start)
+            assert_func(date_D.asfreq('S', "END"), date_D_to_S_end)
 
     def test_conv_hourly(self):
         "frequency conversion tests: from Hourly Frequency"
@@ -701,13 +701,13 @@
             date_H_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1))
             date_H_to_B = dWrap(Date(freq='B', year=2007, month=1, day=1))
 
-            date_H_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_H_to_T_start = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                       hour=0, minute=0))
-            date_H_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1,
+            date_H_to_T_end = dWrap(Date(freq='T', year=2007, month=1, day=1,
                                      hour=0, minute=59))
-            date_H_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_H_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                       hour=0, minute=0, second=0))
-            date_H_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_H_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                      hour=0, minute=59, second=59))
 
             assert_func(date_H.asfreq('A'), date_H_to_A)
@@ -723,10 +723,10 @@
             assert_func(date_H.asfreq('B'), date_H_to_B)
             assert_func(date_H_end_of_bus.asfreq('B'), date_H_to_B)
 
-            assert_func(date_H.asfreq('T', "BEFORE"), date_H_to_T_before)
-            assert_func(date_H.asfreq('T', "AFTER"), date_H_to_T_after)
-            assert_func(date_H.asfreq('S', "BEFORE"), date_H_to_S_before)
-            assert_func(date_H.asfreq('S', "AFTER"), date_H_to_S_after)
+            assert_func(date_H.asfreq('T', "START"), date_H_to_T_start)
+            assert_func(date_H.asfreq('T', "END"), date_H_to_T_end)
+            assert_func(date_H.asfreq('S', "START"), date_H_to_S_start)
+            assert_func(date_H.asfreq('S', "END"), date_H_to_S_end)
 
     def test_conv_minutely(self):
         "frequency conversion tests: from Minutely Frequency"
@@ -757,9 +757,9 @@
             date_T_to_B = dWrap(Date(freq='B', year=2007, month=1, day=1))
             date_T_to_H = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0))
 
-            date_T_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_T_to_S_start = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                       hour=0, minute=0, second=0))
-            date_T_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1,
+            date_T_to_S_end = dWrap(Date(freq='S', year=2007, month=1, day=1,
                                      hour=0, minute=0, second=59))
 
             assert_func(date_T.asfreq('A'), date_T_to_A)
@@ -777,8 +777,8 @@
             assert_func(date_T.asfreq('H'), date_T_to_H)
             assert_func(date_T_end_of_hour.asfreq('H'), date_T_to_H)
 
-            assert_func(date_T.asfreq('S', "BEFORE"), date_T_to_S_before)
-            assert_func(date_T.asfreq('S', "AFTER"), date_T_to_S_after)
+            assert_func(date_T.asfreq('S', "START"), date_T_to_S_start)
+            assert_func(date_T.asfreq('S', "END"), date_T_to_S_end)
 
 
     def test_conv_secondly(self):

Modified: branches/scipy.scons/scipy/sandbox/timeseries/tests/test_timeseries.py
===================================================================
--- branches/scipy.scons/scipy/sandbox/timeseries/tests/test_timeseries.py	2007-11-26 05:32:08 UTC (rev 3594)
+++ branches/scipy.scons/scipy/sandbox/timeseries/tests/test_timeseries.py	2007-11-26 05:33:22 UTC (rev 3595)
@@ -411,9 +411,9 @@
         lowToHigh_start = lowFreqSeries.convert('B', position='START')
 
         assert_equal(lowToHigh_start.start_date,
-                     Date(freq='m', year=2005, month=6).asfreq("B", relation="BEFORE"))
+                     Date(freq='m', year=2005, month=6).asfreq("B", relation="START"))
         assert_equal(lowToHigh_start.end_date,
-                     (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="AFTER"))
+                     (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="END"))
 
         assert_equal(lowToHigh_start._mask[0], False)
         assert_equal(lowToHigh_start._mask[-1], True)
@@ -421,9 +421,9 @@
         lowToHigh_end = lowFreqSeries.convert('B', position='END')
 
         assert_equal(lowToHigh_end.start_date,
-                     Date(freq='m', year=2005, month=6).asfreq("B", relation="BEFORE"))
+                     Date(freq='m', year=2005, month=6).asfreq("B", relation="START"))
         assert_equal(lowToHigh_end.end_date,
-                     (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="AFTER"))
+                     (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="END"))
 
         assert_equal(lowToHigh_end._mask[0], True)
         assert_equal(lowToHigh_end._mask[-1], False)

Modified: branches/scipy.scons/scipy/sandbox/timeseries/tseries.py
===================================================================
--- branches/scipy.scons/scipy/sandbox/timeseries/tseries.py	2007-11-26 05:32:08 UTC (rev 3594)
+++ branches/scipy.scons/scipy/sandbox/timeseries/tseries.py	2007-11-26 05:33:22 UTC (rev 3595)
@@ -688,7 +688,7 @@
         """Returns the index corresponding to a given date, as an integer."""
         return self._dates.date_to_index(date)
     #.....................................................
-    def asfreq(self, freq, relation="AFTER"):
+    def asfreq(self, freq, relation="END"):
         """Converts the dates portion of the TimeSeries to another frequency.
 
 The resulting TimeSeries will have the same shape and dimensions as the
@@ -696,7 +696,7 @@
 
 *Parameters*:
     freq : {freq_spec}
-    relation : {'AFTER', 'BEFORE'} , optional
+    relation : {'END', 'START'} (optional)
 
 *Returns*:
     a new TimeSeries with the .dates DateArray at the specified frequency (the
@@ -1307,17 +1307,34 @@
 def convert(series, freq, func=None, position='END', *args, **kwargs):
     """Converts a series to a frequency. Private function called by convert
 
-    When converting to a lower frequency, func is a function that acts
-    on a 1-d array and returns a scalar or 1-d array. func should handle
-    masked values appropriately. If func is None, then a 2D array is returned,
-    where each column represents the values appropriately grouped into the new
-    frequency. `position` will be ignored in this case.
+*Parameters*:
+    series : {TimeSeries}
+        the series to convert. Skip this parameter if you are calling this as
+        a method of the TimeSeries object instead of the module function.
+    freq : {freq_spec}
+        Frequency to convert the TimeSeries to. Accepts any valid frequency
+        specification (string or integer)
+    func : {function} (optional)
+        When converting to a lower frequency, func is a function that acts on
+        one date's worth of data. func should handle masked values appropriately.
+        If func is None, then each data point in the resulting series will a
+        group of data points that fall into the date at the lower frequency.
 
-    When converting to a higher frequency, position is 'START' or 'END'
-    and determines where the data point is in each period (eg. if going
-    from monthly to daily, and position is 'END', then each data point is
-    placed at the end of the month).
-    """
+        For example, if converting from monthly to daily and you wanted each
+        data point in the resulting series to be the average value for each
+        month, you could specify maskedarray.average for the 'func' parameter.
+    position : {'END', 'START'} (optional)
+        When converting to a higher frequency, position is 'START' or 'END'
+        and determines where the data point is in each period. For example, if
+        going from monthly to daily, and position is 'END', then each data
+        point is placed at the end of the month.
+    *args : {extra arguments for func parameter} (optional)
+        if a func is specified that requires additional parameters, specify
+        them here.
+    **kwargs : {extra keyword arguments for func parameter} (optional)
+        if a func is specified that requires additional keyword parameters,
+        specify them here.
+"""
     if series.ndim == 1:
         obj = _convert1d(series, freq, func, position, *args, **kwargs)
     elif series.ndim == 2:
@@ -1341,8 +1358,8 @@
 
 def group_byperiod(series, freq, position='END'):
     """Converts a series to a frequency, without any processing. If the series
-    has missing data, it is first filled with masked data. Duplicate values in the
-    series will raise an exception.
+has missing data, it is first filled with masked data. Duplicate values in the
+series will raise an exception.
     """
     if series.has_duplicated_dates():
         raise TimeSeriesError("The input series must not have duplicated dates!")
@@ -1357,16 +1374,16 @@
     """Returns a series of the same size as `series`, with the same
 start_date and end_date, but values shifted by `nper`.
 
-:Parameters:
-    - series : (TimeSeries)
+*Parameters*:
+    series : {TimeSeries}
         TimeSeries object to shift
-    - nper : (int)
+    nper : {int}
         number of periods to shift. Negative numbers shift values to the
         right, positive to the left
-    - copy : (boolean, *[True]*)
+    copy : {True, False} (optional)
         copies the data if True, returns a view if False.
 
-:Example:
+*Example*:
 >>> series = time_series([0,1,2,3], start_date=Date(freq='A', year=2005))
 >>> series
 timeseries(data  = [0 1 2 3],
@@ -1376,7 +1393,8 @@
 timeseries(data  = [-- 0 1 2],
            dates = [2005 ... 2008],
            freq  = A-DEC)
->>> pct_change = 100 * (series/tshift(series, -1, copy=False) - 1)"""
+>>> pct_change = 100 * (series/tshift(series, -1, copy=False) - 1)
+"""
     newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype),
                            mask=True)
     if copy:
@@ -1400,13 +1418,13 @@
 def pct(series, nper=1):
     """Returns the rolling percentage change of the series.
 
-:Parameters:
-    - series : (TimeSeries)
+*Parameters*:
+    series : {TimeSeries}
         TimeSeries object to to calculate percentage chage for
-    - nper : (int)
+    nper : {int}
         number of periods for percentage change
 
-:Example:
+*Example*:
 >>> series = time_series([2.,1.,2.,3.], start_date=Date(freq='A', year=2005))
 >>> pct(series)
 timeseries(data  = [-- -50.0 100.0 50.0],
@@ -1415,8 +1433,8 @@
 >>> pct(series, 2)
 timeseries(data  = [-- -- 0.0 200.0],
            dates = [2005 ... 2008],
-           freq  = A-DEC)"""
-
+           freq  = A-DEC)
+"""
     newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype),
                            mask=True)
     if nper < newdata.size:
@@ -1427,21 +1445,23 @@
     return newseries
 TimeSeries.pct = pct
 #...............................................................................
-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
+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
 `fill_value`.
 
-:Parameters:
-    `data`
+*Parameters*:
+    data : {TimeSeries, ndarray}
         Initial array of data.
-    `dates`
-        Initial array of dates.
-    `freq` : float *[None]*
-        New date resolutions. If *None*, the initial resolution is used instead.
-    `fill_value` : float *[None]*
-        Default value for missing data. If None, the data are just masked.
-    """
+    dates : {DateArray} (optional)
+        Initial array of dates. Specify this if you are passing a plain ndarray
+        for the data instead of a TimeSeries.
+    freq : {freq_spec} (optional)
+        Frequency of result. If not specified, the initial frequency is used.
+    fill_value : {scalar of type data.dtype} (optional)
+        Default value for missing data. If Not specified, the data are just
+        masked.
+"""
     # Check the frequency ........
     orig_freq = freq
     freq = check_freq(freq)



More information about the Scipy-svn mailing list