aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/Makefile20
-rw-r--r--docs/conf.py31
-rw-r--r--docs/discussions.rst2
-rw-r--r--docs/howto.rst2
-rw-r--r--docs/index.rst19
-rw-r--r--docs/make.bat35
-rw-r--r--docs/reference.rst83
-rw-r--r--docs/tutorials.rst40
-rw-r--r--poetry.lock174
-rw-r--r--pyproject.toml4
10 files changed, 409 insertions, 1 deletions
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..d4bb2cb
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,20 @@
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line, and also
+# from the environment for the first two.
+SPHINXOPTS ?=
+SPHINXBUILD ?= sphinx-build
+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/conf.py b/docs/conf.py
new file mode 100644
index 0000000..1cc81ba
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,31 @@
+# Configuration file for the Sphinx documentation builder.
+#
+# For the full list of built-in configuration values, see the documentation:
+# https://www.sphinx-doc.org/en/master/usage/configuration.html
+
+# -- Project information -----------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
+
+import os
+import sys
+sys.path.insert(0, os.path.abspath('..'))
+
+project = 'mdpoly'
+copyright = '2024, Naoki Sean Pross <np@0hm.ch>'
+author = 'Naoki Sean Pross <npross@ethz.ch>'
+release = '0.1.0'
+
+# -- General configuration ---------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
+
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary']
+autosummary_generate = True
+
+templates_path = ['_templates']
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+
+# -- Options for HTML output -------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
+
+html_theme = 'alabaster'
+html_static_path = ['_static']
diff --git a/docs/discussions.rst b/docs/discussions.rst
new file mode 100644
index 0000000..87c895a
--- /dev/null
+++ b/docs/discussions.rst
@@ -0,0 +1,2 @@
+Discussions
+===========
diff --git a/docs/howto.rst b/docs/howto.rst
new file mode 100644
index 0000000..e7452d2
--- /dev/null
+++ b/docs/howto.rst
@@ -0,0 +1,2 @@
+How-To Guides
+=============
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..71bf8c6
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,19 @@
+
+Multidimensional Polynomials
+============================
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+
+ tutorials
+ howto
+ discussions
+ reference
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/docs/make.bat b/docs/make.bat
new file mode 100644
index 0000000..32bb245
--- /dev/null
+++ b/docs/make.bat
@@ -0,0 +1,35 @@
+@ECHO OFF
+
+pushd %~dp0
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set SOURCEDIR=.
+set BUILDDIR=_build
+
+%SPHINXBUILD% >NUL 2>NUL
+if errorlevel 9009 (
+ echo.
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+ echo.installed, then set the SPHINXBUILD environment variable to point
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
+ echo.may add the Sphinx directory to PATH.
+ echo.
+ echo.If you don't have Sphinx installed, grab it from
+ echo.https://www.sphinx-doc.org/
+ exit /b 1
+)
+
+if "%1" == "" goto help
+
+%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
+goto end
+
+:help
+%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
+
+:end
+popd
diff --git a/docs/reference.rst b/docs/reference.rst
new file mode 100644
index 0000000..89f5bfb
--- /dev/null
+++ b/docs/reference.rst
@@ -0,0 +1,83 @@
+Package Reference
+=================
+
+Module contents
+---------------
+
+.. automodule:: mdpoly
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+
+mdpoly.abc
+----------
+
+.. automodule:: mdpoly.abc
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.algebra
+--------------
+
+.. automodule:: mdpoly.algebra
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.constants
+----------------
+
+.. automodule:: mdpoly.constants
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.errors
+-------------
+
+.. automodule:: mdpoly.errors
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.leaves
+-------------
+
+.. automodule:: mdpoly.leaves
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.representations
+----------------------
+
+.. automodule:: mdpoly.representations
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.state
+------------
+
+.. automodule:: mdpoly.state
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.types
+------------
+
+.. automodule:: mdpoly.types
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.util
+-----------
+
+.. automodule:: mdpoly.util
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/tutorials.rst b/docs/tutorials.rst
new file mode 100644
index 0000000..a2e1b20
--- /dev/null
+++ b/docs/tutorials.rst
@@ -0,0 +1,40 @@
+Tutorials
+=========
+
+Quickstart
+----------
+
+For the impatient, here is a very quick overview.
+
+.. code:: py
+
+ from mdpoly import State, Variable, Parameter
+ from mdpoly.representations import SparseRepr
+
+ # Construct an expression
+ x, y = Variable.from_names("x, y") # or just Variable("x")
+ k = Parameter("k")
+
+ p = (x + 2 * y) ** 3 + y ** 2 + k
+ print(f"{p = }")
+
+ # Make a concrete representation
+ state = State(parameters={k: 3.14}) # try to replace with empty dict
+ sparse, state = p.to_repr(SparseRepr, state)
+
+ # Look inside the representation
+ for entry in sparse.entries():
+ print(f"at (row, col) = {entry.row, entry.col} there is a polynomial:")
+ for term in sparse.terms(entry):
+ monomial_str = ""
+ for idx in term:
+ var = state.from_index(idx.var_idx)
+ monomial_str += f"{var.name}^{idx.power} "
+
+ # Get the coefficient
+ coeff = sparse.at(entry, term)
+ print(" - the monomial", monomial_str, "has coefficient", coeff)
+
+ # You can also simply iterate over it
+ for entry, term, coeff in sparse:
+ print(entry, term, coeff)
diff --git a/poetry.lock b/poetry.lock
index ee24ab9..4f0c9ce 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,6 +1,17 @@
# This file is automatically @generated by Poetry 1.5.0 and should not be changed by hand.
[[package]]
+name = "alabaster"
+version = "0.7.16"
+description = "A light, configurable Sphinx theme"
+optional = false
+python-versions = ">=3.9"
+files = [
+ {file = "alabaster-0.7.16-py3-none-any.whl", hash = "sha256:b46733c07dce03ae4e150330b975c75737fa60f0a7c591b6c8bf4928a28e2c92"},
+ {file = "alabaster-0.7.16.tar.gz", hash = "sha256:75a8b99c28a5dad50dd7f8ccdd447a121ddb3892da9e53d1ca5cca3106d58d65"},
+]
+
+[[package]]
name = "anyio"
version = "4.3.0"
description = "High level compatibility layer for multiple asynchronous event loop implementations"
@@ -469,6 +480,17 @@ files = [
]
[[package]]
+name = "docutils"
+version = "0.20.1"
+description = "Docutils -- Python Documentation Utilities"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "docutils-0.20.1-py3-none-any.whl", hash = "sha256:96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6"},
+ {file = "docutils-0.20.1.tar.gz", hash = "sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b"},
+]
+
+[[package]]
name = "exceptiongroup"
version = "1.2.0"
description = "Backport of PEP 654 (exception groups)"
@@ -589,6 +611,17 @@ files = [
]
[[package]]
+name = "imagesize"
+version = "1.4.1"
+description = "Getting image size from png/jpeg/jpeg2000/gif file"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+files = [
+ {file = "imagesize-1.4.1-py2.py3-none-any.whl", hash = "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b"},
+ {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"},
+]
+
+[[package]]
name = "ipykernel"
version = "6.29.3"
description = "IPython Kernel for Jupyter"
@@ -1909,6 +1942,17 @@ files = [
]
[[package]]
+name = "snowballstemmer"
+version = "2.2.0"
+description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms."
+optional = false
+python-versions = "*"
+files = [
+ {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"},
+ {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"},
+]
+
+[[package]]
name = "soupsieve"
version = "2.5"
description = "A modern CSS selector implementation for Beautiful Soup."
@@ -1920,6 +1964,134 @@ files = [
]
[[package]]
+name = "sphinx"
+version = "7.2.6"
+description = "Python documentation generator"
+optional = false
+python-versions = ">=3.9"
+files = [
+ {file = "sphinx-7.2.6-py3-none-any.whl", hash = "sha256:1e09160a40b956dc623c910118fa636da93bd3ca0b9876a7b3df90f07d691560"},
+ {file = "sphinx-7.2.6.tar.gz", hash = "sha256:9a5160e1ea90688d5963ba09a2dcd8bdd526620edbb65c328728f1b2228d5ab5"},
+]
+
+[package.dependencies]
+alabaster = ">=0.7,<0.8"
+babel = ">=2.9"
+colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""}
+docutils = ">=0.18.1,<0.21"
+imagesize = ">=1.3"
+Jinja2 = ">=3.0"
+packaging = ">=21.0"
+Pygments = ">=2.14"
+requests = ">=2.25.0"
+snowballstemmer = ">=2.0"
+sphinxcontrib-applehelp = "*"
+sphinxcontrib-devhelp = "*"
+sphinxcontrib-htmlhelp = ">=2.0.0"
+sphinxcontrib-jsmath = "*"
+sphinxcontrib-qthelp = "*"
+sphinxcontrib-serializinghtml = ">=1.1.9"
+
+[package.extras]
+docs = ["sphinxcontrib-websupport"]
+lint = ["docutils-stubs", "flake8 (>=3.5.0)", "flake8-simplify", "isort", "mypy (>=0.990)", "ruff", "sphinx-lint", "types-requests"]
+test = ["cython (>=3.0)", "filelock", "html5lib", "pytest (>=4.6)", "setuptools (>=67.0)"]
+
+[[package]]
+name = "sphinxcontrib-applehelp"
+version = "1.0.8"
+description = "sphinxcontrib-applehelp is a Sphinx extension which outputs Apple help books"
+optional = false
+python-versions = ">=3.9"
+files = [
+ {file = "sphinxcontrib_applehelp-1.0.8-py3-none-any.whl", hash = "sha256:cb61eb0ec1b61f349e5cc36b2028e9e7ca765be05e49641c97241274753067b4"},
+ {file = "sphinxcontrib_applehelp-1.0.8.tar.gz", hash = "sha256:c40a4f96f3776c4393d933412053962fac2b84f4c99a7982ba42e09576a70619"},
+]
+
+[package.extras]
+lint = ["docutils-stubs", "flake8", "mypy"]
+standalone = ["Sphinx (>=5)"]
+test = ["pytest"]
+
+[[package]]
+name = "sphinxcontrib-devhelp"
+version = "1.0.6"
+description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp documents"
+optional = false
+python-versions = ">=3.9"
+files = [
+ {file = "sphinxcontrib_devhelp-1.0.6-py3-none-any.whl", hash = "sha256:6485d09629944511c893fa11355bda18b742b83a2b181f9a009f7e500595c90f"},
+ {file = "sphinxcontrib_devhelp-1.0.6.tar.gz", hash = "sha256:9893fd3f90506bc4b97bdb977ceb8fbd823989f4316b28c3841ec128544372d3"},
+]
+
+[package.extras]
+lint = ["docutils-stubs", "flake8", "mypy"]
+standalone = ["Sphinx (>=5)"]
+test = ["pytest"]
+
+[[package]]
+name = "sphinxcontrib-htmlhelp"
+version = "2.0.5"
+description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files"
+optional = false
+python-versions = ">=3.9"
+files = [
+ {file = "sphinxcontrib_htmlhelp-2.0.5-py3-none-any.whl", hash = "sha256:393f04f112b4d2f53d93448d4bce35842f62b307ccdc549ec1585e950bc35e04"},
+ {file = "sphinxcontrib_htmlhelp-2.0.5.tar.gz", hash = "sha256:0dc87637d5de53dd5eec3a6a01753b1ccf99494bd756aafecd74b4fa9e729015"},
+]
+
+[package.extras]
+lint = ["docutils-stubs", "flake8", "mypy"]
+standalone = ["Sphinx (>=5)"]
+test = ["html5lib", "pytest"]
+
+[[package]]
+name = "sphinxcontrib-jsmath"
+version = "1.0.1"
+description = "A sphinx extension which renders display math in HTML via JavaScript"
+optional = false
+python-versions = ">=3.5"
+files = [
+ {file = "sphinxcontrib-jsmath-1.0.1.tar.gz", hash = "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8"},
+ {file = "sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl", hash = "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178"},
+]
+
+[package.extras]
+test = ["flake8", "mypy", "pytest"]
+
+[[package]]
+name = "sphinxcontrib-qthelp"
+version = "1.0.7"
+description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp documents"
+optional = false
+python-versions = ">=3.9"
+files = [
+ {file = "sphinxcontrib_qthelp-1.0.7-py3-none-any.whl", hash = "sha256:e2ae3b5c492d58fcbd73281fbd27e34b8393ec34a073c792642cd8e529288182"},
+ {file = "sphinxcontrib_qthelp-1.0.7.tar.gz", hash = "sha256:053dedc38823a80a7209a80860b16b722e9e0209e32fea98c90e4e6624588ed6"},
+]
+
+[package.extras]
+lint = ["docutils-stubs", "flake8", "mypy"]
+standalone = ["Sphinx (>=5)"]
+test = ["pytest"]
+
+[[package]]
+name = "sphinxcontrib-serializinghtml"
+version = "1.1.10"
+description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)"
+optional = false
+python-versions = ">=3.9"
+files = [
+ {file = "sphinxcontrib_serializinghtml-1.1.10-py3-none-any.whl", hash = "sha256:326369b8df80a7d2d8d7f99aa5ac577f51ea51556ed974e7716cfd4fca3f6cb7"},
+ {file = "sphinxcontrib_serializinghtml-1.1.10.tar.gz", hash = "sha256:93f3f5dc458b91b192fe10c397e324f262cf163d79f3282c158e8436a2c4511f"},
+]
+
+[package.extras]
+lint = ["docutils-stubs", "flake8", "mypy"]
+standalone = ["Sphinx (>=5)"]
+test = ["pytest"]
+
+[[package]]
name = "stack-data"
version = "0.6.3"
description = "Extract data from python stack frames and tracebacks for informative displays"
@@ -2132,4 +2304,4 @@ test = ["websockets"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.10,<4.0"
-content-hash = "4fe544176264008f8027d33db4737a899f66e008a5183b14bb81f34620e61aa3"
+content-hash = "e6e49bddb59cbb4b0dbccfb99742caba7a8192e1179686ffbb9232b8bbf8c3d1"
diff --git a/pyproject.toml b/pyproject.toml
index 0b75fce..6a32eab 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -15,6 +15,10 @@ scipy = "^1.12.0"
[tool.poetry.group.notebook.dependencies]
notebook = "^7.1.1"
+
+[tool.poetry.group.dev.dependencies]
+sphinx = "^7.2.6"
+
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"