Skip to content
Verified Commit 06c26192 authored by Alexander Hess's avatar Alexander Hess
Browse files

Make `gf2()` cast `value`s 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
parent b2f61558
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment