From 28cfd23d399c32f83f1e27be2dfbab26379cb961 Mon Sep 17 00:00:00 2001 From: Oliver Lemke Date: Mon, 28 Oct 2024 09:16:11 +0100 Subject: [PATCH 1/7] Tweak sphinx heading margins --- python/doc/source/_static/custom.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/python/doc/source/_static/custom.css b/python/doc/source/_static/custom.css index a5fac20a1d..6b42fc62b0 100644 --- a/python/doc/source/_static/custom.css +++ b/python/doc/source/_static/custom.css @@ -131,3 +131,16 @@ .wy-menu-vertical li.toctree-l2 a:hover button.toctree-expand, .wy-menu-vertical li.toctree-l3 a:hover button.toctree-expand, .wy-menu-vertical li.toctree-l4 a:hover button.toctree-expand, .wy-menu-vertical li.toctree-l5 a:hover button.toctree-expand, .wy-menu-vertical li.toctree-l6 a:hover button.toctree-expand, .wy-menu-vertical li.toctree-l7 a:hover button.toctree-expand, .wy-menu-vertical li.toctree-l8 a:hover button.toctree-expand, .wy-menu-vertical li.toctree-l9 a:hover button.toctree-expand, .wy-menu-vertical li.toctree-l10 a:hover button.toctree-expand { color: rgb(64, 64, 64); } + +div.nbinput.container, div.nboutput.container { + margin-bottom: 24px; +} + +.rst-content .toctree-wrapper>p.caption, h1, h2, h3, h4, h5, h6, legend { + margin-top: 24px; +} + +.rst-content .toctree-wrapper > p.caption, .rst-content h1, .rst-content h2, .rst-content h3, .rst-content h4, .rst-content h5, .rst-content h6 { + margin-bottom:12px; +} + From f5f56539ca14b12b58b16536991964181a72fd4a Mon Sep 17 00:00:00 2001 From: Oliver Lemke Date: Mon, 28 Oct 2024 13:46:45 +0100 Subject: [PATCH 2/7] Improve API sphinx layout --- python/doc/source/pyarts.rst | 37 ++++++++++++++++++++++++++++++++ python/src/pyarts/__init__.py.in | 11 ++++------ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/python/doc/source/pyarts.rst b/python/doc/source/pyarts.rst index 6e8e50ecd7..0143a0bd8e 100644 --- a/python/doc/source/pyarts.rst +++ b/python/doc/source/pyarts.rst @@ -3,6 +3,7 @@ API Reference .. toctree:: :maxdepth: 2 + :hidden: pyarts.arts pyarts.cat @@ -15,3 +16,39 @@ API Reference pyarts.utils pyarts.workspace pyarts.xml + + +.. rubric:: Modules + +.. autosummary:: + + pyarts.arts + pyarts.cat + pyarts.data + pyarts.environment + pyarts.hitran + pyarts.plots + pyarts.recipe + pyarts.sensor + pyarts.utils + pyarts.workspace + pyarts.xml + + +.. rubric:: Classes + +.. list-table:: + + * - :class:`~pyarts.workspace.Workspace` + - The ARTS workspace. + + +.. rubric:: Decorators + +.. list-table:: + + * - :class:`~pyarts.workspace.arts_agenda` + - Decorator for creating ARTS agendas. + * - :class:`~pyarts.workspace.callback_operator` + - Callback operator decorator. + diff --git a/python/src/pyarts/__init__.py.in b/python/src/pyarts/__init__.py.in index fa76239085..7956a61c5b 100644 --- a/python/src/pyarts/__init__.py.in +++ b/python/src/pyarts/__init__.py.in @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- - -"""This module contains functions to interact with ARTS. -""" +"""This module contains functions to interact with ARTS.""" from pyarts import sensor # noqa from pyarts import xml # noqa @@ -13,10 +11,9 @@ from pyarts import hitran # noqa from pyarts import cat # noqa from pyarts import fields # noqa from pyarts import recipe # noqa +from pyarts.workspace import Workspace, arts_agenda # noqa +from pyarts.workspace.callback import callback_operator # noqa -__all__ = [s for s in dir() if not s.startswith('_')] +__all__ = [s for s in dir() if not s.startswith("_")] __version__ = "@ARTS_VERSION@" version = __version__ - -# Name the workspace -Workspace = workspace.Workspace From 3152bd19e84f55c4827d147f1783aac94998a45d Mon Sep 17 00:00:00 2001 From: Oliver Lemke Date: Tue, 29 Oct 2024 08:10:04 +0100 Subject: [PATCH 3/7] Add discussions link to contact page Emphasize to use Github instead of mailing lists. --- python/doc/source/contact.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/doc/source/contact.rst b/python/doc/source/contact.rst index 490e33a8d2..106ea0768f 100644 --- a/python/doc/source/contact.rst +++ b/python/doc/source/contact.rst @@ -4,6 +4,11 @@ Contact GitHub ------ * `Submit a bug report `_ +* `Discussions on GitHub `_ + +.. note:: + Please use the Github issue tracker for bug reports and the discussions section for questions and comments if possible. + Only use the mailing lists if you're unable to use the GitHub website. User email list --------------- From 7635849f52a41fac4609b1f158755629a260111d Mon Sep 17 00:00:00 2001 From: Oliver Lemke Date: Tue, 29 Oct 2024 08:11:46 +0100 Subject: [PATCH 4/7] Add callback_operator to docs --- python/doc/source/pyarts.workspace.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/doc/source/pyarts.workspace.rst b/python/doc/source/pyarts.workspace.rst index 85989544a6..4932c6db52 100644 --- a/python/doc/source/pyarts.workspace.rst +++ b/python/doc/source/pyarts.workspace.rst @@ -12,12 +12,13 @@ pyarts.workspace pyarts.workspace.Workspace -.. rubric:: Creating an agenda +.. rubric:: Decorators .. autosummary:: :toctree: stubs arts_agenda + callback_operator pyarts.workspace.utility ------------------------ From 93ead821805426ff3fd53a9b0c776ac2e80a24e2 Mon Sep 17 00:00:00 2001 From: Oliver Lemke Date: Tue, 29 Oct 2024 08:11:57 +0100 Subject: [PATCH 5/7] Update arts module docstring --- src/python_interface/py_module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_interface/py_module.cpp b/src/python_interface/py_module.cpp index a0ed182f83..0d3e0d74a9 100644 --- a/src/python_interface/py_module.cpp +++ b/src/python_interface/py_module.cpp @@ -65,7 +65,7 @@ void py_retrieval(py::module_& m); * 3) Implicit conversion can only be defined between two python-defined Arts types */ NB_MODULE(arts, m) try { - m.doc() = "Interface directly to the C++ types via python"; + m.doc() = "Interface directly to the C++ types, functions and modules via python"; py::class_ ws(m, "CxxWorkspace"); static bool init = true; From ac54fa03317fc0d3eba598f2c37e9073616e1716 Mon Sep 17 00:00:00 2001 From: Oliver Lemke Date: Tue, 29 Oct 2024 08:43:28 +0100 Subject: [PATCH 6/7] Remove sensor and environment module --- python/doc/source/conf.py | 2 - python/doc/source/pyarts.rst | 4 -- python/src/pyarts/__init__.py.in | 1 - python/src/pyarts/environment.py | 69 ----------------------------- python/src/pyarts/sensor.py | 76 -------------------------------- 5 files changed, 152 deletions(-) delete mode 100644 python/src/pyarts/environment.py delete mode 100644 python/src/pyarts/sensor.py diff --git a/python/doc/source/conf.py b/python/doc/source/conf.py index 1867c6ce21..45e35788bc 100644 --- a/python/doc/source/conf.py +++ b/python/doc/source/conf.py @@ -21,8 +21,6 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath(os.path.join('..', '..', 'src'))) -from pyarts.environment import environ - # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. diff --git a/python/doc/source/pyarts.rst b/python/doc/source/pyarts.rst index 0143a0bd8e..8ab43c0ba3 100644 --- a/python/doc/source/pyarts.rst +++ b/python/doc/source/pyarts.rst @@ -8,11 +8,9 @@ API Reference pyarts.arts pyarts.cat pyarts.data - pyarts.environment pyarts.hitran pyarts.plots pyarts.recipe - pyarts.sensor pyarts.utils pyarts.workspace pyarts.xml @@ -25,11 +23,9 @@ API Reference pyarts.arts pyarts.cat pyarts.data - pyarts.environment pyarts.hitran pyarts.plots pyarts.recipe - pyarts.sensor pyarts.utils pyarts.workspace pyarts.xml diff --git a/python/src/pyarts/__init__.py.in b/python/src/pyarts/__init__.py.in index 7956a61c5b..877d63a308 100644 --- a/python/src/pyarts/__init__.py.in +++ b/python/src/pyarts/__init__.py.in @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """This module contains functions to interact with ARTS.""" -from pyarts import sensor # noqa from pyarts import xml # noqa from pyarts import arts # noqa from pyarts import data # noqa diff --git a/python/src/pyarts/environment.py b/python/src/pyarts/environment.py deleted file mode 100644 index 19825f8565..0000000000 --- a/python/src/pyarts/environment.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- -"""Handling of environment variables. - -Implements a mapping object for environment variables. - -The handler is used like ``os.environ``: - ->>> environ['ARTS_DATA_PATH'] -'path/to/data' ->>> environ.get('ARTS_DATA_PATH') -'path/to/data' - -In addition to the user's environment, variables can be set in the in the -configuration file (:mod:`config`) in the ``environment`` section:: - - [environment] - ARTS_BUILD_PATH: /path/to/arts/build/ - -Note: - If the environment variable is set explicitly, the value set in - the configuration file is ignored. -""" -import os - - -__all__ = [ - 'environ', -] - - -class _EnvironmentHandler: - """A mapping object for environment variables. - - See module docstring of :mod:`environment` for more information. - """ - def __getitem__(self, key): - try: - # First, try to return the value from the user's environment... - return os.environ[key] - except : - # TODO: Error handling. - pass - - def __setitem__(self, key, value): - # If an environment variable is set, pass it to the actual user's - # environment. This ensures consistent environments for subprocesses. - os.environ[key] = value - - def __contains__(self, item): - """Implement membership test operators. - - Returns: - `True` if item is in self, `False` otherwise. - """ - try: - self[item] - return True - except KeyError: - return False - - def get(self, key, default=None): - """D.get(k[, d]) -> D[k] if k in D, else d.d defaults to None.""" - # Try to return the value from the user's environment. - # If the key is not set, try to find it in the config. - # If this also fails, return a default value. - return os.environ.get(key) - - -environ = _EnvironmentHandler() diff --git a/python/src/pyarts/sensor.py b/python/src/pyarts/sensor.py deleted file mode 100644 index d7b788d671..0000000000 --- a/python/src/pyarts/sensor.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Implementation of functions related to sensor settings. - -""" - -import numpy as np - - -__all__ = ['get_f_backend_rel_width', - 'get_f_backend_const_width', - ] - - -def get_f_backend_rel_width(f_start, f_end, bandwidth): - """Compute backend frequencies with relative bandwidth. - - This function computes backend frequencies for a given frequency range and - a relative bandwidth. - - Parameters: - f_start (float): beginning of frequency range [Hz] - f_end (float): end of frequency range [Hz] - bandwidth (float): relative bandwidth [dimensionless] - - Return: - np.array, np.array: backend frequencies [Hz], channel widths [Hz] - - """ - if f_start <= 0: - raise Exception('Start frequency must be > 0.') - - if f_start > f_end: - raise Exception('End frequency has to be larger than start frequency.') - - f_backend = [f_start] - while f_backend[-1] <= f_end: - f_backend.append(f_backend[-1] * (bandwidth + 2) / (2 - bandwidth)) - - # do not include last value in results as it exceeds f_end - f_backend = np.array(f_backend[:-1]) - backend_bandwidth = f_backend * bandwidth - - return f_backend, backend_bandwidth - - -def get_f_backend_const_width(f_start, f_end, bandwidth): - """Compute backend frequencies with constant bandwidth. - - This function computes backend frequencies for a given frequency range and - a constant bandwidth. - - Parameters: - f_start (float): beginning of frequency range [Hz] - f_end (float): end of frequency range [Hz] - bandwidth (float): bandwidth [Hz] - - Return: - np.array, np.array: backend frequencies [Hz], channel widths [Hz] - - """ - if f_start <= 0: - raise Exception('Start frequency must be > 0.') - - if f_start > f_end: - raise Exception('End frequency has to be larger than start frequency.') - - f_backend = [f_start] - while f_backend[-1] <= f_end: - f_backend.append(f_backend[-1] + bandwidth) - - # do not include last value in results as it exceeds f_end - f_backend = np.array(f_backend[:-1]) - backend_bandwidth = np.array([bandwidth]) - - return f_backend, backend_bandwidth From 5affaeddbd349a4162e79e6a86d72db499366454 Mon Sep 17 00:00:00 2001 From: Oliver Lemke Date: Tue, 29 Oct 2024 08:49:59 +0100 Subject: [PATCH 7/7] Add indices to toctree --- python/doc/source/indices.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/doc/source/indices.rst b/python/doc/source/indices.rst index 1e489394d3..9c94de21a9 100644 --- a/python/doc/source/indices.rst +++ b/python/doc/source/indices.rst @@ -4,3 +4,8 @@ Indices * :ref:`genindex` * :ref:`modindex` +.. toctree:: + :hidden: + + genindex + modindex