Index: tests/test_timeseries.py
===================================================================
--- tests/test_timeseries.py	(r??vision 2980)
+++ tests/test_timeseries.py	(copie de travail)
@@ -28,7 +28,8 @@
 from timeseries import tseries
 from timeseries import Date, date_array_fromlist, date_array, thisday
 from timeseries import time_series, TimeSeries, adjust_endpoints, \
-    mask_period, align_series, fill_missing_dates, tsmasked, concatenate_series
+    mask_period, align_series, fill_missing_dates, tsmasked, \
+    concatenate_series, stack, split
 
 class test_creation(NumpyTestCase):
     "Base test class for MaskedArrays."
@@ -99,7 +100,7 @@
         assert_equal(series._data.size, 15)
         
     def test_unsorted(self):
-        "Tests that the data are porperly sorted along the dates."
+        "Tests that the data are properly sorted along the dates."
         dlist = ['2007-01-%02i' % i for i in (3,2,1)]
         data = [10,20,30]
         series = time_series(data,dlist)
@@ -368,6 +369,19 @@
         assert_array_equal(shift_negative, shift_negative_result)
         assert_array_equal(shift_positive, shift_positive_result)
     #
+    def test_split(self):
+        """Test the split function."""
+        ms = time_series(N.arange(62).reshape(31,2), 
+            start_date=Date(freq='d', year=2005, month=7, day=1))
+        d1,d2 = split(ms)
+        assert_array_equal(d1.data, ms.data[:,0])
+        assert_array_equal(d1.dates, ms.dates)
+        assert_array_equal(d2.data, ms.data[:,1])
+
+        series = self.d[0]
+        ss = split(series)[0]
+        assert_array_equal(series, ss)
+
     def test_convert(self):
         """Test convert function
 
@@ -380,7 +394,12 @@
         highFreqSeries = time_series(N.arange(100),
                                     start_date=Date(freq='b', year=2005, month=6, day=1))
 
+        ndSeries = time_series(N.arange(62).reshape(31,2), 
+            start_date=Date(freq='d', year=2005, month=7, day=1))
+        
         lowToHigh_start = lowFreqSeries.convert('B', position='START')
+        
+        
 
         assert_equal(lowToHigh_start.start_date,
                      Date(freq='m', year=2005, month=6).asfreq("B", relation="BEFORE"))
@@ -411,6 +430,9 @@
                      (Date(freq='b', year=2005, month=6, day=1) + 99).asfreq('M'))
 
         assert_array_equal(lowFreqSeries, lowFreqSeries.convert("M"))
+        
+        assert_array_equal(ndSeries.convert('M', sum), [[930,961]])
+        
     #
     def test_fill_missing_dates(self):
         """Test fill_missing_dates function"""
@@ -582,4 +604,4 @@
 ###############################################################################
 #------------------------------------------------------------------------------
 if __name__ == "__main__":
-    NumpyTest().run()
\ Pas de fin de ligne ?? la fin du fichier
+    NumpyTest().run()
Index: tseries.py
===================================================================
--- tseries.py	(r??vision 2980)
+++ tseries.py	(copie de travail)
@@ -49,7 +49,7 @@
 'time_series', 'tsmasked',
 'mask_period','mask_inside_period','mask_outside_period','compressed',
 'adjust_endpoints','align_series','aligned','convert','group_byperiod',
-'pct','tshift','fill_missing_dates', 'stack', 'concatenate_series',
+'pct','tshift','fill_missing_dates', 'split', 'stack', 'concatenate_series',
 'empty_like',
 'day_of_week','day_of_year','day','month','quarter','year',
 'hour','minute','second',
@@ -1172,7 +1172,7 @@
     return [adjust_endpoints(x, start_date, end_date) for x in series]
 aligned = align_series
 #....................................................................
-def convert(series, freq, func='auto', position='END'):
+def __convert1d(series, freq, func='auto', position='END'):
     """Converts a series to a frequency.
 
     When converting to a lower frequency, func is a function that acts
@@ -1219,7 +1219,7 @@
 
     tempData = series._series.filled()
     tempMask = getmaskarray(series)
-
+    
     if (tempData.size // series._dates.size) > 1:
         raise TimeSeriesError("convert works with 1D data only !")
 
@@ -1241,6 +1241,28 @@
     newseries.copy_attributes(series)
     return newseries
 
+def convert(series, freq, func='auto', position='END'):
+    """Converts a series to a frequency.
+
+    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 "auto", then an
+    appropriate function is determined based on the observed attribute
+    of the series. If func is None, then a 2D array is returned, where each
+    column represents the values appropriately grouped into the new frequency.
+    interp and position will be ignored in this case.
+
+    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).
+    """
+    if series.ndim == 1:
+        return __convert1d(series, freq, func, position)
+    else:
+        ms = split(series)
+        return stack(*[__convert1d(s, freq, func, position) for s in ms])
+        
 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
@@ -1421,8 +1443,22 @@
     return _data
 #    return time_series(newdata.reshape(nshp), newdates)
 #...............................................................................
+def split(series):
+    """Split a multiple series into individual columns.
+    
+    :Parameters:
+      `series` : the multiple series to be splitted. 
+    """
+    if series.ndim == 1:
+        return [series]
+    else:
+        n = series.shape[1]
+        arr = MA.hsplit(series, n)[0]
+        return [time_series(numpy.squeeze(a), series._dates, **_attrib_dict(series)) for a in arr]
+
+#...............................................................................
 def stack(*series):
-    """performs a column_stack on the data from each series, and the
+    """Performs a column_stack on the data from each series, and the
 resulting series has the same dates as each individual series. All series
 must be date compatible.
 
@@ -1513,4 +1549,4 @@
         # ensure that series can be represented by a string after masking a value
         # (there was a bug before that prevented this from working when using a
         # DateArray for the data)
-        strrep = str(series)
\ Pas de fin de ligne ?? la fin du fichier
+        strrep = str(series)
