Skip to main content

Clean looking engineering calculations for IPython

Project description

ipycalc

Simple Engineering Calculations in Jupyter

Turn the contents of a Jupyter cell into a formatted calculation by following the steps below:

  1. Install ipycalc using pip install ipycalc
  2. Use from ipycalc import calc to bring ipycalc into your notebook's namespace.
  3. Use %%calc as the first line of a cell to indicate that you want to run ipycalc on the contents of a cell.

The basic calculation syntax is:

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

Here's a simple example that calculates the flexural strength of a concrete beam:

Example

Key components of the ipycalc syntax are:

  • : (required) The description must come before this character.
  • = (optional) Used to assign a python expression to a variable name. Omit this if you simply want to reprint a previously defined variable.
  • -> (optional) Separates the python expression from the results formatting rules.
  • * (optional) Indicate the number of decimals you want to see in the result to the left of the *, and the units you want to see in the result to the right.
  • # (optional) Indicates reference text to the side of the calculation - handy for equation references or code references.

Here are a few useful things to keep in mind when using ipycalc:

  • Subscripts can be added by using the _ character to indicate the start of a subscript.
  • Greek characters included in the python_expression can just be written out (e.g. epsilon). To include greek characters in the Variable Description or the Reference Text, you can use Jupyter's Markdown Latex tags (e.g. $\epsilon$). Note that the greek character psi is ambiguous with the unit psi (pounds per square inch), so for that character specifically you'll need to use \grpsi to tell ipycalc you want the greek character rather than the unit.
  • To stack fractions place the numerator and denominater in parentheses: (num)/(denom) yields $\dfrac{num}{denom}$.
  • if statements and else statements are available using python's inline if statement (terniary) notation.
  • Square roots can be displayed using sqrt.
  • Prime characters can be displayed using ^prime.
  • If text gets to lengthy to fit on one line, you can add \\ to force a line break anywhere in a line. This can help your calculations fit within the page's print margins.
  • ipycalc assists you with printing your notebooks. It has a built in nbconvert template called ipycalc that works just like the webpdf template, except it fixes the the bad margins in the webpdf template, and avoids page breaks right after headers. Any cells tagged with hide_cell will not be rendered. Any cells tagged with hide_input will only show the output upon printing. You can select it from the file menu via "File -> Save and Export Notebook As... -> Ipycalc"

IPycalc is still in development. There could be bugs, so be cautious and validate the answers it gives you. A special thanks to @connorferster for his project handcalcs which inspired this project. A link to handcalcs is here: 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-0.0.77.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

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

ipycalc-0.0.77-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ipycalc-0.0.77.tar.gz
Algorithm Hash digest
SHA256 99d931294a6687ea653419490da3c89caf22b6c8302c3084ad82985b11dc71d4
MD5 f9581b202e5c5b69944f3b24d4dd2506
BLAKE2b-256 e74956cc7790ac82006df8f784911bdce1676eed4aa2086fdc1def4294df7c27

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ipycalc-0.0.77-py3-none-any.whl
Algorithm Hash digest
SHA256 d2dbf15aa3c3b6ccce6e3b03fa279bb60bfff9c0d0aa3f0589630c85788a0df3
MD5 c0d67fd054d6e8622d329d301b9d058e
BLAKE2b-256 6cf41abd98477ac129a937e56daa033ab7007fa5f6f9d0ac61c1510eae5571e5

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