Skip to content

fix: derive MAX_PRECISION from the engine, not wrapper bindings#43

Open
hozblok wants to merge 1 commit into
masterfrom
fix/max-precision-not-tied-to-wrapper-bindings
Open

fix: derive MAX_PRECISION from the engine, not wrapper bindings#43
hozblok wants to merge 1 commit into
masterfrom
fix/max-precision-not-tied-to-wrapper-bindings

Conversation

@hozblok

@hozblok hozblok commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Problem

backend.py computed MAX_PRECISION by scanning the bound mp_real_<P> wrapper
classes, so a .pyd with a sparse wrapper ladder (e.g. only mp_real_24) shrank the
Solver bound to 24:

>>> Solver("sqrt(2)", precision=100)()
ValueError: precision must be in [0, 24] (got 100)

The Formula engine itself evaluates at any AllowedPrecisions value regardless of
wrapper coverage — the two concepts are independent.

Fix

  • main.cpp: expose csconstants::max_precision as _formula.MAX_PRECISION.
  • backend.py: read it directly instead of scanning wrappers.
  • One regression test in test_solver_precision_bounds.py: the constant comes from
    the engine attr, not from the wrapper scan.

backend.py computed MAX_PRECISION by scanning the bound mp_real_<P>
wrapper classes, so a .pyd with a sparse wrapper ladder (e.g. only
mp_real_24) shrank the Solver bound to 24 — even though the Formula
engine evaluates at any AllowedPrecisions value regardless of wrapper
coverage. Expose csconstants::max_precision as _formula.MAX_PRECISION
and read it directly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hozblok hozblok force-pushed the fix/max-precision-not-tied-to-wrapper-bindings branch from 7479af0 to 20e5a02 Compare June 10, 2026 14:57
@hozblok hozblok changed the title fix: MAX_PRECISION should reflect engine capability, not wrapper bindings fix: derive MAX_PRECISION from the engine, not wrapper bindings Jun 10, 2026
@hozblok hozblok marked this pull request as ready for review June 10, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant