Changeset 1044

Show
Ignore:
Timestamp:
06/18/08 20:42:59 (2 months ago)
Author:
mattknox_ca
Message:

- removed hard coded version references
- removed old commented out code

Files:

Legend:

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

    r1043 r1044  
    88 
    99__author__ = "Pierre GF Gerard-Marchant  & Matt Knox ($Author$)" 
    10 #__version__ = '0.67' 
    1110__revision__ = "$Revision$" 
    1211__date__     = '$Date$' 
  • trunk/timeseries/scikits/timeseries/const.py

    r1043 r1044  
    7474""" 
    7575__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" 
    76 __version__ = '0.67' 
    7776__revision__ = "$Revision$" 
    7877__date__     = '$Date$' 
  • trunk/timeseries/scikits/timeseries/extras.py

    r1032 r1044  
    77""" 
    88__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" 
    9 __version__ = '0.67' 
    109__revision__ = "$Revision$" 
    1110__date__     = '$Date$' 
     
    143142            fcode = _c.FR_HR 
    144143        elif getattr(res, 'day', 0) >= 1: 
    145             fcode = _c.FR_DAY            
     144            fcode = _c.FR_DAY 
    146145        elif getattr(res, 'day', 0) >= 7: 
    147146            fcode = _c.FR_WK 
  • trunk/timeseries/scikits/timeseries/lib/__init__.py

    r1032 r1044  
    55""" 
    66__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" 
    7 __version__ = '0.67' 
    87__revision__ = "$Revision$" 
    98__date__     = '$Date$' 
  • trunk/timeseries/scikits/timeseries/lib/avcf.py

    r1032 r1044  
    88""" 
    99__author__ = "Pierre GF Gerard-Marchant ($Author$)" 
    10 __version__ = '1.0' 
    1110__revision__ = "$Revision$" 
    1211__date__     = '$Date$' 
     
    3938where $j$ is the lag. 
    4039Positive lags: 
    41 N.correlate(y,x)[n//2+j] = N.correlate(x,y)[n//2-j] = gamma[j]  
     40N.correlate(y,x)[n//2+j] = N.correlate(x,y)[n//2-j] = gamma[j] 
    4241""" 
    4342 
    4443def lags(x, y=None): 
    4544    """Returns the lags at which a cross-correlation is computed. 
    46      
     45 
    4746:Parameters: 
    4847    `x` : Sequence 
     
    6362    return L 
    6463 
    65      
     64 
    6665#............................................................................... 
    6766 
     
    7473and ending point match. 
    7574 
    76     The crosscovariance at lag k, $\hat{R_{x,y}}(k)$, of 2 series {x_1,...,x_n}  
     75    The crosscovariance at lag k, $\hat{R_{x,y}}(k)$, of 2 series {x_1,...,x_n} 
    7776and {y_1,...,y_n} with mean 0 is defined as: 
    7877\hat{R_{x,y}(k) = \sum_{t=1}^{n-k}{x_t y_{t+k}} / \sum_{t=1}^{n-k}{a_t b_{t+k}} 
     
    8382If the optional parameter `periodogram` is True, the denominator of the previous 
    8483expression is $\sum_{t=1}^{n-k}{a_t a_{t+k}} + k$. 
    85   
     84 
    8685Parameters 
    8786---------- 
    8887    x : sequence 
    89         Input data.  
     88        Input data. 
    9089    y : sequence 
    91         Input data.  
     90        Input data. 
    9291        If y is longer than x, it is truncated to match the length of x. 
    9392        If y is shorter than x, x is truncated. 
    9493    periodogram : {True, False} optional 
    9594        Whether to return a periodogram or a standard estimate of the autocovariance. 
    96          
     95 
    9796Returns 
    9897------- 
    9998    cvf : ma.array 
    10099        Cross-covariance at lags [0,1,...,n,n-1,...,-1] 
    101      
     100 
    102101    """ 
    103102    # 
     
    134133 
    135134 
    136 def ccf(x, y, periodogram=True):     
     135def ccf(x, y, periodogram=True): 
    137136    """Computes the auto-correlation of the series x and y at different lags. 
    138137The computations are performed on anomalies (deviations from average). 
     
    141140If x and y are valid TimeSeries object, they are aligned so that their starting 
    142141and ending point match. 
    143   
     142 
    144143Parameters 
    145144---------- 
    146145    x : sequence 
    147         Input data.  
     146        Input data. 
    148147    y : sequence 
    149         Input data.  
     148        Input data. 
    150149        If y is longer than x, it is truncated to match the length of x. 
    151150        If y is shorter than x, x is truncated. 
    152151    periodogram : {True, False} optional 
    153152        Whether to return a periodogram or a standard estimate of the autocovariance. 
    154          
     153 
    155154Returns 
    156155------- 
     
    176175If the optional parameter `periodogram` is True, the denominator of the previous 
    177176expression is $\sum_{t=1}^{n-k}{a_t a_{t+k}} + k$. 
    178   
     177 
    179178Parameters 
    180179---------- 
     
    183182    mode : {True, False} optional 
    184183        Whether to return a periodogram or a standard estimate of the autocovariance. 
    185          
     184 
    186185Returns 
    187186------- 
    188187    avf : ma.array 
    189188        Autocovariance at lags [0,1,...,n,n-1,...,-1] 
    190          
     189 
    191190    """ 
    192191    x = ma.array(x, copy=False, subok=True, dtype=float) 
     
    215214Gaps in the series are filled first, anomalies are then computed and missing 
    216215values filled with 0. 
    217   
    218   
     216 
     217 
    219218Parameters 
    220219---------- 
     
    223222    mode : {True, False} optional 
    224223        Whether to return a periodogram or a standard estimate of the autocorrelation. 
    225          
     224 
    226225Returns 
    227226------- 
     
    239238Gaps in the series are filled first, the anomalies are then computed and the missing 
    240239values filled with 0. 
    241   
     240 
    242241:Parameters: 
    243242    `x` : TimeSeries 
     
    259258    if mode: 
    260259        dnm_ = np.fromiter((np.sum(x[k:]*x[:-k])/np.sum(m[k:]*xx[:-k]) 
    261                             for k in range(1,n)),  
     260                            for k in range(1,n)), 
    262261                            dtype=float) 
    263262    else: 
    264263        dnm_ = np.fromiter((np.sum(x[k:]*x[:-k])/\ 
    265264                            np.sqrt((m[k:]*xx[:-k]).sum() * (m[:-k]*xx[k:]).sum()) 
    266                             for k in range(1,n)),  
     265                            for k in range(1,n)), 
    267266                           dtype=float) 
    268267    poslags = _avf[1:]/dnm_ 
    269     return ma.fix_invalid(np.concatenate([np.array([1.]),  
    270                                           poslags,  
     268    return ma.fix_invalid(np.concatenate([np.array([1.]), 
     269                                          poslags, 
    271270                                          poslags[::-1]])) 
    272271 
    273 ##..............................................................................     
     272##.............................................................................. 
    274273def acf_std(x, maxlag=None, periodogram=True, 
    275274            confidence=0.6826895, simplified=True, acf_cached=None): 
    276     """Computes the approximate standard deviation of the autocorrelation  
     275    """Computes the approximate standard deviation of the autocorrelation 
    277276coefficients. 
    278277 
     
    280279Parameters 
    281280---------- 
    282     x : ndarray  
     281    x : ndarray 
    283282        Input data. 
    284283    maxlag : {None, int} optional 
     
    286285    periodogram : {True, False} 
    287286        Whether to use a periodogram-like estimate of the ACF or not. 
    288     confidence : {0.6826895, float} optional  
     287    confidence : {0.6826895, float} optional 
    289288        Confidence level. The default value returns the standard deviation. 
    290289    simplified : {True, False} optional 
     
    292291    acf_cached : {ndarray} optional 
    293292        Pre-computed acf coefficients. 
    294          
     293 
    295294Notes 
    296295----- 
     
    302301\begin{equation} 
    303302\begin{split} 
    304 var[r_k] &\approx  
     303var[r_k] &\approx 
    305304    \frac{1}{N} \sum_{j=-\infty}^{+\infty}{ \left\{ 
    306305        r_{j}^2 + r_{j+k} r_{j-k} - 4 r_{k} r_{j} r_{j-k} + 2 r_{j}^2 r_{k}^2 
     
    308307    \frac{1}{N} \sum_{j=-\infty}^{+\infty}{ \left\{ 
    309308        r_{j}^2 [ 1 + 2 r_{k}^2] + r_{j+k} r_{j-k} - 4 r_{k} r_{j} r_{j-k} 
    310         \right\}  
     309        \right\} 
    311310\end{split} 
    312311\end{equation} 
     
    348347##.............................................................................. 
    349348def pacf(x, periodogram=True, lagmax=None): 
    350     """Computes the partial autocorrelation function of series `x` along  
     349    """Computes the partial autocorrelation function of series `x` along 
    351350    the given axis. 
    352351 
     
    355354        Time series. 
    356355    periodogram : {True, False} optional 
    357         Whether to use a periodogram-like estimate of the ACF or not.         
     356        Whether to use a periodogram-like estimate of the ACF or not. 
    358357    lagmax : {None, int} optional 
    359358        Maximum lag. If None, the maximum lag is set to n/4+1, with n the series 
    360         length.         
    361     """     
     359        length. 
     360    """ 
    362361    acfx = acf(x, periodogram)[:,None] 
    363362    # 
  • trunk/timeseries/scikits/timeseries/lib/interpolate.py

    r1032 r1044  
    77""" 
    88__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" 
    9 __version__ = '1.0' 
    109__revision__ = "$Revision$" 
    1110__date__     = '$Date$' 
  • trunk/timeseries/scikits/timeseries/lib/moving_funcs.py

    r1043 r1044  
    88""" 
    99__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" 
    10 __version__ = '0.67' 
    1110__revision__ = "$Revision$" 
    1211__date__     = '$Date$' 
  • trunk/timeseries/scikits/timeseries/lib/plotlib.py

    r1032 r1044  
    88""" 
    99__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" 
    10 __version__ = '0.67' 
    1110__revision__ = "$Revision$" 
    1211__date__     = '$Date$' 
  • trunk/timeseries/scikits/timeseries/lib/reportlib.py

    r1043 r1044  
    5454""" 
    5555__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" 
    56 __version__ = '0.67' 
    5756__revision__ = "$Revision$" 
    5857__date__     = '$Date$' 
  • trunk/timeseries/scikits/timeseries/lib/tests/test_avcf.py

    r956 r1044  
    88""" 
    99__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" 
    10 __version__ = '1.0' 
    1110__revision__ = "$Revision: 55 $" 
    1211__date__     = '$Date: 2006-12-20 03:24:40 -0500 (Wed, 20 Dec 2006) $' 
     
    4443        self.fdeaths = [901, 689, 827, 677, 522, 406, 441, 393, 387, 582, 578, 
    4544                        666, 830, 752, 785, 664, 467, 438, 421, 412, 343, 440, 
    46                         531, 771, 767,1141, 896, 532, 447, 420, 376, 330, 357,  
    47                         445, 546, 764, 862, 660, 663, 643, 502, 392, 411, 348,  
    48                         387, 385, 411, 638, 796, 853, 737, 546, 530, 446, 431,  
    49                         362, 387, 430, 425, 679, 821, 785, 727, 612, 478, 429,  
     45                        531, 771, 767,1141, 896, 532, 447, 420, 376, 330, 357, 
     46                        445, 546, 764, 862, 660, 663, 643, 502, 392, 411, 348, 
     47                        387, 385, 411, 638, 796, 853, 737, 546, 530, 446, 431, 
     48                        362, 387, 430, 425, 679, 821, 785, 727, 612, 478, 429, 
    5049                        405, 379, 393, 411, 487, 574] 
    5150        self.mdeaths = ma.asarray(self.mdeaths) 
    5251        self.fdeaths = ma.asarray(self.fdeaths) 
    53      
     52 
    5453    # 
    5554    def test_avf_nomasked(self): 
     
    8786        assert_almost_equal(avfp[:21], 
    8887                            np.r_[[pz.var()], 
    89                                   [(pz[k:]*pz[:-k]).sum()/(mz[k:]*mz[:-k]).sum()  
     88                                  [(pz[k:]*pz[:-k]).sum()/(mz[k:]*mz[:-k]).sum() 
    9089                                   for k in range(1,21)]]) 
    9190    #...................................................... 
     
    9796        assert_almost_equal(cvfmf[:16].round(), 
    9897                            [ 74941, 56473, 27961, -820,-29395,-47777,-52855, 
    99                              -46871,-29427, -1390, 30090, 50403,55378, 49061,  
     98                             -46871,-29427, -1390, 30090, 50403,55378, 49061, 
    10099                             27739,-260]) 
    101100        assert_almost_equal(cvfmf[-15:].round(), 
    102101                            [  1156, 28067, 47243, 54365, 47740, 26100, -1883, 
    103                              -29299,-46964,-52031,-46368,-26827,  1517, 31105,  
     102                             -29299,-46964,-52031,-46368,-26827,  1517, 31105, 
    104103                              57137,]) 
    105104    #...................................................... 
     
    107106        (mdeaths, fdeaths) = (self.mdeaths, self.fdeaths) 
    108107        (mdeaths_, fdeaths_) = (mdeaths.copy(), fdeaths.copy()) 
    109         mdeaths_[0] = fdeaths_[-1] = ma.masked         
     108        mdeaths_[0] = fdeaths_[-1] = ma.masked 
    110109        cvfmf = cvf(mdeaths_,fdeaths_) 
    111110        assert_almost_equal(cvfmf[:16].round(4), 
     
    128127                             -0.046,-0.059, 0.068, 0.148, 0.061]) 
    129128        mdeaths_ = mdeaths.copy() 
    130         mdeaths_[0] = ma.masked         
     129        mdeaths_[0] = ma.masked 
    131130        pacfm = pacf(mdeaths_) 
    132131        assert_almost_equal(pacfm[:19].round(3), 
  • trunk/timeseries/scikits/timeseries/lib/tests/test_interpolate.py

    r768 r1044  
    55""" 
    66__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: matthew.brett@gmail.com $)" 
    7 __version__ = '1.0' 
    87__revision__ = "$Revision: 3836 $" 
    98__date__     = '$Date: 2008-01-15 08:09:03 -0500 (Tue, 15 Jan 2008) $' 
  • trunk/timeseries/scikits/timeseries/lib/tests/test_moving_funcs.py

    r1029 r1044  
    77""" 
    88__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: pierregm $)" 
    9 __version__ = '1.0' 
    109__revision__ = "$Revision: 2819 $" 
    1110__date__     = '$Date: 2007-03-03 18:00:20 -0500 (Sat, 03 Mar 2007) $' 
     
    7776            assert(isinstance(ravg, MaskedArray)) 
    7877            #!!!: __getitem__[int] used to return a TimeSeries, now returns an array 
    79 #            assert_almost_equal(ravg[18]._series.squeeze(),  
     78#            assert_almost_equal(ravg[18]._series.squeeze(), 
    8079#                                data[18-k:18+k+1]._series.mean(0)) 
    81             assert_almost_equal(ravg[18].squeeze(),  
     80            assert_almost_equal(ravg[18].squeeze(), 
    8281                                data[18-k:18+k+1]._series.mean(0)) 
    8382            m = np.zeros(data.shape, bool) 
  • trunk/timeseries/scikits/timeseries/setup.py

    r1032 r1044  
    11 
    2 __version__ = '0.67' 
    32__revision__ = "$Revision$" 
    43__date__     = '$Date$' 
  • trunk/timeseries/scikits/timeseries/tdates.py

    r1043 r1044  
    1010 
    1111__author__ = "Pierre GF Gerard-Marchant & Matt Knox" 
    12 __version__ = '1.0' 
    1312__revision__ = "$Revision$" 
    1413__date__     = '$Date$' 
    15  
    1614 
    1715import datetime as dt 
     
    2018import warnings 
    2119import types 
    22  
    2320 
    2421import numpy as np 
     
    377374        _result = np.empty(self.shape, dtype=np.object_) 
    378375        _result.flat = [d.datetime for d in self.ravel()] 
    379 #        for idx, val in numpy.ndenumerate(self): 
    380 #            operator.setitem(_result, idx, Date(freq=self.freq, value=val).datetime) 
    381376        return _result.tolist() 
    382377    # 
     
    545540            return self[-1] 
    546541        return None 
    547  
    548 #............................ 
    549542 
    550543nodates = DateArray([]) 
     
    644637    if end_date is None: 
    645638        if length is None: 
    646 #            raise ValueError,"No length precised!" 
    647639            length = 1 
    648640    else: 
  • trunk/timeseries/scikits/timeseries/tests/test_dates.py

    r1036 r1044  
    77""" 
    88__author__ = "Pierre GF Gerard-Marchant ($Author: matthew.brett@gmail.com $)" 
    9 __version__ = '1.0' 
    109__revision__ = "$Revision: 3836 $" 
    1110__date__     = '$Date: 2008-01-15 08:09:03 -0500 (Tue, 15 Jan 2008) $' 
  • trunk/timeseries/scikits/timeseries/tests/test_extras.py

    r941 r1044  
    88""" 
    99__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: matthew.brett@gmail.com $)" 
    10 __version__ = '1.0' 
    1110__revision__ = "$Revision: 3836 $" 
    1211__date__     = '$Date: 2008-01-15 08:09:03 -0500 (Tue, 15 Jan 2008) $' 
    13  
    1412 
    1513import numpy as np 
  • trunk/timeseries/scikits/timeseries/tests/test_timeseries.py

    r1037 r1044  
    88""" 
    99__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: matthew.brett@gmail.com $)" 
    10 __version__ = '1.0' 
    1110__revision__ = "$Revision: 3836 $" 
    1211__date__     = '$Date: 2008-01-15 08:09:03 -0500 (Tue, 15 Jan 2008) $' 
  • trunk/timeseries/scikits/timeseries/tests/test_trecords.py

    r1029 r1044  
    77""" 
    88__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: matthew.brett@gmail.com $)" 
    9 __version__ = '1.0' 
    109__revision__ = "$Revision: 3836 $" 
    1110__date__     = '$Date: 2008-01-15 08:09:03 -0500 (Tue, 15 Jan 2008) $' 
     
    214213    # 
    215214    def setup(self): 
    216         a = time_series(np.random.rand(24),  
     215        a = time_series(np.random.rand(24), 
    217216                        start_date=ts.now('M')) 
    218         b = time_series(np.random.rand(24)*100, dtype=int,  
     217        b = time_series(np.random.rand(24)*100, dtype=int, 
    219218                        start_date=ts.now('M'),) 
    220 #        c = time_series(["%02i" % _ for _ in np.arange(24)],  
     219#        c = time_series(["%02i" % _ for _ in np.arange(24)], 
    221220#                         start_date=ts.now('M')) 
    222         c = time_series(np.arange(24),  
     221        c = time_series(np.arange(24), 
    223222                         start_date=ts.now('M')) 
    224223        trec = fromarrays([a,b,c], dates=a.dates, names='a,b,c') 
     
    235234        for key in ('a','b','c'): 
    236235            assert_equal(a_trec[key], base[key].convert('A', ma.mean)) 
    237          
     236 
    238237 
    239238############################################################################### 
  • trunk/timeseries/scikits/timeseries/trecords.py

    r1032 r1044  
    88""" 
    99__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" 
    10 __version__ = '1.0' 
    1110__revision__ = "$Revision$" 
    1211__date__     = '$Date$' 
     
    117116 
    118117    def __array_finalize__(self,obj): 
    119         self.__dict__.update(_varshape = getattr(obj, '_varshape', ()),  
     118        self.__dict__.update(_varshape = getattr(obj, '_varshape', ()), 
    120119                             _dates=getattr(obj,'_dates',DateArray([])), 
    121120                             _observed=getattr(obj,'_observed',None), 
     
    211210        if self.size > 1: 
    212211            mstr = ["(%s)" % ",".join([str(i) for i in s]) 
    213                     for s in zip(*[getattr(self,f)._series  
     212                    for s in zip(*[getattr(self,f)._series 
    214213                                   for f in self.dtype.names])] 
    215214            return "[%s]" % ", ".join(mstr) 
    216215        else: 
    217216            mstr = ["%s" % ",".join([str(i) for i in s]) 
    218                     for s in zip([getattr(self,f)._series  
     217                    for s in zip([getattr(self,f)._series 
    219218                                  for f in self.dtype.names])] 
    220219            return "(%s)" % ", ".join(mstr) 
     
    276275        if a func is specified that requires additional keyword parameters, 
    277276        specify them here. 
    278      
     277 
    279278        """ 
    280279        kwargs.update(func=func, position=position) 
    281280        field_names = self.dtype.names 
    282281        by_field = [self[f].convert(freq,**kwargs) for f in field_names] 
    283         output = fromarrays(by_field,  
     282        output = fromarrays(by_field, 
    284283                            dates=by_field[0].dates, 
    285284                            names=field_names) 
     
    421420    #!!!: Anyway, we need to use numpy.io first, shouldn't we ? 
    422421    #!!!: Using the kind of autodetermination of dtypes, or all-as-object 
    423 #    err_msg = "trecords.fromtextfile is temporarily out of service.\n"\ 
    424 #              "Please accept our apologies for any inconvenience." 
    425 #    raise NotImplementedError(err_msg) 
    426      
     422 
    427423    # Declare the pattern for the dates column 
    428424    import re 
  • trunk/timeseries/scikits/timeseries/tseries.py

    r1037 r1044  
    2020 
    2121__author__ = "Pierre GF Gerard-Marchant & Matt Knox" 
    22 __version__ = '1.0' 
    2322__revision__ = "$Revision$" 
     23__date__     = '$Date$' 
    2424 
    2525import sys 
     
    721721            raise NotImplementedError(err_msg) 
    722722            #!!!: We could also not do anything... 
    723             #result._dates = self._dates 
    724723        return result 
    725724 
     
    10631062    def __call__ (self, *args, **params): 
    10641063        raise NotImplementedError 
    1065 #TimeSeries.transpose = _tsarraymethod('transpose', ondates=True) 
     1064 
    10661065TimeSeries.swapaxes = _tsarraymethod('swapaxes', ondates=True) 
    1067  
    10681066 
    10691067#####--------------------------------------------------------------------------- 
     
    14801478                          length=len(tmpdata), 
    14811479                          freq=to_freq) 
    1482 #    assert(get_varshape(tmpdata, newdates), newvarshape) 
    14831480 
    14841481    newseries = tmpdata.view(type(series)) 
     
    17071704            err_msg = "fill_missing_dates is not yet implemented for nD series!" 
    17081705            raise NotImplementedError(err_msg) 
    1709 #    if dates.ndim > 1 and dates.ndim == datad.ndim: 
    1710 #        datad.shape = -1 
    17111706    # ...and now, fill it ! ...... 
    17121707    (tstart, tend) = dflat[[0,-1]]