Changeset 1169

Show
Ignore:
Timestamp:
07/29/08 19:51:12 (4 months ago)
Author:
pierregm
Message:

* fixed .reshape to accept a list of integers and an additional order parameter as input.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/timeseries/scikits/timeseries/tests/test_timeseries.py

    r1166 r1169  
    600600        assert_equal(test1D._series.shape, newshape) 
    601601        assert_equal(test1D._dates.shape, newshape) 
     602        # Using multiple args 
     603        test1D = series1D.reshape(*newshape) 
     604        assert_equal(test1D.shape, newshape) 
     605         
    602606    # 
    603607    def test_reshaping_2D(self): 
  • trunk/timeseries/scikits/timeseries/tseries.py

    r1166 r1169  
    739739 
    740740 
    741     def reshape(self, newshape): 
    742         """a.reshape(shape, order='C') 
     741    def reshape(self, *newshape, **kwargs): 
     742        """ 
    743743 
    744744    Returns a time series containing the data of a, but with a new shape. 
    745  
    746745    The result is a view to the original array; if this is not possible, 
    747746    a ValueError is raised. 
     
    761760        A new view to the timeseries. 
    762761 
     762    Warnings 
     763    -------- 
     764    The `._dates` part is reshaped, but the order is NOT ensured. 
     765 
    763766        """ 
    764767        # 1D series : reshape the dates as well 
    765768        if not self._varshape: 
    766             result = MaskedArray.reshape(self, newshape) 
    767             result._dates = self._dates.reshape(newshape) 
     769            kwargs.update(order=kwargs.get('order','C')) 
     770            result = MaskedArray.reshape(self, *newshape, **kwargs) 
     771            result._dates = ndarray.reshape(self._dates, *newshape, **kwargs) 
    768772        # nV/nD series: raise an exception for now ( 
    769773        else: