Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Commits that only reformat code, skipped by `git blame` and GitHub's blame view.
# Use locally with: git config blame.ignoreRevsFile .git-blame-ignore-revs

# Format code with ruff
f3fde52c38ffb0d84709b2184990f1d1dcb5c06f
23 changes: 21 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: 2026 Alexander Blech
# SPDX-License-Identifier: MPL-2.0

# Tests and docs build on every pull request, on pushes to main, and weekly.
# Lint, tests and docs build on every pull request, on pushes to main, and weekly.
# Dependencies are resolved fresh on each run, so a new library release can turn
# CI red with no change here. The weekly run is there to catch exactly that.

Expand All @@ -29,6 +29,25 @@ env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.13"
# prek installs the checks at the versions in .pre-commit-config.yaml.
- name: Install
run: |
python -m pip install --upgrade pip
python -m pip install --group lint
- name: Run checks
run: prek run --all-files --show-diff-on-failure

tests:
name: Tests (${{ matrix.os }}, Python ${{ matrix.python }})
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -82,7 +101,7 @@ jobs:
pass:
name: Pass
if: always()
needs: [tests, docs]
needs: [lint, tests, docs]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
Expand Down
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# OpenQuad - open database for multi-dimensional numerical integration
# SPDX-FileCopyrightText: 2026 Alexander Blech
# SPDX-License-Identifier: MPL-2.0

# Checks run before each commit after `prek install`, and in CI with
# `prek run --all-files`. Versions are pinned; `prek update` moves them forward.

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.2
hooks:
- id: ruff-check
- id: ruff-format

- repo: https://github.com/codespell-project/codespell
rev: v2.4.3
hooks:
- id: codespell

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.39.0
hooks:
- id: check-github-workflows

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.27
hooks:
- id: validate-pyproject
12 changes: 6 additions & 6 deletions doc/api/methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ The first entry denotes the input string for the method specification, cf. the
* ``Romberg``: `Romberg's method <https://en.wikipedia.org/wiki/Romberg's_method>`_, see :func:`scipy.integrate.romberg`
* ``1d-MonteCarlo``:`Monte Carlo integration <https://en.wikipedia.org/wiki/Monte_Carlo_integration>`_

These methods need the following additional keyword paramters:
These methods need the following additional keyword parameters:

* ``size``: float: Number of sampling points.
* ``degree``: float: Degree of exactness. For Gauss methods alternative to ``size``.
* ``a`` : float: Lower boundary of the integral.
* ``b`` : float: Upper boundary of the integral.
* ``jacobian`` : callable, optional: Jacobian to apply to the coordinate.
* ``periodic`` : logical, optinal: If ``True``, assume periodic boundary conditions.
* ``periodic`` : logical, optional: If ``True``, assume periodic boundary conditions.


:math:`\mathrm{S}^2` methods
Expand All @@ -41,10 +41,10 @@ These methods need the following additional keyword paramters:
* ``S2-Covering-ZCW``: near-uniform coverings with the `ZCW`_ method
* ``S2-MonteCarlo``: `Monte Carlo integration <https://en.wikipedia.org/wiki/Monte_Carlo_integration>`_

These methods need the following additional keyword paramters:
These methods need the following additional keyword parameters:

* ``size``: float: Number of sampling points.
* ``degree``: float: Degree of exactness. For Gauss methods and spherical desings alternative to ``size``.
* ``degree``: float: Degree of exactness. For Gauss methods and spherical designs alternative to ``size``.


:math:`\mathrm{SO}(3)` methods
Expand All @@ -55,7 +55,7 @@ These methods need the following additional keyword paramters:
* ``SO3-Covering-Karney``: near-uniform coverings from `Charles Karney`_
* ``SO3-MonteCarlo``: `Monte Carlo integration <https://en.wikipedia.org/wiki/Monte_Carlo_integration>`_

These methods need the following additional keyword paramters:
These methods need the following additional keyword parameters:

* ``size``: float: Number of sampling points.
* ``degree``: float: Degree of exactness. For Gauss and Chebyshev methods alternative to ``size``.
Expand All @@ -66,7 +66,7 @@ These methods need the following additional keyword paramters:
The following extensions are planned for the next release:

* Implementing the three-dimensional unit sphere, :math:`\mathrm{S}^3`.
* Adding spherical desings and coverings from `Neil Sloane and Ronald Hardin`_.
* Adding spherical designs and coverings from `Neil Sloane and Ronald Hardin`_.
* Providing a way to use :math:`\mathrm{S}^3` quadratures for :math:`\mathrm{SO}(3)`
and vice versa.
* Implementing a class for the unit circle, :math:`\mathrm{S}^1`.
Expand Down
48 changes: 24 additions & 24 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'OpenQuad'
copyright = '2024, OpenQuad developers'
author = 'Alexander Blech et al.'
project = "OpenQuad"
copyright = "2024, OpenQuad developers"
author = "Alexander Blech et al."
release = openquad.__version__

# -- General configuration ---------------------------------------------------
Expand All @@ -25,21 +25,19 @@
# nitpick_ignore = [("py:class", "callable")]

extensions = [
'autoapi.extension',
'sphinx.ext.intersphinx',
'sphinx.ext.doctest',
'sphinx_design',
'sphinx_copybutton',
'numpydoc',
"autoapi.extension",
"sphinx.ext.intersphinx",
"sphinx.ext.doctest",
"sphinx_design",
"sphinx_copybutton",
"numpydoc",
]

intersphinx_mapping = get_intersphinx_mapping(
packages={"python", "numpy", "scipy"}
)
#intersphinx_disabled_reftypes = ["*"]
intersphinx_mapping = get_intersphinx_mapping(packages={"python", "numpy", "scipy"})
# intersphinx_disabled_reftypes = ["*"]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# Will be included in the beginning of every RST file
rst_prolog = """
Expand All @@ -49,7 +47,7 @@
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'pydata_sphinx_theme'
html_theme = "pydata_sphinx_theme"

html_theme_options = {
"logo": {
Expand All @@ -76,22 +74,22 @@
"footer_center": ["sphinx-version"],
"navbar_end": [
"theme-switcher",
#"version-switcher",
# "version-switcher",
"navbar-icon-links",
],
"use_edit_page_button": False,
"navbar_align": "content",
#"show_version_warning_banner": True,
# "show_version_warning_banner": True,
"show_toc_level": 2,
"show_nav_level": 2, #TODO
"navigation_depth": 4, #TODO
#"collapse_navigation": True,
"announcement": "https://raw.githubusercontent.com/qucontrol/openquad/main/doc/_templates/announcement_banner.html"
"show_nav_level": 2, # TODO
"navigation_depth": 4, # TODO
# "collapse_navigation": True,
"announcement": "https://raw.githubusercontent.com/qucontrol/openquad/main/doc/_templates/announcement_banner.html",
}


html_static_path = ['_static']
html_css_files = ['openquad.css']
html_static_path = ["_static"]
html_css_files = ["openquad.css"]
html_copy_source = False
html_show_sourcelink = False

Expand All @@ -117,13 +115,15 @@
"inherited-members",
]


def skip_submodules(app, what, name, obj, skip, options):
if what == "module":
skip = True
elif what == "package" and name != "openquad":
skip = True
return skip


# -----------------------------------------------------------------------------
def setup(sphinx):
sphinx.connect("autoapi-skip-member", skip_submodules)
13 changes: 12 additions & 1 deletion doc/contributing/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ issues in commits.
.. _Linking a pull request to an issue: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue


Relases follow `semantic versioning`_ and need to be compatible with `PyPA
Releases follow `semantic versioning`_ and need to be compatible with `PyPA
version specifiers`_ (former `PEP440`_).

.. _semantic versioning: https://semver.org/
Expand All @@ -67,11 +67,22 @@ Code needs to be compatible with `PEP 8`_. It is formatted with `Ruff`_, which
follows the Black code style, with Ruff's default line length of 88
characters.

Formatting, linting, spelling and the project configuration are checked with
`prek`_, which is part of the development installation. The checks and their
versions are listed in ``.pre-commit-config.yaml``, and CI runs the same ones.
Run ``prek install`` once to check every commit before it is made, or run all
checks on demand:

.. code-block:: bash

prek run --all-files

Docstrings are written according to the `NumPy Style Guide`_, e.g. see this
`comprehensive example`_.

.. _PEP 8: https://peps.python.org/pep-0008/
.. _Ruff: https://docs.astral.sh/ruff/formatter/
.. _prek: https://prek.j178.dev/
.. _NumPy Style Guide: https://numpydoc.readthedocs.io/en/latest/format.html
.. _comprehensive example: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html

Expand Down
2 changes: 1 addition & 1 deletion doc/contributing/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _contributing:

Contributer guide
Contributor guide
=================

Contributions are very welcome! Whether you're reporting bugs, suggesting new
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OpenQuad documentation
User guide <using/index>
Tutorials <using/tutorials>
API reference <api/index>
Contributer guide <contributing/index>
Contributor guide <contributing/index>
.. Cite me <using/cite>

**Version**: |release|
Expand Down
2 changes: 1 addition & 1 deletion doc/using/howtos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
How-tos
-------

Recipies to achieve common tasks using |openquad|, targeted towards users familiar with the basic concepts.
Recipes to achieve common tasks using |openquad|, targeted towards users familiar with the basic concepts.

For detailed description of the classes and methods contained in |openquad|, see the :ref:`API reference <api>`.

Expand Down
2 changes: 1 addition & 1 deletion doc/using/intro_package.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ features.

Currently, the following geometries are implemented:

- :math:`n`-dimensional Euclidian spaces, :math:`\mathrm{R}^n`: :class:`openquad.Rn`
- :math:`n`-dimensional Euclidean spaces, :math:`\mathrm{R}^n`: :class:`openquad.Rn`
- the surface of the 2d unit sphere, :math:`\mathrm{S}^2`: :class:`openquad.S2`
- the space of all orientations in 3d-space, i.e., the rotation group
:math:`\mathrm{SO}(3)`: :class:`openquad.SO3`
Expand Down
2 changes: 1 addition & 1 deletion doc/using/intro_using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Sample points and weights
"""""""""""""""""""""""""

Sample points and weights are stored as NumPy arrays in :attr:`~openquad.S2.points` and
:attr:`~openquad.S2.weights`, respecitvely.
:attr:`~openquad.S2.weights`, respectively.

.. doctest::

Expand Down
62 changes: 62 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,65 @@ testpaths = ["tests"]
# Turn warnings into errors. Ignore a warning only with an explicit filter and a
# comment giving the reason.
filterwarnings = ["error"]

[tool.codespell]
# "Reson" abbreviates the journal J. Magn. Reson.
ignore-words-list = "reson"

[tool.ruff]
# The data tables are left as they are, as they will move out of the package.
# Code examples in Markdown keep their hand-written layout.
extend-exclude = ["src/openquad/data/", "*.md"]

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"F", # pyflakes
"W", # pycodestyle warnings
"I", # isort
"B", # flake8-bugbear
"UP", # pyupgrade
"C4", # flake8-comprehensions
"NPY", # NumPy-specific rules
"PT", # flake8-pytest-style
"PIE", # flake8-pie
"RET", # flake8-return
"RUF", # ruff-specific rules
"SIM", # flake8-simplify
"PTH", # flake8-use-pathlib
"PGH", # pygrep-hooks
"FURB", # refurb
]

[tool.ruff.lint.isort]
known-first-party = ["openquad"]

[tool.ruff.lint.per-file-ignores]
# Findings present when ruff was introduced, not fixed yet. Remove a code once the
# file is fixed or replaced. New files get the full rule set.
"doc/conf.py" = ["F401", "SIM114"]
"src/conftest.py" = ["I001"]
"src/openquad/__init__.py" = ["F401", "I001", "RUF022"]
"src/openquad/base.py" = [
"B006", "B024", "B904", "E722", "I001", "PIE790", "RET505", "SIM102", "SIM108",
]
"src/openquad/fibonacci.py" = ["I001", "RET506"]
"src/openquad/geometries.py" = [
"B006", "B007", "B905", "F541", "I001", "PIE790", "PT018", "RET503", "RET505",
"RET506", "RUF012", "SIM113", "SIM114", "W293",
]
"src/openquad/graef.py" = ["I001"]
"src/openquad/grid.py" = ["E501", "I001"]
"src/openquad/karney.py" = ["I001"]
"src/openquad/monte_carlo.py" = ["F821", "I001"]
"src/openquad/newton_cotes.py" = ["F401", "I001"]
"src/openquad/womersley.py" = ["I001", "SIM108"]
"tests/test_Rn_quadrature.py" = ["F841", "I001"]
"tests/test_S2_quadrature.py" = ["C408", "E501", "F841", "I001"]
"tests/test_SO3_quadrature.py" = ["C408", "E501", "F841", "I001"]
"tests/test_base.py" = ["F401", "I001", "SIM118"]
"tests/test_base_1d_quadrature_methods.py" = [
"E731", "F821", "F841", "I001", "PT006", "PT011",
]
"tests/test_base_2d_quadrature_methods.py" = ["F401", "F841", "I001", "PT006"]
"tests/test_base_3d_quadrature_methods.py" = ["E501", "F401", "F841", "I001", "PT006"]
3 changes: 2 additions & 1 deletion src/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
This file is automatically evaluated by pytest. It ensures that we can write
doctests without distracting import statements in the doctest.
"""

import pytest
import numpy as np


@pytest.fixture(autouse=True)
def set_doctest_env(doctest_namespace):
doctest_namespace['np'] = np
doctest_namespace["np"] = np
4 changes: 2 additions & 2 deletions src/openquad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# SPDX-FileCopyrightText: 2024 Alexander Blech
# SPDX-License-Identifier: MPL-2.0

__version__ = '0.3.0+dev'
__version__ = "0.3.0+dev"

# Expose top-level interface
from .geometries import Rn, S2, SO3

__all__ = ['Rn', 'S2', 'SO3']
__all__ = ["Rn", "S2", "SO3"]

# Expose submodules
from . import (
Expand Down
Loading
Loading