Commit graph

65 commits

Author SHA1 Message Date
aeca30b72e
Add Domain() to top-level imports for lalib
Some checks failed
audit / audit (push) Has been cancelled
docs / docs (push) Has been cancelled
lint / lint (push) Has been cancelled
test-coverage / test-coverage (push) Has been cancelled
test-docstrings / test-docstrings (push) Has been cancelled
tests / test-3.10 (push) Has been cancelled
tests / test-3.11 (push) Has been cancelled
tests / test-3.12 (push) Has been cancelled
tests / test-3.13 (push) Has been cancelled
tests / test-3.9 (push) Has been cancelled
2024-10-20 02:45:41 +02:00
4a5e316d0c
Add lalib.domains.Domain
- this class models domains from linear algebra
  and is needed for the `Vector` class to be created
- `Domain` wraps Python's built-in `frozenset` type
  + they must contain at least one label
  + as a convenience, so-called canonical `Domain`s
    (i.e., with labels `0`, `1`, ...) can be created
    by passing in a positive `int`eger to `Domain()`
- the `Domain.is_canonical` property indicates
  what kind a `Domain` is
- add unit tests for the class
- add extensive documentation for the class
2024-10-20 02:35:43 +02:00
9308633ded
Make smoke tests exit early 2024-10-20 02:24:43 +02:00
81bbd4ac0f
Make smoke tests not do cross checking
Some unit tests also contain integration-like tests
that should not be run when smoke testing
2024-10-20 02:12:11 +02:00
bfbbbd01e4
Fix missing Python version
Forgotten in commit 25c718fe6a
2024-10-20 01:55:31 +02:00
06c26192ad
Make gf2() cast values in non-strict mode
- so far, `gf2()` runs in a `strict` mode by default
  => `gf2(42)` results in a `ValueError`
- we adapt `gf2()` (a.k.a. `lalib.elements.galois.GF2Element`)
  such that it behaves more like the built-in `bool()`
  => `gf2(42)` returns `one`, like `bool(42)` returns `True`
- further, the `GF2Element` class is adjusted such that
  `one` and `zero` assume their counterparts to be
  `1`-like or `0`-like objects during binary operations;
  other values result in an error
  => for example, `one + 1` works but `one + 42` does not
  => so, when used in binary operations, `one` and `zero`
     continue to cast their counterparts in `strict` mode
- simplify the casting logic
- make `value` a positional-only argument in `gf2()`
  (like most of the built-in constructors)
- provide more usage examples in the docstrings
  clarifying when `strict` mode is used and when not
- propagate the above changes to the test suite:
  + adapt test cases with regard to the `strict` mode logic
  + add new test cases to `assert` how `gf2()`
    can process `str`ings directly
  + rename two test cases involving `complex` numbers
    to mimic the naming from the newly added test cases
2024-10-16 14:49:35 +02:00
b2f6155872
Merge branch 'fields' into 'develop'
Some checks failed
audit / audit (push) Has been cancelled
docs / docs (push) Has been cancelled
lint / lint (push) Has been cancelled
test-coverage / test-coverage (push) Has been cancelled
test-docstrings / test-docstrings (push) Has been cancelled
tests / test-3.10 (push) Has been cancelled
tests / test-3.11 (push) Has been cancelled
tests / test-3.12 (push) Has been cancelled
tests / test-3.13 (push) Has been cancelled
tests / test-3.9 (push) Has been cancelled
2024-10-16 12:01:00 +02:00
c7f076c35c
Update dependencies
- bandit (1.7.9 -> 1.7.10)
- black (24.8.0 -> 24.10.0)
- charset-normalizer (3.3.2 -> 3.4.0)
- coverage (7.6.1 -> 7.6.3)
- distlib (0.3.8 -> 0.3.9)
- markupsafe (2.1.5 -> 3.0.1)
- mypy (1.11.2 -> 1.12.0)
- pydoclint (0.5.7 -> 0.5.9)
- rich (13.8.1 -> 13.9.2)
- ruff (0.6.5 -> 0.6.9)
- sphinx (8.0.2 -> 8.1.3)
- virtualenv (20.26.5 -> 20.26.6)
2024-10-16 11:55:52 +02:00
6ddb545491
Remove unnecessary Optional
The type hints `object` and `Optional[object]`
both allow the default value `None`.

Also, this commit gets rid of ruff's "FA100" error
for the two changed lines.
2024-10-16 11:47:51 +02:00
81912f1a81
Make linters check for unused function arguments 2024-10-16 11:23:54 +02:00
25c718fe6a
Make Python 3.13 the new default 2024-10-16 01:32:14 +02:00
f952d95951
Make value a positional-only argument in gf2()
Most of Python's built-in data types behave like this as well
2024-10-15 02:17:23 +02:00
849b786e13
Add fields to top-level imports for lalib 2024-10-15 02:15:10 +02:00
6bd21ce134
Fix missing module
Forgotten in commit 153094eef5
2024-10-15 02:04:34 +02:00
7e3e67c300
Add smoke tests
- extend `pytest` with an option to run only the minimum number
  of (unit) test cases to just keep the coverage at 100%
- rationale:
  + many of the unit test cases partly overlap with
    respect to the lines of source code executed
  + also, integration tests, by definition, do not
    contribute to a higher test coverage
- implementation: mark "redundant" test cases as one of:
  + `pytest.mark.integration_test`
    => code usage from the perspective of the end user
  + `pytest.mark.overlapping_test`
    => tests not contributing to the 100% coverage
  + `pytest.mark.sanity_test`
    => tests providing confidence in the test data
- add `tests.conftest` module
  => programatically convert the above markers into
     `@pytest.mark.no_cover` and collect the non-"redundant" tests
- add nox session "test-fast" to run only the minimum
  number of (unit) test while holding coverage at 100%
- refactor some test modules
  + wrap some test cases in a class
  + move sanity tests to the end of the files
2024-10-15 01:49:32 +02:00
de740ebb5f
Unify the various *_THRESHOLDs 2024-10-14 16:36:02 +02:00
04addacb09
Add tests.utils module 2024-10-14 16:34:17 +02:00
153094eef5
Add Q, R, C, and GF2 fields
- add `lalib.fields.base.Field`, a blueprint for all concrete fields,
  providing a unified interface to be used outside of the
  `lalib.fields` sub-package
- implement `lalib.fields.complex_.ComplexField`, or `C` for short,
  the field over the complex numbers (modeled as `complex` numbers)
- implement `lalib.fields.galois.GaloisField2`, or `GF2` for short,
  the (finite) field over the two elements `one` and `zero`
  + adapt `lalib.elements.galois.GF2Element.__eq__()` to return
    `NotImplemented` instead of `False` for non-castable `other`s
    => this fixes a minor issue with `pytest.approx()`
- implement `lalib.fields.rational.RationalField`, or `Q` for short,
  the field over the rational numbers (modeled as `fractions.Fraction`s)
- implement `lalib.fields.real.RealField`, or `R` for short,
  the field over the real numbers (modeled as `float`s)
- organize top-level imports for `lalib.fields`,
  making `Q`, `R`, `C`, and `GF2` importable with
  `from lalib.fields import *`
- provide extensive unit and integration tests for the new objects:
  + test generic and common behavior in `tests.fields.test_base`
  + test specific behavior is other modules
  + test the well-known math axioms for all fields (integration tests)
  + test the new objects' docstrings
  + add "pytest-repeat" to run randomized tests many times
2024-10-14 15:17:42 +02:00
cbc1f8fd3a
Add lalib.config for library-wide settings
Also, refactor `lalib.elements.galois`
(incl. tests) to use the new settings
2024-10-14 15:02:50 +02:00
febed693b8
Make asserts more Pythonic 2024-10-14 14:38:09 +02:00
08067b3d6e
Fix pytest not respecting the singleton pattern
This is only a temporary fix!

See issue: https://github.com/webartifex/lalib/issues/1
2024-09-27 16:16:01 +02:00
3d9f990c68
Reset random.seed() before every test case 2024-09-27 16:04:37 +02:00
4c0c7887e5
Allow and unify the usage of TODOs 2024-09-27 15:29:33 +02:00
06d003b615
Hide gf2 sub-classes even more
- the `gf2` sub-classes `GF2One` and `GF2Zero` have no purpose
  other than to provide unique `help(one)` and `help(zero)` messages
- delete them at the bottom of `lalib.elements.galois`
  to prevent them from being imported at all
  (`type(one)` and `type(zero)` still appear to be the `gf2` class,
   which is a little white lie, provided by some meta class)
- differentiate between official and inofficial API in the test suite
2024-09-19 15:36:10 +02:00
348cd53767
Make lalib.elements.galois.to_gf2() a detail
- `to_gf2()` is only to be used within `GF2Element.__new__()`
  => rename it into `_to_gf2()`
- the test cases in `TestGF2ConstructorWithCastedValue`
  cover everything in `TestGF2Casting`
  => retire the redundant test cases
     and make the test suite run faster
2024-09-19 14:22:10 +02:00
917c217ca0
Rename lalib.elements.gf2.GF2 & friends
- the future (concrete) Galois `Field` implementation
  shall receive the name `GF2` (as per common math notation)
  => name conflict with the current `GF2` class
     implementing the elements of the future Galois `Field`
  => rename the current `GF2` class into `GF2Element`
- because `GF2Element` is a bit tedius to type for the end user,
  we introduce a `gf2` alias in line with the naming convention
  for the built-in data types (e.g., `int` or `float`)
  that are also used as elements of (other) `Field`s
  => name conflict with the current `lalib.elements.gf2` module
  => rename the module into `lalib.elements.galois`
- adjust the docstrings to refer to "the `gf2` type"
- adjust the top-level imports and tests
2024-09-19 12:14:20 +02:00
65de932f8d
Add lalib.fields sub-package 2024-09-18 23:42:38 +02:00
4c47ca1b17
Merge branch 'gf2-type' into 'develop' 2024-09-18 23:16:51 +02:00
ea85c73933
Update dependencies
- filelock (3.16.0 -> 3.16.1)
- identify (2.6.0 -> 2.6.1)
- idna (3.8 -> 3.10)
- platformdirs (4.3.2 -> 4.3.6)
- pytest (8.3.2 -> 8.3.3)
- rich (13.8.0 -> 13.8.1)
- ruff (0.6.4 -> 0.6.5)
- setuptools (74.1.2 -> 75.1.0)
- urllib3 (2.2.2 -> 2.2.3)
- virtualenv (20.26.4 -> 20.26.5)
2024-09-18 22:53:33 +02:00
51c73163e4
Refactor test_top_level_imports() test cases ...
... into a unified location
2024-09-18 20:05:49 +02:00
62b25f66d9
Organize top-level imports for lalib
- make `GF2`, `one`, and `zero`, defined in the `lalib.elements.gf2`
  module, available as top-level imports for the `lalib` package
  via `from lalib import *`
- provide some code snippets in the package's docstring
- test the star import
2024-09-18 18:37:54 +02:00
3cfc0db136
Organize top-level imports for lalib.elements
- make `GF2`, `one`, and `zero`, defined in the `lalib.elements.gf2`
  module, available as top-level imports in the `lalib.elements`
  sub-package via `from lalib.elements import *`
- provide some code snippets in the sub-package's docstring
- test the star import
2024-09-18 18:29:40 +02:00
3cecf0d989
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
2024-09-18 18:04:35 +02:00
d405c22c90
Enforce PEP257 strictly ...
... and put docstrings for class constructors
into `.__init__()` methods

Source: https://peps.python.org/pep-0257/#multi-line-docstrings
2024-09-18 15:17:53 +02:00
d9dcea8379
Do not allow mere "pragma: no cover"s 2024-09-18 15:15:24 +02:00
9083cebe18
Fix missing empty line ...
... to make overview on sections clearer
2024-09-18 15:08:19 +02:00
d507e1f56d
Add lalib.elements sub-package 2024-09-10 11:53:17 +02:00
5d2f430893
Bump version 2024-09-10 03:55:36 +02:00
fbc9b5f134
Prepare release v0.4.2 2024-09-10 03:39:30 +02:00
d77e96c426
Merge branch 'set-up-project' into 'develop' 2024-09-10 03:33:50 +02:00
0b5cc56925
Drop nox-poetry support
Whereas nox-poetry is a nice project,
it is not (yet) widely supported.

The `install_pinned()` function inside the "noxfile.py"
achieves most of its functionality.

Also, there is a chance poetry will be replaced in this project.

So, we no longer drag nox-poetry along.
2024-09-10 03:28:17 +02:00
97b91c676e
Add a "clean-cwd" task
- add nox session "clean-cwd" to clean the working directory
- the task is roughly `git clean -X` with minor exceptions
2024-09-10 03:26:06 +02:00
dd868cce4d
Run poetry publish on GitHub actions 2024-09-10 03:22:52 +02:00
b92d871acf
Integrate readthedocs.io
We publish the docs to readthedocs.io
2024-09-10 03:12:22 +02:00
3f8b5cb146
Integrate codecov.io
We publish the test coverage reporting to codecov.io
2024-09-10 03:10:26 +02:00
5518837cbc
Run nox -s test-docstrings on GitHub actions
The xdoctest integration in pytest (see tests/test_docstrings.py)
is prone to miss docstrings in new source files as they must be
included in the test case explicitly.

So, to play it safe, we run the nox session "test-docstrings" on CI.
2024-09-10 03:00:56 +02:00
9c6cae3593
Run nox -s test-coverage on GitHub actions 2024-09-10 02:53:35 +02:00
62f7a79abf
Run nox -s test on GitHub actions 2024-09-10 02:50:06 +02:00
3e3182353e
Run nox -s lint on GitHub actions 2024-09-10 02:47:46 +02:00
f98491a6b5
Run nox -s docs on GitHub actions 2024-09-10 02:45:58 +02:00