Skip to main content

Clean looking engineering calculations for IPython

Project description

ipycalc

Engineering calculations in Jupyter, formatted for clear review and professional reports.

ipycalc helps engineers move from raw notebook math to readable, auditable calculations. Write equations in Python, add descriptions and references, and get polished output that is easier to check, share, and print.

Why Use ipycalc?

  • Turn opaque code cells into presentation-ready engineering calculations.
  • Keep the speed and flexibility of Python while improving readability.
  • Add units, references, and notation in one place.
  • Export cleaner PDFs with the built-in nbconvert template.
  • Reuse project variables across notebooks without manual copy/paste.

If you already use Jupyter for design work, ipycalc helps close the gap between computation and documentation.

Quick Start

  1. Install:
pip install ipycalc
  1. Import in your notebook:
from ipycalc import calc
  1. Start a calc cell with %%calc.

Basic Syntax

Variable Description: variable_name = python_expression -> result_decimal_places*result_unit # Reference Text

Example (flexural strength of a concrete beam):

Example

Syntax Reference

  • : (required) Description appears before this character.
  • = (optional) Assign a Python expression to a variable. Omit to reprint a previously defined variable.
  • -> (optional) Separates the expression from result formatting rules.
  • * (optional) Set decimal places to the left and result units to the right.
  • # (optional) Add right-side reference text (equation references, code references, notes).

Useful Notes

  • Subscripts: use _ to indicate the start of a subscript.
  • Greek in expressions: write names directly (for example epsilon).
  • Greek in descriptions/reference text: use Jupyter Markdown LaTeX (for example $\epsilon$).
  • psi is ambiguous with pressure units; use \grpsi when you need the Greek character.
  • Stacked fractions: wrap numerator and denominator in parentheses, for example (num)/(denom) renders as $\dfrac{num}{denom}$.
  • Conditionals: use Python inline ternary notation.
  • Square roots: use sqrt.
  • Prime notation: use ^prime.
  • Manual line breaks: insert \\ where needed to avoid overflow in print layouts.
  • Printing: ipycalc includes an nbconvert template named ipycalc that behaves like webpdf, but with improved margins and better page-break behavior after headers.
  • Numbered/sectioned printing: use the ipycalc_numbered exporter to automatically number section headers (h2 and below). This is useful for formal calculation packages where references to section numbers are required.
  • Tag a cell with one of the following tags to change the way it prints to PDF:
    • hide_cell excludes the entire cell.
    • hide_input prints output only.
  • In Jupyter, export with:
    • File -> Save and Export Notebook As... -> Ipycalc
    • File -> Save and Export Notebook As... -> Ipycalc_numbered
  • From the command line, you can also export with jupyter nbconvert --to ipycalc or jupyter nbconvert --to ipycalc_numbered.

Sharing Variables Between Notebooks

ipycalc can save variables from one notebook and import them into another. This is useful for multi-notebook workflows, such as loads feeding into member design.

Saving variables:

from ipycalc import save_vars
save_vars('my_notebook.ipynb')

This writes user-defined variables (including pint quantities with units) to .ipycalc_vars/my_notebook.json in the notebook's directory. The notebook file itself is never modified.

Importing variables:

from ipycalc import import_vars
import_vars('my_notebook.ipynb')           # import all saved variables
import_vars('my_notebook.ipynb', 'P', 'L') # import specific variables only

Both functions are also available directly inside a %%calc cell with no import statement required.

Variables are saved and loaded by filename only. Both notebooks must be in the same working directory.

Project Status

ipycalc is actively evolving. Validate results as part of your normal engineering QA process.

Special thanks to @connorferster and the handcalcs project for inspiration: https://github.com/connorferster/handcalcs

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

ipycalc-1.0.3.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

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

ipycalc-1.0.3-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file ipycalc-1.0.3.tar.gz.

File metadata

  • Download URL: ipycalc-1.0.3.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ipycalc-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a571cc51055f2891301e45aa054c3bc213582ab7b7017655834669cd03dbffab
MD5 df35b0afa8b10257a07f458a60cff11d
BLAKE2b-256 334495bf53116a6108a0a8a0cac28d11076a7d1ec72e963c6efc3d79e4bd82dc

See more details on using hashes here.

File details

Details for the file ipycalc-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: ipycalc-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ipycalc-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 828a2aafece1844865e2119917f788cb105327e13ae14dd0fdb54b22883539cc
MD5 fd6d09dbbf1f2faab550589382e81495
BLAKE2b-256 e38aa920ca55f78bb4dd0f3adb48faa2294fbc5f7231255068837a9f889e478f

See more details on using hashes here.

Supported by

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