Symbolic and units-aware calculations for Jupyter notebooks
Welcome to Keecas, a Python package for symbolic and units-aware calculations in Jupyter notebooks, specifically designed for Quarto rendered documents (LaTeX PDF, HTML).
What is Keecas?
Keecas minimizes boilerplate for symbolic calculations in Jupyter notebooks by using Python dicts as its core container - keys represent left-hand side symbols, values represent right-hand side expressions. This natural mapping enables clean, readable code with dict comprehensions.
Built on SymPy (symbolic math), Pint (units), and Pipe (functional programming), Keecas provides a streamlined interface for unit-aware calculations with automatic LaTeX rendering.
Key Features
Symbolic Mathematics: Work with symbolic expressions and equations
Unit-Aware Calculations: Automatic unit conversion and dimensional analysis
LaTeX Output: Beautiful equation rendering for documents (amsmath)
Jupyter Integration: Seamless notebook workflow
Internationalization: Support for multiple languages and locales
Configurable: Flexible configuration system
Quick Example
from keecas import symbols, u, pc, show_eqn, generate_unique_label# Define symbols with LaTeX notationF_d, A_load, sigma = symbols(r"F_{d}, A_{load}, \sigma")# Parameters with units_p = { F_d: 10* u.kN, A_load: 50* u.cm**2,}# Expressions_e = { sigma: "F_d / A_load"| pc.parse_expr}# Evaluate_v = { k: v | pc.subs(_e | _p) | pc.convert_to([u.MPa]) | pc.Nfor k, v in _e.items()}# Description_d = { F_d: "design force", A_load: "loaded area", sigma: "normal stress",}# Label (Quarto only)_l = generate_unique_label(_d)# Displayshow_eqn( [_p | _e, _v, _d], # list of dict as main input label=_l # a dict of labels (key matching))
The normal stress is shown in \(\eqref{eq-27myzkyp}\) is the result of the design force \(\eqref{eq-1kv2lsa6}\) divided by the loaded area \(\eqref{eq-1qnugots}\).