From cf48c412bd7c02d4fc6c0b05aa89be0306d64314 Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Mon, 25 Feb 2019 18:32:48 -0600 Subject: [PATCH 1/3] Small plotting fixes, including sign error and text size --- attune/workup/_intensity.py | 10 +++++++--- attune/workup/_plot.py | 19 ++++++++++++------- attune/workup/_tune_test.py | 5 ++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/attune/workup/_intensity.py b/attune/workup/_intensity.py index 8056ce3..74f6a0b 100644 --- a/attune/workup/_intensity.py +++ b/attune/workup/_intensity.py @@ -37,6 +37,7 @@ def intensity( cutoff_factor=0.1, autosave=True, save_directory=None, + **spline_kwargs, ): """Workup a generic intensity plot for a single dependent. @@ -72,8 +73,11 @@ def intensity( cutoff = channel.max() * cutoff_factor channel.clip(min=cutoff) - offsets = _intensity(data, channel.natural_name, setpoints[:]) - print(offsets) + offsets = _intensity(data, channel.natural_name, setpoints[:], **spline_kwargs) + try: + raw_offsets = _intensity(data, channel.natural_name, setpoints[:], spline=False) + except ValueError: + raw_offsets = None units = data.axes[1].units if units == "None": @@ -91,7 +95,7 @@ def intensity( # Why did we have to map setpoints? curve.map_setpoints(setpoints[:]) - fig, _ = plot_intensity(data, channel.natural_name, dependent, curve, old_curve) + fig, _ = plot_intensity(data, channel.natural_name, dependent, curve, old_curve, raw_offsets) if autosave: if save_directory is None: diff --git a/attune/workup/_plot.py b/attune/workup/_plot.py index 38eb2aa..08185cb 100644 --- a/attune/workup/_plot.py +++ b/attune/workup/_plot.py @@ -3,35 +3,40 @@ import numpy as np -def plot_intensity(data, channel, dependent, curve, prior_curve=None): +def plot_intensity(data, channel, dependent, curve, prior_curve=None, raw_offsets=None): fig, gs = wt.artists.create_figure( - width="double", nrows=2, cols=[1, "cbar"], default_aspect=.5 + width="single", nrows=2, cols=[1, "cbar"], default_aspect=.5 ) ax = plt.subplot(gs[0, 0]) - curve_plot_kwargs = {"lw": 4, "c": "k", "alpha": .75} + curve_plot_kwargs = {"lw": 5, "c": "k", "alpha": .5} prior_curve_plot_kwargs = {"lw": 2, "c": "k"} ax.plot(curve.setpoints[:], curve[dependent][:], **curve_plot_kwargs) if prior_curve: ax.plot(prior_curve.setpoints[:], prior_curve[dependent][:], **prior_curve_plot_kwargs) ax.set_ylabel(dependent) wt.artists.plot_gridlines() + ax.set_xlim(*curve.get_limits()) + ax.xaxis.set_tick_params(label1On=False) ax = plt.subplot(gs[1, 0]) ax.pcolor(data, channel=channel) - xlim = ax.get_xlim() if prior_curve: ypoints = ( - prior_curve(curve.setpoints[:], curve.setpoints.units, full=False)[dependent] - - curve[dependent][:] + curve[dependent][:] + - prior_curve(curve.setpoints[:], curve.setpoints.units, full=False)[dependent] ) else: ypoints = curve[dependent][:] + + if raw_offsets is not None: + ax.plot(curve.setpoints[:], raw_offsets, c="grey", lw=5, alpha=0.5) + ax.plot(curve.setpoints[:], ypoints, **curve_plot_kwargs) ax.axhline(0, **prior_curve_plot_kwargs) wt.artists.plot_gridlines() ax.set_ylabel(r"$\mathsf{{\Delta {dependent}}}$".format(dependent=dependent)) ax.set_xlabel(f"Setpoint ({curve.setpoints.units})") - ax.set_xlim(xlim) + ax.set_xlim(*curve.get_limits()) cax = plt.subplot(gs[1, 1]) ticks = np.linspace(data[channel].null, data[channel].max(), 11) diff --git a/attune/workup/_tune_test.py b/attune/workup/_tune_test.py index b3c02da..e1e788d 100644 --- a/attune/workup/_tune_test.py +++ b/attune/workup/_tune_test.py @@ -75,7 +75,10 @@ def tune_test( channel.clip(min=cutoff) offsets = _offsets(data, channel.natural_name, setpoints[:]) - raw_offsets = _offsets(data, channel.natural_name, data.axes[0].points, spline=False) + try: + raw_offsets = _offsets(data, channel.natural_name, data.axes[0].points, spline=False) + except ValueError: + raw_offsets = None # make curve ---------------------------------------------------------------------------------- new_curve = old_curve.copy() From 1539de43a81419c0bb73ecb32d7bfd940511dda7 Mon Sep 17 00:00:00 2001 From: ksunden Date: Wed, 10 Apr 2019 23:10:41 -0500 Subject: [PATCH 2/3] Initial boiler plate for docs generation --- docs/.gitignore | 4 + docs/Makefile | 20 +++ docs/api/attune.curve.rst | 10 ++ docs/api/attune.interpolator.rst | 10 ++ docs/api/attune.rst | 19 ++ docs/api/attune.workup.rst | 10 ++ docs/api/modules.rst | 7 + docs/conf.py | 290 +++++++++++++++++++++++++++++++ docs/contributing.rst | 147 ++++++++++++++++ docs/index.rst | 52 ++++++ docs/install.rst | 56 ++++++ docs/make.bat | 36 ++++ examples/README.txt | 4 + examples/simple_curve.py | 14 ++ 14 files changed, 679 insertions(+) create mode 100644 docs/.gitignore create mode 100644 docs/Makefile create mode 100644 docs/api/attune.curve.rst create mode 100644 docs/api/attune.interpolator.rst create mode 100644 docs/api/attune.rst create mode 100644 docs/api/attune.workup.rst create mode 100644 docs/api/modules.rst create mode 100644 docs/conf.py create mode 100644 docs/contributing.rst create mode 100644 docs/index.rst create mode 100644 docs/install.rst create mode 100644 docs/make.bat create mode 100644 examples/README.txt create mode 100644 examples/simple_curve.py diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..9ca6ee8 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,4 @@ +auto_examples/ +_build/ +gen_modules/ +modules/ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..1d93ff7 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = python3 -msphinx +SPHINXPROJ = WrightTools +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.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 + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/api/attune.curve.rst b/docs/api/attune.curve.rst new file mode 100644 index 0000000..79ff418 --- /dev/null +++ b/docs/api/attune.curve.rst @@ -0,0 +1,10 @@ +attune.curve package +==================== + +Module contents +--------------- + +.. automodule:: attune.curve + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/attune.interpolator.rst b/docs/api/attune.interpolator.rst new file mode 100644 index 0000000..f7b1bf0 --- /dev/null +++ b/docs/api/attune.interpolator.rst @@ -0,0 +1,10 @@ +attune.interpolator package +=========================== + +Module contents +--------------- + +.. automodule:: attune.interpolator + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/attune.rst b/docs/api/attune.rst new file mode 100644 index 0000000..95226b0 --- /dev/null +++ b/docs/api/attune.rst @@ -0,0 +1,19 @@ +attune package +============== + +Subpackages +----------- + +.. toctree:: + + attune.curve + attune.interpolator + attune.workup + +Module contents +--------------- + +.. automodule:: attune + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/attune.workup.rst b/docs/api/attune.workup.rst new file mode 100644 index 0000000..1afb0df --- /dev/null +++ b/docs/api/attune.workup.rst @@ -0,0 +1,10 @@ +attune.workup package +===================== + +Module contents +--------------- + +.. automodule:: attune.workup + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/modules.rst b/docs/api/modules.rst new file mode 100644 index 0000000..742ddb8 --- /dev/null +++ b/docs/api/modules.rst @@ -0,0 +1,7 @@ +attune +====== + +.. toctree:: + :maxdepth: 4 + + attune diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..7cdacfb --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,290 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# WrightTools documentation build configuration file, created by +# sphinx-quickstart on Tue Jul 18 13:01:20 2017. +# +# 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. + + +# --- import ------------------------------------------------------------------------------------- + + +import glob +import os +import sys +import sphinx_gallery +import math + + +# --- define ------------------------------------------------------------------------------------- + + +here = os.path.abspath(os.path.dirname(__file__)) + +with open(os.path.join(os.path.dirname(here), "attune", "VERSION")) as version_file: + version = version_file.read().strip() + + +# 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. + +sys.path.insert(0, os.path.abspath(".")) +sys.path.insert(0, os.path.abspath("../attune")) + + +# --- 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.doctest", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.mathjax", + "sphinx.ext.ifconfig", + "sphinx.ext.viewcode", + "matplotlib.sphinxext.plot_directive", + "sphinx_gallery.gen_gallery", + "sphinx.ext.napoleon", +] + +# ----------------------------------------------------------------------------- +# Autosummary +# ----------------------------------------------------------------------------- + +autosummary_generate = glob.glob("api/*.rst") + +# 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 = ".rst" + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = "attune" +copyright = "2016-2019, attune Developers" +author = "attune Developers" + +# 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 = version +# The full version, including alpha/beta/rc tags. +release = version + +# 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"] + +# 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 = True + + +# -- 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 = {} + +# HTML context adapted from http://docs.readthedocs.io/en/latest/vcs.html +html_context = { + "display_github": True, # Integrate GitHub + "github_user": "wright-group", # Username + "github_repo": "WrightTools", # Repo name + "github_version": "master", # Version + "conf_py_path": "/docs/", # Path in the checkout to the docs root +} + +# 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: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars +html_sidebars = { + "**": [ + "about.html", + "navigation.html", + "relations.html", # needs 'show_related': True theme option to display + "searchbox.html", + "donate.html", + ] +} + + +# --- Options for HTMLHelp output ---------------------------------------------------------------- + + +# Output file base name for HTML help builder. +htmlhelp_basename = "WrightToolsdoc" + + +# --- 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, + "WrightTools.tex", + "WrightTools Documentation", + "WrightTools Developers", + "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, "attune", "attune 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, + "attune", + "attune Documentation", + author, + "attune", + "One line description of project.", + "Miscellaneous", + ) +] + + +# --- gallery ------------------------------------------------------------------------------------ + + +def reset_wt(gallery_conf, fname): + # This is an awful hack because python does not allow unloading modules + # This is, however, the same thing upstream sphinx-gallery does for + # seaborn, so it's not _so_ bad I guess. 2019-04-07 KFS + for module in list(sys.modules.keys()): + if module.startswith("WrightTools.datasets"): + del sys.modules[module] + + +sphinx_gallery_conf = { + "examples_dirs": "../examples", + "filename_pattern": "/*.py", + "gallery_dirs": "auto_examples", + "download_section_examples": False, + "backreferences_dir": os.path.join("gen_modules", "backreferences"), + "reset_modules": ["matplotlib", reset_wt], +} + + +# --- plots -------------------------------------------------------------------------------------- + + +plot_pre_code = """ +import numpy as np +np.random.seed(0) +""" + +plot_include_source = True +plot_formats = [("png", 100), "pdf"] + +phi = (math.sqrt(5) + 1) / 2 + +plot_rcparams = { + "font.size": 8, + "axes.titlesize": 8, + "axes.labelsize": 8, + "xtick.labelsize": 8, + "ytick.labelsize": 8, + "legend.fontsize": 8, + "figure.figsize": (3 * phi, 3), + "figure.subplot.bottom": 0.2, + "figure.subplot.left": 0.2, + "figure.subplot.right": 0.9, + "figure.subplot.top": 0.85, + "figure.subplot.wspace": 0.4, + "text.usetex": False, +} + + +# --- intersphinx configuration ------------------------------------------------------------------ + + +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), + "scipy": ("https://docs.scipy.org/doc/scipy/reference", None), + "matplotlib": ("http://matplotlib.org", None), + "numpy": ("https://docs.scipy.org/doc/numpy/", None), +} diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..a5fbd78 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1,147 @@ +.. _contributing: + +Contributing +============ + +Thank you so much for contributing to ``attune``! +We really appreciate your help. + +If you have any questions at all, please either `open an issue on GitHub `_ or email a ``attune`` maintainer. The current maintainers can always be found in `CONTRIBUTORS `_. + +Preparing +--------- + +#. fork the `attune repository `_ (if you have push access to the main repository you can skip this step) +#. clone ``attune`` to your machine: + + .. code-block:: bash + + $ git clone + + +#. in the cloned directory (note, to install to system python, you may need to use ``sudo`` for this command): + + .. code-block:: bash + + $ pip install -e .[dev] + +#. run tests + + .. code-block:: bash + + $ python setup.py test + + +Contributing +------------ + +#. ensure that the changes you intend to make have corresponding `issues on GitHub `_ + a) if you aren't sure how to break your ideas into atomic issues, feel free to open a discussion issue + b) looking for low-hanging fruit? check out the `help wanted label `_ for beginner-friendly issues + + .. code-block:: bash + + $ # Create the branch, including remote + $ git branch --set-upstream-to origin origin/ + $ git checkout # Switch to the newly created branch + +#. run all tests to ensure that nothing is broken right off the start + + .. code-block:: bash + + $ python setup.py test + +#. make your changes, commiting often + + .. code-block:: bash + + $ git status # See which files you have changed/added + $ git diff # See changes since your last commit + $ git add + $ git commit -m "Description of changes" -m "More detail if needed" + +#. mark your issues as resolved (within your commit message): + + .. code-block:: bash + + $ git commit -m "added crazy colormap (resolves #99)" + + a. If your commit is related to an issue, but does not resolve it, use ``addresses #99`` in the commit message +#. if appropriate, add tests that address your changes (if you just fixed a bug, it is strongly reccomended that you add a test so that the bug cannot come back unanounced) +#. once you are done with your changes, run your code through flake8 and pydocstyle + + .. code-block:: bash + + $ flake8 file.py + $ pydocstyle file.py + +#. rerun tests +#. add yourself to `CONTRIBUTORS `_ +#. push your changes to the remote branch (github) + + .. code-block:: bash + + $ git pull # make sure your branch is up to date + $ git push + +#. make a pull request to the master branch +#. communicate with the maintainers in your pull request, assuming any further work needs to be done +#. celebrate! 🎉 + +Style +----- + +Internally we use the following abbreviations: + WrightTools + ``import WrightTools as wt`` + Matplotlib + ``import matplotlib as mpl`` + Pyplot + ``from matplotlib import pyplot as plt`` + NumPy + ``import numpy as np`` + +``attune`` follows `pep8 `_, with the following modifications: + +#. Maximum line length from 79 characters to 99 characters. + +``attune`` also folows `numpy Docstring Convention`_, which is a set of adjustments to `pep257`_. +``attune`` additionally ignores one guideline: + +#. ``attune`` does not require all magic methods (e.g. ``__add__``) to have a docstring. + + a) It remains encourged to add a docstring if there is any ambiguity of the meaning. + +.. _numpy docstring convention: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt +.. _pep257: https://www.python.org/dev/peps/pep-0257/ + +We use `flake8 `_ for automated code style enforcement, and `pydocstyle `_ for automated docstring style checking. + + +.. code-block:: bash + + $ # These will check the whole directory (recursively) + $ flake8 + $ pydocstyle + +Consider using `black `_ for automated code corrections. +Black is an opinionated code formatter for unambiguous standardization. + +.. code-block:: bash + + $ git commit -m "Describe changes" + $ black file.py + $ git diff # review changes + $ git add file.py + $ git commit -m "black style fixes" + +We also provide a configuration to use git hooks to automatically apply ``black`` style to edited files. +This hook can be installed using ``pre-commit``: + +.. code-block:: bash + + $ pre-commit install + +When committing, it will automatically apply the style, and prevent the commit from completing if changes are made. +If that is the case, simply re-add the changed files and then commit again. +This prevents noisy commit logs with changes that are purely style conformity. diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..030b967 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,52 @@ +``attune`` is a package for representing, generating, and updating tuning curves. + + +Status +------ + ++-------------------+-------------------+ +| **PyPI** | ++-------------------+-------------------+ ++ version | |pypi-version| | ++-------------------+-------------------+ +| **conda-forge** | ++-------------------+-------------------+ +| version | |conda-version| | ++-------------------+-------------------+ +| **Read the Docs** | ++-------------------+-------------------+ +| stable | |rtd-stable| | ++-------------------+-------------------+ +| latest | |rtd-latest| | ++-------------------+-------------------+ + +Contents +-------- + +.. toctree:: + :maxdepth: 2 + + install + contributing + api/modules + auto_examples/index + +Index +----- + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + + +.. |conda-version| image:: https://anaconda.org/conda-forge/attune/badges/version.svg + :target: https://anaconda.org/conda-forge/attune + +.. |pypi-version| image:: https://badge.fury.io/py/attune.svg + :target: https://badge.fury.io/py/attune + +.. |rtd-latest| image:: https://readthedocs.org/projects/attune/badge/?version=latest + :target: http://attune.readthedocs.io/en/latest/?badge=latest + +.. |rtd-stable| image:: https://readthedocs.org/projects/attune/badge/?version=stable + :target: http://attune.readthedocs.io/en/stable/?badge=stable diff --git a/docs/install.rst b/docs/install.rst new file mode 100644 index 0000000..b112bbd --- /dev/null +++ b/docs/install.rst @@ -0,0 +1,56 @@ +.. _install: + +.. note:: + This page contains information that is not (yet) true, as attune is not yet distributed. + However, it should be true once a release is made, which is hopefully soon. + + +Installation +============ + +``attune`` requires Python 3.6 or newer. + +conda-forge +----------- + +Conda_ is a multilingual package/environment manager. +It seamlessly handles non-Python library dependencies which many scientific Python tools rely upon. +Conda is recommended, especially for Windows users. +If you don't have Python yet, start by `installing Anaconda`_ or `miniconda`_. + +`conda-forge`_ is a community-driven conda channel. `conda-forge contains an attune feedstock`_. + +.. code-block:: bash + + conda config --add channels conda-forge + conda install attune + +To upgrade: + +.. code-block:: bash + + conda update attune + +pip +--- + +pip_ is Python's official package manager. `attune is hosted on PyPI`_. + + +.. code-block:: bash + + pip install attune + +To upgrade: + +.. code-block:: bash + + pip install attune --upgrade + +.. _Conda: https://conda.io/docs/intro.html +.. _installing Anaconda: https://www.continuum.io/downloads +.. _conda-forge: https://conda-forge.org/ +.. _conda-forge contains an attune feedstock: https://github.com/conda-forge/attune-feedstock +.. _miniconda: https://conda.io/miniconda.html +.. _pip: https://pypi.python.org/pypi/pip +.. _attune is hosted on PyPI: https://pypi.org/project/attune/ diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..535cf4b --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,36 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=python -msphinx +) +set SOURCEDIR=. +set BUILDDIR=_build +set SPHINXPROJ=WrightTools + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The Sphinx module was not found. Make sure you have Sphinx installed, + echo.then set the SPHINXBUILD environment variable to point to the full + echo.path of the 'sphinx-build' executable. Alternatively you may add the + echo.Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/examples/README.txt b/examples/README.txt new file mode 100644 index 0000000..f003ff6 --- /dev/null +++ b/examples/README.txt @@ -0,0 +1,4 @@ +.. _auto_examples-index: + +Gallery +======= diff --git a/examples/simple_curve.py b/examples/simple_curve.py new file mode 100644 index 0000000..8be71d9 --- /dev/null +++ b/examples/simple_curve.py @@ -0,0 +1,14 @@ +""" +Simple Curve Plot +================= +""" + +import attune +import numpy as np + +d0 = attune.Dependent(np.linspace(-5, 5, 20), "One Dependent") +d1 = attune.Dependent(np.sin(np.linspace(-4, 0, 20)), "Two Dependent") +s = attune.Setpoints(np.linspace(1300, 1400, 20), "Some Setpoints", "wn") +c = attune.Curve(s, [d0, d1], "Sample Curve") + +c.plot() From f9739444d97387901a3f5be784e9edbdf5657229 Mon Sep 17 00:00:00 2001 From: ksunden Date: Wed, 10 Apr 2019 23:28:10 -0500 Subject: [PATCH 3/3] Better api handling --- docs/api/.gitignore | 9 ++++++ docs/api/attune.curve.Curve.rst | 43 +++++++++++++++++++++++++++ docs/api/attune.curve.Setpoints.rst | 23 +++++++++++++++ docs/api/attune.curve.TopasCurve.rst | 44 ++++++++++++++++++++++++++++ docs/api/attune.curve.rst | 8 +++++ docs/api/attune.interpolator.rst | 11 +++++-- docs/api/attune.rst | 19 ------------ docs/api/attune.workup.rst | 9 ++++-- docs/api/modules.rst | 10 ++++--- docs/conf.py | 2 +- 10 files changed, 148 insertions(+), 30 deletions(-) create mode 100644 docs/api/.gitignore create mode 100644 docs/api/attune.curve.Curve.rst create mode 100644 docs/api/attune.curve.Setpoints.rst create mode 100644 docs/api/attune.curve.TopasCurve.rst delete mode 100644 docs/api/attune.rst diff --git a/docs/api/.gitignore b/docs/api/.gitignore new file mode 100644 index 0000000..2390429 --- /dev/null +++ b/docs/api/.gitignore @@ -0,0 +1,9 @@ +*.rst +!modules.rst +!attune.curve.rst +!attune.curve.Curve.rst +!attune.curve.Dependents.rst +!attune.curve.Setpoints.rst +!attune.curve.TopasCurve.rst +!attune.interpolator.rst +!attune.workup.rst diff --git a/docs/api/attune.curve.Curve.rst b/docs/api/attune.curve.Curve.rst new file mode 100644 index 0000000..5997e78 --- /dev/null +++ b/docs/api/attune.curve.Curve.rst @@ -0,0 +1,43 @@ +attune.curve.Curve +================== + +.. currentmodule:: attune.curve + +.. autoclass:: Curve + + + .. automethod:: __init__ + + + .. rubric:: Methods + + .. autosummary:: + + ~Curve.__init__ + ~Curve.coerce_dependents + ~Curve.convert + ~Curve.copy + ~Curve.get_dependent_positions + ~Curve.get_limits + ~Curve.get_source_setpoint + ~Curve.interpolate + ~Curve.map_setpoints + ~Curve.offset_by + ~Curve.offset_to + ~Curve.plot + ~Curve.read + ~Curve.save + ~Curve.sort + + + + + + .. rubric:: Attributes + + .. autosummary:: + + ~Curve.dependent_names + ~Curve.dependent_units + + \ No newline at end of file diff --git a/docs/api/attune.curve.Setpoints.rst b/docs/api/attune.curve.Setpoints.rst new file mode 100644 index 0000000..d3951dc --- /dev/null +++ b/docs/api/attune.curve.Setpoints.rst @@ -0,0 +1,23 @@ +attune.curve.Setpoints +====================== + +.. currentmodule:: attune.curve + +.. autoclass:: Setpoints + + + .. automethod:: __init__ + + + .. rubric:: Methods + + .. autosummary:: + + ~Setpoints.__init__ + ~Setpoints.convert + + + + + + \ No newline at end of file diff --git a/docs/api/attune.curve.TopasCurve.rst b/docs/api/attune.curve.TopasCurve.rst new file mode 100644 index 0000000..fe49ee1 --- /dev/null +++ b/docs/api/attune.curve.TopasCurve.rst @@ -0,0 +1,44 @@ +attune.curve.TopasCurve +======================= + +.. currentmodule:: attune.curve + +.. autoclass:: TopasCurve + + + .. automethod:: __init__ + + + .. rubric:: Methods + + .. autosummary:: + + ~TopasCurve.__init__ + ~TopasCurve.coerce_dependents + ~TopasCurve.convert + ~TopasCurve.copy + ~TopasCurve.get_dependent_positions + ~TopasCurve.get_limits + ~TopasCurve.get_source_setpoint + ~TopasCurve.interpolate + ~TopasCurve.map_setpoints + ~TopasCurve.offset_by + ~TopasCurve.offset_to + ~TopasCurve.plot + ~TopasCurve.read + ~TopasCurve.read_all + ~TopasCurve.save + ~TopasCurve.sort + + + + + + .. rubric:: Attributes + + .. autosummary:: + + ~TopasCurve.dependent_names + ~TopasCurve.dependent_units + + \ No newline at end of file diff --git a/docs/api/attune.curve.rst b/docs/api/attune.curve.rst index 79ff418..7a40949 100644 --- a/docs/api/attune.curve.rst +++ b/docs/api/attune.curve.rst @@ -8,3 +8,11 @@ Module contents :members: :undoc-members: :show-inheritance: + +.. autosummary:: + :toctree: ../api + + Curve + Dependent + Setpoints + TopasCurve diff --git a/docs/api/attune.interpolator.rst b/docs/api/attune.interpolator.rst index f7b1bf0..c6d926b 100644 --- a/docs/api/attune.interpolator.rst +++ b/docs/api/attune.interpolator.rst @@ -5,6 +5,11 @@ Module contents --------------- .. automodule:: attune.interpolator - :members: - :undoc-members: - :show-inheritance: + +.. autosummary:: + :toctree: ../api + + Interpolator + Linear + Poly + Spline diff --git a/docs/api/attune.rst b/docs/api/attune.rst deleted file mode 100644 index 95226b0..0000000 --- a/docs/api/attune.rst +++ /dev/null @@ -1,19 +0,0 @@ -attune package -============== - -Subpackages ------------ - -.. toctree:: - - attune.curve - attune.interpolator - attune.workup - -Module contents ---------------- - -.. automodule:: attune - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/api/attune.workup.rst b/docs/api/attune.workup.rst index 1afb0df..16c653c 100644 --- a/docs/api/attune.workup.rst +++ b/docs/api/attune.workup.rst @@ -5,6 +5,9 @@ Module contents --------------- .. automodule:: attune.workup - :members: - :undoc-members: - :show-inheritance: + +.. autosummary:: + :toctree: ../api + + intensity + tune_test diff --git a/docs/api/modules.rst b/docs/api/modules.rst index 742ddb8..67673b9 100644 --- a/docs/api/modules.rst +++ b/docs/api/modules.rst @@ -1,7 +1,9 @@ -attune -====== +attune API +========== .. toctree:: - :maxdepth: 4 + :maxdepth: 6 - attune + attune.curve + attune.interpolator + attune.workup diff --git a/docs/conf.py b/docs/conf.py index 7cdacfb..52a68b5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -86,7 +86,7 @@ # General information about the project. project = "attune" -copyright = "2016-2019, attune Developers" +copyright = "2018-2019, attune Developers" author = "attune Developers" # The version info for the project you're documenting, acts as replacement for