human-to-sympy
Parse human-typed equation strings into canonical SymPy expression strings.
human-to-sympy accepts the kind of math people actually type — ^ for power,
familiar function names, bare identifiers — and returns the corresponding SymPy
expression as a normalized string. It does not perform equivalence comparison;
for that, use eq-equiv.
What it does
- Replaces
^with**. - Splits on
=when present and returns the right-hand side (forgenerate_sympy_rhs*) or both sides (forgenerate_sympy_equation). - Distinguishes function-call sites from bare identifiers and binds them to
sympy.Functionandsympy.Symbolrespectively, while leaving SymPy builtins (pi,E,log,sin, ...) alone. - Returns a typed result object preserving the failure reason on parse error.
API
from human_to_sympy import (
SympyEquationGenerationResult,
SympyGenerationResult,
check_symbols,
generate_sympy_equation,
generate_sympy_rhs,
generate_sympy_rhs_with_error,
)
generate_sympy_rhs(text) -> str | None— convenience accessor for the RHS string.generate_sympy_rhs_with_error(text) -> SympyGenerationResult— same, but preserves the parse error.generate_sympy_equation(text) -> SympyEquationGenerationResult— returns both sides of anlhs = rhsequation.check_symbols(text, variables) -> list[str]— warns when expression free symbols are not declared in the supplied variable list.
Example
from human_to_sympy import generate_sympy_rhs
assert generate_sympy_rhs("Fa = 1 / (2 * pi * Ta)") == "1/(2*pi*Ta)"
assert generate_sympy_rhs("(2*pi*Ta*f)^2") == "(2*pi*Ta*f)**2"
Metadata
Release files for human-to-sympy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| human_to_sympy-0.1.0.tar.gz | 9.5 kB | Without provenance | Details for human_to_sympy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| human_to_sympy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for human_to_sympy-0.1.0-py3-none-any.whl |
Total release size: 15.2 kB
Release files / human_to_sympy-0.1.0.tar.gz
| Download URL | human_to_sympy-0.1.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
745d5ecc38137bcf836f5a3c6709518909ef98be2c93c8af78cead44a8dcd2c4
|
|
BLAKE2b-256 checksum How to use checksums |
92b471b8d966aaca0545835944fcdc58076fed3773ed42165227f18980a480ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.8
|
Release files / human_to_sympy-0.1.0-py3-none-any.whl
| Download URL | human_to_sympy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
122710d13689388f0ccfe18ecd365cc3d7c19d1a2d64154ce8e5708622385c90
|
|
BLAKE2b-256 checksum How to use checksums |
715a08d252ff69f9389a23ef56534820c5f51ca0f587d2ec36bd3b09df8f7d74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.8
|
Security for human-to-sympy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.