Symbolic and units-aware calculations for Jupyter notebooks with beautiful LaTeX output.
keecas minimizes boilerplate for symbolic calculations using Python dicts as the core container - keys represent left-hand side symbols, values represent right-hand side expressions. Built on SymPy, Pint, and Pipe, it provides automatic unit conversion and LaTeX rendering for Quarto documents.
fromkeecasimportsymbols, u, pc, show_eqn# 1. Define symbols with LaTeX notationF, A, sigma=symbols(r"F, A, \sigma")
# 2. Cell-local parameters_p= {
F: 10*u.kN,
A: 50*u.cm**2,
}
# 3. Cell-local expressions_e= {
sigma: "F / A"|pc.parse_expr
}
# 4. Evaluation with pipe operations_v= {
k: v|pc.subs(_e|_p) |pc.convert_to([u.MPa]) |pc.Nfork, vin_e.items()
}
# 5. Display as LaTeX amsmathshow_eqn([_p|_e, _v])Output:
\begin{align} F & = 10{\,}\text{kN} & \\[8pt] A & = 50{\,}\text{cm}^{2} & \\[8pt]\sigma & = \dfrac{F}{A} & = 2.0{\,}\text{MPa}\end{align}See hello_world.ipynb for more examples.
pip install keecas
# or
uv add keecasLaunch JupyterLab with keecas template:
keecas edit # Minimal template
keecas edit --template quickstart # Comprehensive examples
keecas edit analysis.ipynb # Open specific notebook
keecas edit --temp # Temporary sessionManage global and local settings via TOML files:
# Initialize configuration
keecas config init --global
# Edit configuration
keecas config edit --global # Terminal editor
keecas config open --local # System editor (GUI)# View configuration
keecas config show # Merged settings
keecas config path # File locations- Dict-based equations: Natural mapping of LHS to RHS
- Pipe operations: Chain operations like
expr | pc.subs(...) | pc.N - Unit-aware: Automatic conversion between Pint and SymPy units
- LaTeX output: Renders as amsmath align blocks
- Cross-references: Label generation for Quarto documents
- Multi-language: 10 languages supported (5 fully localized)
- Configuration: Global/local TOML-based settings
Full documentation: https://kompre.github.io/keecas
MIT License - see LICENSE