Skip to content

Commit

Permalink
rtds
Browse files Browse the repository at this point in the history
  • Loading branch information
dfm committed Nov 17, 2018
1 parent 0d58de0 commit 5648a86
Show file tree
Hide file tree
Showing 11 changed files with 1,231 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_build
xml
39 changes: 39 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

default: dirhtml

.PHONY: clean
clean:
rm -rf $(BUILDDIR)/* $(TUTORIALS)

.PHONY: html
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

.PHONY: dirhtml
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

.PHONY: singlehtml
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
412 changes: 412 additions & 0 deletions docs/_static/notebooks/intro-to-pymc3.ipynb

Large diffs are not rendered by default.

427 changes: 427 additions & 0 deletions docs/_static/notebooks/quickstart.ipynb

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions docs/api/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
.. _install:

Installation
============

The core implementation of celerite is written in C++ so this will need to be
compiled to be called from Python. The easiest way for a new user to do this
will be by following the directions in the :ref:`using-conda` section below.
Power users might be able to eke out a bit more performance by tuning the
linear algebra library and installing :ref:`source`.

.. _using-conda:

Using conda
-----------

The easiest way to install celerite is using `conda
<http://continuum.io/downloads>`_ (via `conda-forge
<https://conda-forge.github.io/>`_) with the following command:

.. code-block:: bash
conda install -c conda-forge celerite
Using pip
---------

celerite can also be installed using `pip <https://pip.pypa.io>`_ after
installing `Eigen <http://eigen.tuxfamily.org/>`_:

.. code-block:: bash
pip install celerite
.. _source:

From Source
-----------

The source code for celerite can be downloaded `from GitHub
<https://github.com/dfm/celerite>`_ by running

.. code-block:: bash
git clone https://github.com/dfm/celerite.git
.. _python-deps:

Dependencies
++++++++++++

For the Python interface, you'll (obviously) need a Python installation and I
recommend `conda <http://continuum.io/downloads>`_ if you don't already have
your own opinions.

After installing Python, the following dependencies are required to build
celerite:

1. `NumPy <http://www.numpy.org/>`_ for math and linear algebra in Python, and
2. `pybind11 <https://pybind11.readthedocs.io>`_ for the Python–C++ interface.
3. `autograd <https://github.com/HIPS/autograd>`_ (optional) for computing
gradients in celerite models.

If you're using conda, you can install all of the dependencies with the
following command:

.. code-block:: bash
conda install -c conda-forge numpy pybind11 autograd
Building
++++++++

After installing the dependencies, you can build the celerite module by
running:

.. code-block:: bash
python setup.py install
in the root directory of the source tree.

Automatic differentiation
+++++++++++++++++++++++++

Gradients of celerite models are computed using automatic differentiation. By
default, this is implemented using the ``AutoDiffScalar`` in Eigen, but it is
possible to get faster performance by using the `stan-math library
<https://github.com/stan-dev/math>`_. To do this, download the library from
`the GitHub page <https://github.com/stan-dev/math>`_ and build celerite using
the following command:

.. code-block:: bash
python setup.py build_ext -I${STAN}:${STAN}/lib/boost_1.62.0:${STAN}/lib/cvodes_2.9.0/include -DUSE_STAN_MATH install
where ``${STAN}`` is the directory where you downloaded the stan-math library.


Testing
-------

To run the unit tests, install `pytest <http://doc.pytest.org/>`_ and then
execute:

.. code-block:: bash
py.test -v
All of the tests should (of course) pass.
If any of the tests don't pass and if you can't sort out why, `open an issue
on GitHub <https://github.com/dfm/celerite/issues>`_.
61 changes: 61 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import glob
import subprocess

import sphinx_nameko_theme

import exoplanet # NOQA

# Convert the tutorials
for fn in glob.glob("_static/notebooks/*.ipynb"):
name = os.path.splitext(os.path.split(fn)[1])[0]
print("Building {0}...".format(name))
subprocess.check_call(
"jupyter nbconvert --template tutorials/tutorial_rst --to rst "
+ fn + " --output-dir tutorials", shell=True)

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.mathjax",
]
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
'astropy': ('http://docs.astropy.org/en/stable/', None),
}

templates_path = ["_templates"]
source_suffix = ".rst"
master_doc = "index"

# General information about the project.
project = "exoplanet"
author = "Dan Foreman-Mackey"
copyright = "2018, " + author

version = exoplanet.__version__
release = exoplanet.__version__

exclude_patterns = ["_build"]
pygments_style = "sphinx"

# Readthedocs.
# on_rtd = os.environ.get("READTHEDOCS", None) == "True"
html_theme_path = [sphinx_nameko_theme.get_html_theme_path()]
html_theme = "nameko"

html_context = dict(
display_github=True,
github_user="dfm",
github_repo="exoplanet",
github_version="master",
conf_py_path="/docs/",
)
html_static_path = ["_static"]
html_show_sourcelink = False
16 changes: 16 additions & 0 deletions docs/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: exoplanet

channels:
- conda-forge

dependencies:
- python=3.5
- pandoc
- numpy
- scipy
- astropy
- setuptools
- pymc3
- jupyter
- pip:
- sphinx-nameko-theme
52 changes: 52 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
exoplanet
=========

*exoplanet* is being actively developed in `a public repository on GitHub
<https://github.com/dfm/exoplanet>`_ so if you have any trouble, `open an issue
<https://github.com/dfm/exoplanet/issues>`_ there.

.. raw:: html

<p>
<a href="https://travis-ci.org/dfm/exoplanet"><img src="https://img.shields.io/travis/dfm/exoplanet/master.svg?style=flat"/></a>
<br>
<a href="https://rodluger.github.io/starry"><img src="https://img.shields.io/badge/powered_by-starry-EB5368.svg?style=flat"/></a>
<a href="https://celerite.readthedocs.io"><img src="https://img.shields.io/badge/powered_by-celerite-EB5368.svg?style=flat"/></a>
<a href="https://docs.pymc.io"><img src="https://img.shields.io/badge/powered_by-PyMC3-EB5368.svg?style=flat"/></a>
<a href="http://www.astropy.org"><img src="https://img.shields.io/badge/powered_by-AstroPy-EB5368.svg?style=flat"/></a>
</p>


.. toctree::
:maxdepth: 2
:caption: Tutorials

tutorials/quickstart
tutorials/intro-to-pymc3


.. toctree::
:maxdepth: 2
:caption: API Documentation

api/install


License & Attribution
---------------------

Copyright 2018, Daniel Foreman-Mackey.

The source code is made available under the terms of the MIT license.

If you make use of this code, please cite the following paper:

.. code-block:: tex

tbd


Changelog
---------

.. include:: ../HISTORY.rst
94 changes: 94 additions & 0 deletions docs/tutorials/tutorial_rst.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{%- extends 'display_priority.tpl' -%}

{% block header %}
.. module:: celerite

.. note:: This tutorial was generated from an IPython notebook that can be
downloaded `here <../../_static/notebooks/{{ resources.metadata.name }}.ipynb>`_.

.. _{{resources.metadata.name}}:
{% endblock %}

{% block in_prompt %}
{% endblock in_prompt %}

{% block output_prompt %}
{% endblock output_prompt %}

{% block input %}
{%- if cell.source.strip() and not cell.source.startswith("%") -%}
.. code:: python

{{ cell.source | indent}}
{% endif -%}
{% endblock input %}

{% block error %}
::

{{ super() }}
{% endblock error %}

{% block traceback_line %}
{{ line | indent | strip_ansi }}
{% endblock traceback_line %}

{% block execute_result %}
{% block data_priority scoped %}
{{ super() }}
{% endblock %}
{% endblock execute_result %}

{% block stream %}
.. parsed-literal::

{{ output.text | indent }}
{% endblock stream %}

{% block data_svg %}
.. image:: {{ output.metadata.filenames['image/svg+xml'] | urlencode }}
{% endblock data_svg %}

{% block data_png %}
.. image:: {{ output.metadata.filenames['image/png'] | urlencode }}
{% endblock data_png %}

{% block data_jpg %}
.. image:: {{ output.metadata.filenames['image/jpeg'] | urlencode }}
{% endblock data_jpg %}

{% block data_latex %}
.. math::

{{ output.data['text/latex'] | strip_dollars | indent }}
{% endblock data_latex %}

{% block data_text scoped %}
.. parsed-literal::

{{ output.data['text/plain'] | indent }}
{% endblock data_text %}

{% block data_html scoped %}
.. raw:: html

{{ output.data['text/html'] | indent }}
{% endblock data_html %}

{% block markdowncell scoped %}
{{ cell.source | markdown2rst }}
{% endblock markdowncell %}

{%- block rawcell scoped -%}
{%- if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) %}
{{cell.source}}
{% endif -%}
{%- endblock rawcell -%}

{% block headingcell scoped %}
{{ ("#" * cell.level + cell.source) | replace('\n', ' ') | markdown2rst }}
{% endblock headingcell %}

{% block unknowncell scoped %}
unknown type {{cell.type}}
{% endblock unknowncell %}

0 comments on commit 5648a86

Please sign in to comment.