Skip to content

Commit

Permalink
Fixed documentation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Apr 18, 2019
1 parent c7e6200 commit 23da5f3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
3 changes: 1 addition & 2 deletions astropy/timeseries/core.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

from astropy.table import QTable
from astropy.utils.misc import InheritDocstrings

__all__ = ['BaseTimeSeries']


class BaseTimeSeries(QTable, metaclass=InheritDocstrings):
class BaseTimeSeries(QTable):

_required_columns = None

Expand Down
6 changes: 4 additions & 2 deletions astropy/timeseries/sampled.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
from astropy.time import Time, TimeDelta
from astropy import units as u
from astropy.units import Quantity
from astropy.utils.misc import InheritDocstrings

from astropy.timeseries.core import BaseTimeSeries

__all__ = ['TimeSeries']


class TimeSeries(BaseTimeSeries, metaclass=InheritDocstrings):
class TimeSeries(BaseTimeSeries):
"""
A class to represent time series data in tabular form.
Expand Down Expand Up @@ -184,6 +183,9 @@ def __getitem__(self, item):
return super().__getitem__(item)

def add_columns(self, *args, **kwargs):
"""
See :meth:`~astropy.table.Table.add_columns`.
"""
# Note that the docstring is inherited from QTable
result = super().add_columns(*args, **kwargs)
if len(self.indices) == 0 and 'time' in self.colnames:
Expand Down
8 changes: 4 additions & 4 deletions docs/timeseries/data_access.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ with two data columns - ``flux`` and ``temp``::

As for |Table|, columns can be accessed by name::

>>> ts['flux']
<Quantity [1., 4., 5., 3., 2.] Jy>
>>> ts['flux'] # doctest: +FLOAT_CMP
<Quantity [ 1., 4., 5., 3., 2.] Jy>
>>> ts['time']
<Time object: scale='utc' format='isot' value=['2016-03-22T12:30:31.000' '2016-03-22T12:30:34.000'
'2016-03-22T12:30:37.000' '2016-03-22T12:30:40.000'
Expand All @@ -50,10 +50,10 @@ and rows can be accessed by index::
Accessing individual values can then be done either by accessing a column then a
row, or vice-versa::

>>> ts[0]['flux']
>>> ts[0]['flux'] # doctest: +FLOAT_CMP
<Quantity 1. Jy>

>>> ts['temp'][2]
>>> ts['temp'][2] # doctest: +FLOAT_CMP
<Quantity 39. K>

.. _timeseries-accessing-times:
Expand Down
18 changes: 12 additions & 6 deletions docs/timeseries/pandas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
Interfacing with the pandas package
***********************************

.. doctest-requires:: pandas

.. |Time| replace:: :class:`~astropy.time.Time`
.. |Quantity| replace:: :class:`~astropy.units.Quantity`
.. |TimeSeries| replace:: :class:`~astropy.timeseries.TimeSeries`
Expand All @@ -28,7 +26,9 @@ Nevertheless, there are cases where using pandas :class:`~pandas.DataFrame`
objects might make sense, so we provide methods to easily convert to/from
:class:`~pandas.DataFrame` objects.

Let's consider a simple example starting from a :class:`~pandas.DataFrame`::
Let's consider a simple example starting from a :class:`~pandas.DataFrame`:

.. doctest-requires:: pandas

>>> import pandas
>>> import numpy as np
Expand All @@ -43,7 +43,9 @@ Let's consider a simple example starting from a :class:`~pandas.DataFrame`::
2015-07-06 3

We can convert this to an astropy |TimeSeries| using
:meth:`~astropy.timeseries.TimeSeries.from_pandas`::
:meth:`~astropy.timeseries.TimeSeries.from_pandas`:

.. doctest-requires:: pandas

>>> from astropy.timeseries import TimeSeries
>>> ts = TimeSeries.from_pandas(df)
Expand All @@ -57,7 +59,9 @@ We can convert this to an astropy |TimeSeries| using
2015-07-06T00:00:00.000000000 3

Converting to :class:`~pandas.DataFrame` can also easily be done with
:meth:`~astropy.timeseries.TimeSeries.to_pandas`::
:meth:`~astropy.timeseries.TimeSeries.to_pandas`:

.. doctest-requires:: pandas

>>> ts['b'] = [1.2, 3.4, 5.4]
>>> df_new = ts.to_pandas()
Expand All @@ -69,7 +73,9 @@ Converting to :class:`~pandas.DataFrame` can also easily be done with
2015-07-06 3 5.4

Missing values in the time column are supported and correctly converted to
pandas' NaT object::
pandas' NaT object:

.. doctest-requires:: pandas

>>> ts.time[2] = np.nan
>>> ts
Expand Down

0 comments on commit 23da5f3

Please sign in to comment.