Commit graph

8 commits

Author SHA1 Message Date
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
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
51c73163e4
Refactor test_top_level_imports() test cases ...
... into a unified location
2024-09-18 20:05:49 +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
d507e1f56d
Add lalib.elements sub-package 2024-09-10 11:53:17 +02:00