Changeset 1204

Show
Ignore:
Timestamp:
08/07/08 00:52:15 (4 months ago)
Author:
pierregm
Message:

docstring formatting

Files:

Legend:

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

    r1151 r1204  
    9898 
    9999def prevbusday(day_end_hour=18, day_end_min=0): 
    100     """Returns the previous business day (Monday-Friday) at business frequency. 
     100    """ 
     101    Returns the previous business day (Monday-Friday) at business frequency. 
    101102 
    102103    Parameters 
     
    111112    now('Business') will be returned. Otherwise, now('Business')-1 will be 
    112113    returned. 
    113 """ 
     114 
     115    """ 
    114116    tempDate = dt.datetime.now() 
    115117    dateNum = tempDate.hour + float(tempDate.minute)/60 
     
    177179 
    178180class DateArray(ndarray): 
    179     """Defines a ndarray of dates, as ordinals. 
    180  
    181 When viewed globally (array-wise), DateArray is an array of integers. 
    182 When viewed element-wise, DateArray is a sequence of dates. 
    183 For example, a test such as : 
    184 >>> DateArray(...) = value 
    185 will be valid only if value is an integer, not a Date 
    186 However, a loop such as : 
    187 >>> for d in DateArray(...): 
    188 accesses the array element by element. Therefore, `d` is a Date object. 
     181    """ 
     182    Defines a ndarray of dates, as ordinals. 
     183 
     184    When viewed globally (array-wise), DateArray is an array of integers. 
     185    When viewed element-wise, DateArray is a sequence of dates. 
     186    For example, a test such as : 
     187    >>> DateArray(...) = value 
     188    will be valid only if value is an integer, not a Date 
     189    However, a loop such as : 
     190    >>> for d in DateArray(...): 
     191    accesses the array element by element. Therefore, `d` is a Date object. 
    189192    """ 
    190193    def __new__(cls, dates=None, freq=None, copy=False): 
     
    320323    @property 
    321324    def qyear(self): 
    322         """For quarterly frequency dates, returns the year corresponding to the 
    323 year end (start) month. When using QTR or QTR-E based quarterly 
    324 frequencies, this is the fiscal year in a financial context. 
    325  
    326 For non-quarterly dates, this simply returns the year of the date.""" 
     325        """ 
     326    For quarterly frequency dates, returns the year corresponding to the 
     327    year end (start) month. When using QTR or QTR-E based quarterly 
     328    frequencies, this is the fiscal year in a financial context. 
     329 
     330    For non-quarterly dates, this simply returns the year of the date. 
     331 
     332    """ 
    327333 
    328334        return self.__getdateinfo__('F') 
     
    400406    # 
    401407    def asfreq(self, freq=None, relation="END"): 
    402         """Converts the dates to another frequency. 
    403  
    404 *Parameters*: 
     408        """ 
     409     
     410    Converts the dates to another frequency. 
     411 
     412    Parameters 
     413    ---------- 
    405414    freq : {freq_spec} 
    406415        Frequency to convert the DateArray to. Accepts any valid frequency 
     
    414423        For example, if converting a monthly date to a daily date, specifying 
    415424        'START' ('END') would result in the first (last) day in the month. 
    416 """ 
     425 
     426    """ 
    417427        # Note: As we define a new object, we don't need caching 
    418428        if freq is None or freq == _c.FR_UND: 
  • trunk/timeseries/scikits/timeseries/tseries.py

    r1203 r1204  
    879879original series (unlike the `convert` method). 
    880880 
    881 *Parameters*: 
     881    Parameters 
     882    ---------- 
    882883    freq : {freq_spec} 
    883884    relation : {'END', 'START'} (optional) 
    884885 
    885 *Returns*: 
    886     a new TimeSeries with the .dates DateArray at the specified frequency (the 
    887     .asfreq method of the .dates property will be called). The data in the 
     886    Returns 
     887    ------- 
     888    A new TimeSeries with the .dates DateArray at the specified frequency (the 
     889    `.asfreq` method of the .dates property will be called). The data in the 
    888890    resulting series will be a VIEW of the original series. 
    889891 
    890 *Notes*: 
     892    Notes 
     893    ----- 
    891894    The parameters are the exact same as for DateArray.asfreq , please see the 
    892895    __doc__ string for that method for details on the parameters and how the 
     
    899902    #..................................................... 
    900903    def transpose(self, *axes): 
    901         """Returns a view of the series with axes transposed 
    902  
    903 *Parameters*: 
    904     *axes : {integers} 
    905         the axes to swap 
    906  
    907 *Returns*: 
    908     a VIEW of the series with axes for both the data and dates transposed 
    909  
    910 *Notes*: 
     904        """ 
     905    Returns a view of the series with axes transposed 
     906 
     907    Parameters 
     908    ---------- 
     909    axes : {integers} 
     910        The axes to swap 
     911 
     912    Returns 
     913    ------- 
     914    A VIEW of the series with axes for both the data and dates transposed 
     915 
     916    Notes 
     917    ----- 
    911918    If no axes are given, the order of the axes are switches. For a 2-d array, 
    912919    this is the usual matrix transpose. If axes are given, they describe how 
     
    937944 
    938945    def filled(self, fill_value=None): 
    939         """Returns an array of the same class as `_data`,  with masked values 
    940 filled with `fill_value`. Subclassing is preserved. 
     946        """ 
     947 
     948    Returns an array of the same class as `_data`,  with masked values 
     949    filled with `fill_value`. Subclassing is preserved. 
    941950 
    942951    Parameters 
     
    951960 
    952961    def tolist(self): 
    953         """Returns the dates and data portion of the TimeSeries "zipped" up in 
    954 a list of standard python objects (eg. datetime, int, etc...).""" 
     962        """ 
     963    Returns the dates and data portion of the TimeSeries "zipped" up in 
     964    a list of standard python objects (eg. datetime, int, etc...). 
     965     
     966        """ 
    955967        if self.ndim > 0: 
    956968            return zip(self.dates.tolist(), self.series.tolist()) 
     
    961973    # Pickling 
    962974    def __getstate__(self): 
    963         "Returns the internal state of the TimeSeries, for pickling purposes." 
     975        """ 
     976     
     977    Returns the internal state of the TimeSeries, for pickling purposes. 
     978        """ 
    964979    #    raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" 
    965980        state = (1, 
     
    977992    # 
    978993    def __setstate__(self, state): 
    979         """Restores the internal state of the TimeSeries, for pickling purposes. 
     994        """ 
     995     
     996    Restores the internal state of the TimeSeries, for pickling purposes. 
    980997    `state` is typically the output of the ``__getstate__`` output, and is a 5-tuple: 
    981998 
     
    16001617#............................................................................... 
    16011618def tshift(series, nper, copy=True): 
    1602     """Returns a series of the same size as `series`, with the same 
    1603 start_date and end_date, but values shifted by `nper`. 
    1604  
    1605 *Parameters*: 
    1606     series : {TimeSeries} 
     1619    """ 
     1620    Returns a series of the same size as `series`, with the same `start_date` 
     1621    and `end_date`, but values shifted by `nper`. 
     1622 
     1623    Parameters 
     1624    ---------- 
     1625    series : TimeSeries 
    16071626        TimeSeries object to shift. Ignore this parameter if calling this as a 
    16081627        method. 
    1609     nper : {int} 
     1628    nper : int 
    16101629        number of periods to shift. Negative numbers shift values to the 
    16111630        right, positive to the left 
    1612     copy : {True, False} (optional) 
     1631    copy : {True, False}, optional 
    16131632        copies the data if True, returns a view if False. 
    16141633 
    1615 *Example*: 
    1616 >>> series = time_series([0,1,2,3], start_date=Date(freq='A', year=2005)) 
    1617 >>> series 
    1618 timeseries(data  = [0 1 2 3], 
    1619            dates = [2005 ... 2008], 
    1620            freq  = A-DEC) 
    1621 >>> tshift(series, -1) 
    1622 timeseries(data  = [-- 0 1 2], 
    1623            dates = [2005 ... 2008], 
    1624            freq  = A-DEC) 
    1625 >>> pct_change = 100 * (series/series.tshift(-1, copy=False) - 1) 
    1626 """ 
     1634    Example 
     1635    ------- 
     1636    >>> series = time_series([0,1,2,3], start_date=Date(freq='A', year=2005)) 
     1637    >>> series 
     1638    timeseries(data  = [0 1 2 3], 
     1639               dates = [2005 ... 2008], 
     1640               freq  = A-DEC) 
     1641    >>> tshift(series, -1) 
     1642    timeseries(data  = [-- 0 1 2], 
     1643               dates = [2005 ... 2008], 
     1644               freq  = A-DEC) 
     1645    >>> pct_change = 100 * (series/series.tshift(-1, copy=False) - 1) 
     1646 
     1647    """ 
    16271648    newdata = masked_array(np.empty(series.shape, dtype=series.dtype), 
    16281649                           mask=True) 
     
    16541675#............................................................................... 
    16551676def pct(series, nper=1): 
    1656     """Returns the rolling percentage change of the series. 
    1657  
    1658 *Parameters*: 
     1677    """ 
     1678    Returns the rolling percentage change of the series. 
     1679 
     1680    Parameters 
     1681    ---------- 
    16591682    series : {TimeSeries} 
    16601683        TimeSeries object to to calculate percentage chage for. Ignore this 
     
    16631686        number of periods for percentage change 
    16641687 
    1665 *Notes*: 
    1666     series of integer types will be upcast 
     1688    Notes 
     1689    ----- 
     1690    Series of integer types will be upcast 
    16671691    1.0 == 100% in result 
    16681692 
    1669 *Example*: 
    1670 >>> series = time_series([2.,1.,2.,3.], start_date=Date(freq='A', year=2005)) 
    1671 >>> series.pct() 
    1672 timeseries([-- -0.5 1.0 0.5], 
    1673            dates = [2005 ... 2008], 
    1674            freq  = A-DEC) 
    1675 >>> series.pct(2) 
    1676 timeseries([-- -- 0.0 2.0], 
    1677            dates = [2005 ... 2008], 
    1678            freq  = A-DEC) 
    1679 """ 
     1693    Examples 
     1694    -------- 
     1695    >>> series = time_series([2.,1.,2.,3.], start_date=Date(freq='A', year=2005)) 
     1696    >>> series.pct() 
     1697    timeseries([-- -0.5 1.0 0.5], 
     1698               dates = [2005 ... 2008], 
     1699               freq  = A-DEC) 
     1700    >>> series.pct(2) 
     1701    timeseries([-- -- 0.0 2.0], 
     1702               dates = [2005 ... 2008], 
     1703               freq  = A-DEC) 
     1704 
     1705    """ 
    16801706    _dtype = _get_type_num_double(series.dtype) 
    16811707    if _dtype != series.dtype: 
     
    16921718#............................................................................... 
    16931719def fill_missing_dates(data, dates=None, freq=None, fill_value=None): 
    1694     """Finds and fills the missing dates in a time series. The data 
    1695 corresponding to the initially missing dates are masked, or filled to 
    1696 `fill_value`. 
    1697  
    1698 *Parameters*: 
     1720    """ 
     1721    Finds and fills the missing dates in a time series. The data 
     1722    corresponding to the initially missing dates are masked, or filled to 
     1723    `fill_value`. 
     1724 
     1725    Parameters 
     1726    ---------- 
    16991727    data : {TimeSeries, ndarray} 
    17001728        Initial array of data. 
     
    17071735        Default value for missing data. If Not specified, the data are just 
    17081736        masked. 
    1709 """ 
     1737 
     1738    """ 
    17101739    # Check the frequency ........ 
    17111740    orig_freq = freq