Add GF2 type for Galois field elements

- add `GF2` class in the `lalib.elements` sub-package
  implementing a typical Galois field with two elements
- the singleton objects `one` and `zero` are the concrete
  instances of the `GF2` type for the end users
- besides the typical Galois arithmetic, `one` and `zero`
  behave like the built-in numbers `1` and `0`
  and implement the `numbers.Rational` interface
- add exhaustive docstrings with usage examples
- add (unit) test cases with 100% coverage
This commit is contained in:
Alexander Hess 2024-09-18 18:04:35 +02:00
commit 3cecf0d989
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
6 changed files with 1381 additions and 1 deletions

View file

@ -230,6 +230,7 @@ TEST_DEPENDENCIES = (
"pytest",
"pytest-cov",
"semver",
'typing-extensions; python_version < "3.11"', # to support Python 3.9 & 3.10
"xdoctest",
)
@ -284,6 +285,7 @@ def test_coverage_run(session: nox.Session) -> None:
session.install(".")
install_pinned(session, "coverage", *TEST_DEPENDENCIES)
session.env["NO_CROSS_REFERENCE"] = "true"
session.run(
"python",
"-m",
@ -430,6 +432,11 @@ def start(session: nox.Session) -> None:
session.env["PIP_CACHE_DIR"] = ".cache/pip"
session.env["PIP_DISABLE_PIP_VERSION_CHECK"] = "true"
if session.python in ("3.12", "3.11"):
session.env["PRAGMA_SUPPORT_39_N_310"] = "to support Python 3.9 & 3.10"
else:
session.env["PRAGMA_SUPPORT_39_N_310"] = f"{_magic_number =}"
def suppress_poetry_export_warning(session: nox.Session) -> None:
"""Temporary fix to avoid poetry's warning ...