Commit 99d804fe authored by Moritz Huebner's avatar Moritz Huebner

Merge branch 'master' of

parents 9e024ce3 eb891603
......@@ -30,18 +30,27 @@ exitcode-jessie:
- coverage run --include=tupak/* -a test/
- coverage html
- coverage-badge -o coverage_badge.svg -f
# Make the documentation
- pip install -r docs/requirements.txt
- cd docs
- make html
- htmlcov/
- coverage_badge.svg
- docs/_build/html/
stage: deploy
- exitcode-jessie
- mkdir public/
- mv htmlcov/ public/
- mv /builds/Monash/tupak/coverage_badge.svg public/
- mv docs/_build/html/* public/
- public
[![pipeline status](](
[![coverage report](](
# Tupak
......@@ -81,6 +81,6 @@ have also written [a shortened tl;dr here](./
We have a variety of tests which can be found in the `tests` directory. You
can find a [current coverage report for master
# Minimal makefile for Sphinx documentation
# You can set these variables from the command line.
SPHINXBUILD = python -msphinx
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
\ No newline at end of file
# -*- coding: utf-8 -*-
# tupak documentation build configuration file, created by
# sphinx-quickstart on Fri May 25 12:08:01 2018.
# This file is execfile()d with the current directory set to its
# containing dir.
# Note that not all possible configuration values are present in this
# autogenerated file.
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
import os
import sys
sys.path.insert(0, os.path.abspath('../tupak/'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax', 'numpydoc',
'nbsphinx', 'sphinx.ext.autosummary']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix = ['.rst', '.md']
source_suffix = '.txt'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'tupak'
copyright = u'2018, Paul Lasky'
author = u'Paul Lasky'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
# The short X.Y version.
version = u'0.2'
# The full version, including alpha/beta/rc tags.
release = u'0.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'requirements.txt']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
# This is required for the alabaster theme
# refs:
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'tupakdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# Latex figure (float) alignment
# 'figure_align': 'htbp',
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'tupak.tex', u'tupak Documentation',
u'Paul Lasky', 'manual'),
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'tupak', u'tupak Documentation',
[author], 1)
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'tupak', u'tupak Documentation',
author, 'tupak', 'One line description of project.',
Welcome to tupak's documentation!
.. automodule:: tupak
.. toctree::
:maxdepth: 3
:caption: Contents:
Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
`tupak` likelihood objects are used in calculating the likelihood of the data
for some specific set of parameters. In mathematical notation, the likelihood
can be generically written as :math:`\mathcal{L}(d| \theta)`. How this is
coded up will depend on the problem, but `tupak` expects all likelihood
objects to have a `parameters` attribute (a dictionary of key-value pairs) and
a `log_likelihood()` method.
The default likelihood we use in the examples is `GravitationalWaveTransient`:
.. autoclass:: tupak.likelihood.GravitationalWaveTransient
We also provide a simpler likelihood
.. autoclass:: tupak.likelihood.BasicGravitationalWaveTransient
We provide an empty parent class which can be subclassed for alternative use
.. autoclass:: tupak.likelihood.Likelihood
html5lib==1.0b8 # Hack to ensure documentation generated
Given a `likelihood` and `prior`, we can run parameter estimation using `run_sampler`
.. autofunction:: tupak.sampler.run_sampler
Writing documentation
This is a short tutorial on how to contribute to the documentation of ``tupak``.
Writing the basics
First, open your terminal and head to the ``docs`` directory in your clone of
`tupak`. Once here, you'll notice there are a number of `*txt` files. Each one
is a page of the documentation.
Let's say you want to write documentation about the your new feature (or update
the existing documentation). Simply open a new file ``a-new-feature.txt`` in
your text editor. Then add a title and some text::
A new tupak feature!
Here we'll put a description of the new feature
Next, in order to get your new page known by the rest of the documentation,
open ``index.rst`` and, under ``toctree`` add the name of your file (without
the suffix). For the example above::
.. toctree::
:maxdepth: 3
:caption: Contents:
Checking the results
You can check what this will look like by (whilst in the ``docs`` directory)
running the command::
$ make html
This will create a directory ``./_build/html`` with the documentation. To
see the result, open the file ``./_build/html/index.html`` in your browser.
Pushing your changes to master
To contribute your documentation changes, you should create a branch and add in
all of the new/changed files::
$ git checkout -b adding-my-new-documentation
$ git add index.txt
$ git add a-new-feature.txt
$ git commit -m "Adding my documentation for the feature"
$ git push origin adding-my-new-documentation
Then, on the web interface create an merge request.
Using reStructured text
The help files are written in reStructured text format. To familiarise yourself
with these features visit
A useful feature is the ability to `format code examples <>`_. This is done through the use of ``::`` and indendentation. For
example, to make this code block::
import tupak
You would write::
to make this code block::
import tupak
reStructured text is very powerful, but can be quite particular. For example,
**all code blocks must be indented by 3 spaces**.
Sphinx autodoc
Most of the documentation for ``tupak`` should be written in the `docstrings
<>`_ of the functions themselves. We
can add these into the online documentation using `autodoc
<>`_. To add the documentation
for a class, add a line such as::
.. autoclass:: tupak.likelihood.GravitationalWaveTransient
into your documentation file. Similarly, to document a function::
.. autofunction:: tupak.sampler.run_sampler
......@@ -4,17 +4,24 @@ from distutils.core import setup
import subprocess
# Write a version file containing the git hash and info
git_log = subprocess.check_output(['git', 'log', '-1', '--pretty=%h %ai']).decode('utf-8')
git_diff = (subprocess.check_output(['git', 'diff', '.'])
+ subprocess.check_output(['git', 'diff', '--cached', '.'])).decode('utf-8')
if git_diff == '':
status = '(CLEAN) ' + git_log
status = '(UNCLEAN) ' + git_log
git_log = subprocess.check_output(
['git', 'log', '-1', '--pretty=%h %ai']).decode('utf-8')
git_diff = (subprocess.check_output(['git', 'diff', '.'])
+ subprocess.check_output(
['git', 'diff', '--cached', '.'])).decode('utf-8')
if git_diff == '':
status = '(CLEAN) ' + git_log
status = '(UNCLEAN) ' + git_log
except subprocess.CalledProcessError:
version_file = '.version'
with open('tupak/' + version_file, 'w+') as f:
Tupak is The User friendly Parameter estimAtion Kode
from __future__ import print_function, division
# import local files, utils should be imported first
......@@ -527,11 +527,16 @@ def get_empty_interferometer(name):
minimum_frequency=20, maximum_frequency=2048,
latitude=43 + 37. / 60 + 53.0921 / 3600, longitude=10 + 30. / 60 + 16.1878 / 3600,
elevation=51.884, xarm_azimuth=70.5674, yarm_azimuth=160.5674),
'GEO600': Interferometer(name='GEO600', power_spectral_density=PowerSpectralDensity(asd_file='GEO600_S6e_asd.txt'),
minimum_frequency=40, maximum_frequency=2048,
length=0.6, latitude=52 + 14. / 60 + 42.528 / 3600, longitude=9 + 48. / 60 + 25.894 / 3600,
xarm_azimuth=115.9431, yarm_azimuth=21.6117)
'GEO600': Interferometer(name='GEO600',
minimum_frequency=40, maximum_frequency=2048, length=0.6,
latitude=52 + 14. / 60 + 42.528 / 3600, longitude=9 + 48. / 60 + 25.894 / 3600,
elevation=114.425, xarm_azimuth=115.9431, yarm_azimuth=21.6117),
'CE': Interferometer(name='CE', power_spectral_density=PowerSpectralDensity('CE_psd.txt'),
minimum_frequency=10, maximum_frequency=2048,
length=40, latitude=46 + 27. / 60 + 18.528 / 3600,
longitude=-(119 + 24. / 60 + 27.5657 / 3600), elevation=142.554, xarm_azimuth=125.9994,
yarm_azimuth=215.994, xarm_tilt=-6.195e-4, yarm_tilt=1.25e-5),
if name in known_interferometers.keys():
......@@ -39,7 +39,7 @@ class Result(dict):
def __init__(self, dictionary=None):
if type(dictionary) is dict:
for key in dictionary:
setattr(self, key, dictionary[key])
setattr(self, key, self._decode_object(dictionary[key]))
def __getattr__(self, name):
......@@ -62,6 +62,22 @@ class Result(dict):
return ''
def _decode_object(self, item):
""" When reading in data, ensure all bytes are decoded to strings """
return item.decode()
except AttributeError:
return [i.decode() for i in item]
except (AttributeError, TypeError):
logging.debug("Unable to decode item")
return item
def get_result_dictionary(self):
return dict(self)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment