Skip to content

Commit c4ee9d8

Browse files
committed
Add example and fix URL typo in README.
1 parent 90d90f0 commit c4ee9d8

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

README.rst

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,37 @@ The library can be imported in the usual manner:
3737
import pratts
3838
from pratts import pratts
3939
40+
Examples
41+
^^^^^^^^
42+
To generate a `Pratt certificate <https://en.wikipedia.org/wiki/Primality_certificate#Pratt_certificates>`__ for a prime number, it is sufficient to supply an iterable of appropriately chosen primes that make it possible to recursively construct the certificate:
43+
44+
.. code-block:: python
45+
46+
>>> pratts(241, [2, 3, 5])
47+
{2: [], 3: [2], 5: [2], 241: [2, 3, 5]}
48+
49+
50+
.. |primefactors| replace:: ``primefactors``
51+
.. _primefactors: https://docs.sympy.org/latest/modules/ntheory.html#sympy.ntheory.factor_.primefactors
52+
53+
Alternatively, a function that returns prime factors can be supplied (such as the |primefactors|_ function that is available in the `SymPy library <https://www.sympy.org/>`__):
54+
55+
.. code-block:: python
56+
57+
>>> from sympy import primefactors
58+
>>> pratts(241, primefactors)
59+
{2: [], 3: [2], 5: [2], 241: [2, 3, 5]}
60+
61+
A certificate can be verified by supplying its keys (such that the same certificate is generated and returned):
62+
63+
.. code-block:: python
64+
65+
>>> certificate = pratts(1011235813471123581347, primefactors)
66+
>>> pratts(1011235813471123581347, certificate.keys()) is not None
67+
True
68+
>>> pratts(1011235813471123581347, certificate.keys()) == certificate
69+
True
70+
4071
Development
4172
-----------
4273
All installation and development dependencies are fully specified in ``pyproject.toml``. The ``project.optional-dependencies`` object is used to `specify optional requirements <https://peps.python.org/pep-0621>`__ for various development tasks. This makes it possible to specify additional options (such as ``docs``, ``lint``, and so on) when performing installation using `pip <https://pypi.org/project/pip>`__:
@@ -87,7 +118,7 @@ The version number format for this library and the changes to the library associ
87118

88119
Publishing
89120
^^^^^^^^^^
90-
This library can be published as a `package on PyPI <https://pypi.org/project/parts>`__ via the GitHub Actions workflow found in ``.github/workflows/build-publish-sign-release.yml`` that follows the `recommendations found in the Python Packaging User Guide <https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/>`__.
121+
This library can be published as a `package on PyPI <https://pypi.org/project/pratts>`__ via the GitHub Actions workflow found in ``.github/workflows/build-publish-sign-release.yml`` that follows the `recommendations found in the Python Packaging User Guide <https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/>`__.
91122

92123
Ensure that the correct version number appears in ``pyproject.toml``, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has an `automation rule <https://docs.readthedocs.io/en/stable/automation-rules.html>`__ that activates and sets as the default all tagged versions.
93124

0 commit comments

Comments
 (0)