From 24cd866c985e67ab1278855122eab763a84f6ebf Mon Sep 17 00:00:00 2001 From: bcarreres Date: Fri, 3 Nov 2023 14:28:33 -0400 Subject: [PATCH] Test docs --- .readthedocs.yaml | 12 ++++ .vscode/settings.json | 3 + docs/api.rst | 17 +++++ docs/api/flip.covariance.rst | 23 +++++++ docs/basicusage.rst | 2 + docs/conf.py | 128 +++++++++++++++++++++++++++++++++++ docs/index.rst | 24 +++++++ docs/installation.rst | 10 +++ flip/__init__.py | 7 +- flip/model_evaluation.py | 1 - requirements.txt | 1 + setup.cfg | 25 ++++--- 12 files changed, 241 insertions(+), 12 deletions(-) create mode 100644 .readthedocs.yaml create mode 100644 .vscode/settings.json create mode 100644 docs/api.rst create mode 100644 docs/api/flip.covariance.rst create mode 100644 docs/basicusage.rst create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/installation.rst create mode 100644 requirements.txt diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..30ebad0 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,12 @@ +version: 2 + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/conf.py + +# Optionally set the version of Python and requirements required to build your docs +python: + version: "3.9" + install: + - method: pip + path: .[docs] \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..73dc9f3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "restructuredtext.preview.name": "docutils" +} \ No newline at end of file diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 0000000..3450f76 --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,17 @@ +API +==== + +.. currentmodule:: flip + +.. autosummary:: + :toctree: generated + :recursive: + + flip.covariance + flip.likelihood + flip.fitter + flip.gridding + flip.model_evaluation + flip.power_spectra + flip.utils + diff --git a/docs/api/flip.covariance.rst b/docs/api/flip.covariance.rst new file mode 100644 index 0000000..f2c0d1d --- /dev/null +++ b/docs/api/flip.covariance.rst @@ -0,0 +1,23 @@ +flip.covariance +=============== + +.. automodule:: flip.covariance + + + + + + + + + + + + + + + + + + + diff --git a/docs/basicusage.rst b/docs/basicusage.rst new file mode 100644 index 0000000..a13831d --- /dev/null +++ b/docs/basicusage.rst @@ -0,0 +1,2 @@ +Getting started +=============== diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..393c955 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,128 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# 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('.')) + + +# -- Project information ----------------------------------------------------- +import sys +import os +import numpy +sys.path.insert(0, os.path.abspath('..')) +import flip + +project = 'flip' +copyright = '2023, C. Ravoux' +author = 'C. Ravoux, B. Carreres' + +# The full version, including alpha/beta/rc tags +release = flip.__version__ + +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), + 'sncosmo': ('https://sncosmo.readthedocs.io/en/stable/', None), + 'pandas': ('https://pandas.pydata.org/docs/', None)} + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. + +extensions = ['myst_parser', 'sphinx.ext.napoleon', 'sphinx_markdown_tables', 'sphinx.ext.autosectionlabel', + 'sphinx.ext.linkcode', 'sphinx.ext.intersphinx', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary'] + +napoleon_google_docstring = True +myst_enable_extensions = ["dollarmath"] +myst_dmath_double_inline = True + +autosectionlabel_prefix_document = True +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + +source_suffix = { + '.rst': 'restructuredtext', + '.txt': 'markdown', + '.md': 'markdown', +} +# -- 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 = "furo" + +# 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'] + +html_logo = "" + +html_theme_options = { + "sidebar_hide_name": True, + } + +import inspect +from os.path import relpath + + +# Copied on sncosmo documentation +def linkcode_resolve(domain, info): + """Determine the URL corresponding to Python object.""" + if domain != 'py': + return None + + modname = info['module'] + fullname = info['fullname'] + + submod = sys.modules.get(modname) + if submod is None: + return None + + obj = submod + for part in fullname.split('.'): + try: + obj = getattr(obj, part) + except: + return None + + try: + fn = inspect.getsourcefile(obj) + except: + fn = None + if not fn: + return None + + try: + source, lineno = inspect.findsource(obj) + except: + lineno = None + + if lineno: + linespec = "#L%d" % (lineno + 1) + else: + linespec = "" + + fn = relpath(fn, start=flip.__flip_dir_path__) + + return "https://github.com/corentinravoux/flip/tree/main/%s%s" % (fn, linespec) \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..adc5a6a --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,24 @@ + +Welcome to flip's documentation! +================================= + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + installation.rst + basicusage.rst + +.. toctree:: + :hidden: + :titlesonly: + + api + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` \ No newline at end of file diff --git a/docs/installation.rst b/docs/installation.rst new file mode 100644 index 0000000..cf8d486 --- /dev/null +++ b/docs/installation.rst @@ -0,0 +1,10 @@ +Installation +============ + +Clone the repository from github and install using pip. + +.. code:: bash + + git clone https://github.com/corentinravoux/flip.git + cd flip + pip install . diff --git a/flip/__init__.py b/flip/__init__.py index 643a316..5086a2f 100644 --- a/flip/__init__.py +++ b/flip/__init__.py @@ -1,4 +1,9 @@ """Init file of the flip package.""" -from . import covariance +from . import covariance +from . import fitter +from . import gridding +from . import likelihood +from . import model_evaluation +from . import utils __version__ = "1.0.0" \ No newline at end of file diff --git a/flip/model_evaluation.py b/flip/model_evaluation.py index 69d55ee..41e72ac 100644 --- a/flip/model_evaluation.py +++ b/flip/model_evaluation.py @@ -1,5 +1,4 @@ import numpy as np -from fitfs8 import grid_utils, joint_cov import itertools import matplotlib.pyplot as plt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ecf975e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +-e . \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 46be03f..362702a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,16 +6,6 @@ email = corentin.ravoux.research@gmail.com author = Corentin Ravoux long_description = file : README.md license = MIT -classifiers = - # Trove classifiers - # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers - License :: OSI Approved :: MIT License - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy [options] @@ -26,3 +16,18 @@ install_requires = scipy matplotlib importlib-metadata + cosmoprimo @ git+https://github.com/cosmodesi/cosmoprimo + + +[options.extras_require] +docs = + markdown + sphinx >= 5.2.3 + sphinx-markdown-tables >= 0.0.15 + numpydoc + furo + myst-parser + sphinx-copybutton + sphinx-design + sphinx-inline-tabs + sphinx-tabs \ No newline at end of file