Representing Constructible Numbers in Python
The constructible module provides exact representation of constructible numbers in Python.
Python 2 and Python 3 are supported.
The constructible numbers are the smallest field containing the rational numbers, where the square root of any non-negative constructible number is constructible as well. The non-negative constructible numbers are the lengths which can be constructed from the unit length using only a compass and a straightedge.
Usage
Usually the sqrt function is enough to work with constructible numbers:
>>> from constructible import sqrt >>> x = sqrt(2) + sqrt(3) >>> print(x) ((0 + 1 * sqrt(2)) + (1 + 0 * sqrt(2)) * sqrt((3 + 0 * sqrt(2)))) >>> y = x*x >>> print(y) ((5 + 0 * sqrt(2)) + (0 + 2 * sqrt(2)) * sqrt((3 + 0 * sqrt(2)))) >>> z = y*y >>> t = 10*y - z >>> t == 1 True
Installation
To install from PYPI just type
pip install constructible
The library is a single pure python file, so it is also easy to install by hand.
Testing
There are some tests using unittest. Thanks to Travis-CI each push to github triggers a test:
Releasing on PYPI
The following steps are needed:
make sure .pypirc is up to date:
[distutils] index-servers = pypi pypitest [pypi] repository=https://pypi.org/legacy/ username=xxx password=xxx [pypitest] repository=https://test.pypi.org/legacy/ username=xxx password=xxx
Update the version in setup.py
Tag the version in git:
git tag 0.1 -m "Adds a tag so that we can put this on PyPI." git push --tags origin
Test release with:
python setup.py sdist upload -r pypitest
Productive release with:
python setup.py sdist upload -r pypi
Changelog
2016-05-23 V0.1 Initial Release
2016-09-30 V0.2 Fixing Issue 1 and added Tests
2016-10-03 V0.3 Fixing Issue 2
2016-10-23 V0.4 Added __hash__ and __float__, speed optimizations
2020-07-08 V0.5 New hash function and improvements by Arsenii A.
Aknowledgements
Thanks to Anders Kaseorg whose implementation of constructible numbers in Haskell provided inspiration and in particular the algorithm for taking square roots in quadratic extension fields.
Metadata
Release files for constructible 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| constructible-0.5.0.zip | 6.8 kB | Without provenance | Details for constructible-0.5.0.zip |
Release files / constructible-0.5.0.zip
| Download URL | constructible-0.5.0.zip |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df86b3b738e609cee017c7c76f29d740e8b00fde24f48d952926165dc4881ccb
|
|
BLAKE2b-256 checksum How to use checksums |
464daafc6633d14beac32990874f82a6e5c2462518c5c32bc99497d2b80b91fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.5
|
Security for constructible 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.