Skip to content

Releases

Release v0.2.0

Choose a tag to compare

@MikesRND MikesRND released this 15 Nov 15:45
139b0a5

Chainfix 0.2.0 adds exact binary fixed-point arithmetic for real and complex scalars, and optional NumPy arrays with ordered reductions. It contains breaking changes; read Upgrading from 0.1.x before upgrading.

Highlights

  • Binary arithmetic (#13). Fixb/Ufixb support +, -, *, reflected integer operations, unary sign and abs, exact comparisons and hashing, raw shifts, and power-of-two scaling. Immutable Format and Math descriptors control result growth, all six rounding modes, and raise/saturate/wrap overflow. Use an explicit math= per call, or local_binary_context for a scope.
  • Complex scalars (#14). New CFixb: exact complex binary fixed point with one shared signed format, mixed complex/real/integer operators, conjugation, mag2, quantization, and exact equality and hashing.
  • Arrays (#18). Optional chainfix.arrays, installed with pip install "chainfix[arrays]" (NumPy >= 2.5). Real and interleaved complex arrays support broadcasting, arithmetic, comparisons, and disjoint out= buffers, using checked int64 kernels. The core package still does not depend on NumPy.
  • Ordered reductions (#24). cfa.sum, cfa.dot, cfa.matmul, Array.sum, and @, plus np.sum, np.add.reduce, np.dot, and np.matmul dispatch. Each reduction has separate product, accumulator, and sum quantization stages.
  • Faster complex gain (#21). Lower-allocation conversion kernels speed up public array paths, for example complex out= multiplication and nearest-even quantization. See docs/buffer-reuse.md.
  • Exact decimal construction (#27). Fixd/Ufixd round once from the exact input value under the decimal context's math, accept Fraction and fixed-point inputs, and compare and hash exactly against binary, complex, and Python numbers. str() gives the exact decimal value, and repr() rebuilds the value exactly.
  • Packaging (#28). Apache-2.0 metadata in the PEP 639 format (License-Expression), and updated project URLs.

Upgrading from 0.1.x

  • Python 3.12 or newer is required. Support for Python 3.8–3.11 is dropped. Tested on 3.12 through 3.15.
  • Binary overflow defaults to RAISE. Construction and conversion follow the context's rounding and overflow modes, or an explicit math=. To saturate or wrap on purpose, configure Math explicitly.
  • Exact conversion. Floats convert from their exact binary value and round once. Some results differ from 0.1.x, which converted through floats. For example, Fixd(2.675, 32, 2).int is 267, matching decimal.Decimal.
  • Exact equality and hashing. Fixed-point values compare and hash by exact numeric value, across formats and bases.
  • Contexts are immutable (#26). BinaryContext and DecimalContext are final. Assigning to them raises AttributeError, and subclassing raises TypeError. Use ctx.replace(...) together with set_*_context or local_*_context; both scopes also work as decorators.
    • ctx.copy() and get_default() are removed. set_*_context installs the given context rather than a copy.
    • The default contexts are frozen, so there is no process-wide default to change. Use contextvars.copy_context().run, Thread(context=...) on Python 3.14+, or an explicit math=.
    • Contexts pickled by earlier versions don't load, and contexts can't be weakly referenced.
    • DecimalContext drops its unused overflow setting and now carries math, which defaults to nearest-even rounding with raise on overflow.
  • Removed internals. _Fix, _Ufix, FromTypes, the default_* helpers, and get_current_context() are removed.
  • Error handling. FixedPointOverflowError subclasses ValueError, so existing except ValueError handlers still catch overflow.
  • Decimal arithmetic and direct decimal.Decimal construction input are still unsupported. For finite values, use Fraction(Decimal(...)).

Full documentation: README, binary arithmetic, arrays.

Full changelog: v0.1.2...v0.2.0

Release v0.1.2

Choose a tag to compare

@MikesRND MikesRND released this 27 Jul 22:29
c1fdc0c
  • Add support up to Python 3.13
  • Modernize build system
  • Add code coverage
  • Updated license

Release 0.1.1

Choose a tag to compare

@MikesRND MikesRND released this 21 Sep 18:42
89a7883
  • Added contexts for creating binary and decimal fixed point objects
  • New as_integer_ratio method
  • Refactored into multiple modules
  • Additional tests
  • Limit * imports
  • Raise exception when value is out of range
  • Automate pypi releases

Initial Release

Choose a tag to compare

@MikesRND MikesRND released this 20 Sep 21:51

Initial release