Skip to main content

mpeqs

Exact answers for the arithmetic a language model should not be doing itself.

Linux macOS Windows PyPI

pip install mpeqs
import mpeqs

mpeqs.solve({"solver": "arith", "answer": "(17/100)*250"})   # Fraction(85, 2)

The model names a solver and fills its slots. This evaluates the spec exactly, or refuses by name — it never guesses, and it never returns a number it could not derive.

The refusal is the point. A solver that cannot evaluate a spec raises Refusal with a reason, and that reason is a routing signal: it tells the caller to ask the model, rather than quietly handing back a wrong number.

try:
    mpeqs.solve({"solver": "arith", "answer": "1/0"})
except mpeqs.Refusal as why:
    ...   # ask the model; the record declined this one

Shape disposes over name. A model that picks the wrong solver but fills the right slots has still described the problem correctly, so a spec carrying an answer key is arithmetic whatever it calls itself. Pass repair=False to turn that off.

What is exact and what is not

Results come back as fractions.Fraction, so nothing is lost on the way out. The exactness is in the arithmetic, not in the parsing: a ratio written as a ratio stays exact, while a decimal literal is read as a float first.

mpeqs.solve({"solver": "arith", "answer": "1/10+2/10"})   # Fraction(3, 10)  exact
mpeqs.solve({"solver": "arith", "answer": "0.1+0.2"})     # the binary expansion

Solvers

arith, geometry, iterate, modular, multisearch, polynomial, and the named families behind them — factorisation, gcd/lcm, linear systems, quadratics, remainders, combinatorics, rates, mixtures, ratios, base conversion.

mpeqs.solvers() lists what a given build dispatches to.

No dependencies

The whole library is standard library. One py3-none-any wheel serves Linux, macOS and Windows on every supported interpreter, the install is instant, and a test asserts that no third-party import creeps in.

Licence

The mpedb License 1.0 — free of charge for every person and every organization, except that a group over five billion dollars in revenue or valuation owes seven US cents per device, once. Not an OSI-approved licence.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpeqs-0.1.0.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mpeqs-0.1.0-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

Details for the file mpeqs-0.1.0.tar.gz.

File metadata

  • Download URL: mpeqs-0.1.0.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.12

File hashes

Hashes for mpeqs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc8058aff83fd3686a8f2e4eff719a36a4ec4305691086e24f5b0277b8836681
MD5 d0a65463a697aaed49a7bceb645378cc
BLAKE2b-256 0237a56ab5b06f31e9802664d1f4b2f95644a3ccfbdb8b33d5966258a383a686

See more details on using hashes here.

File details

Details for the file mpeqs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mpeqs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.12

File hashes

Hashes for mpeqs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d28ab4dca37aa5ebec91f13ead7939bd6b7d4cf2facc4c4c26f2e7200fa674b6
MD5 64790c0da85057299cf381aebec8ad23
BLAKE2b-256 3ff4853a12954b52e32ff469c00cec98bcb39485b3047f6d20a4f0221c4425f2

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page