Skip to main content

Clean looking engineering calculations for IPython

Project description

ipycalc

Simple Engineering Calculations in Python

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

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.
  • 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 notation.
  • Square roots can be displayed using sqrt.
  • Prime characters can be displayed using ^prime.
  • If a line gets too long for printing, you can add a line break to the description, equation, or reference by inserting \\.
  • 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 its infancy. I'm sure there are bugs, so be cautious and use your head. A special thanks to @connorferster for handcalcs which inspired this project: https://github.com/connorferster/handcalcs

Project details


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.51.tar.gz (124.1 kB view details)

Uploaded Source

Built Distribution

ipycalc-0.0.51-py3-none-any.whl (132.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ipycalc-0.0.51.tar.gz
  • Upload date:
  • Size: 124.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for ipycalc-0.0.51.tar.gz
Algorithm Hash digest
SHA256 12c3c0030181fcbca946bc10a3f3997987f7547e028c1f265eeb8ad7c096e91b
MD5 f520d6373bcc70c0f6dfa9f07d7df6a6
BLAKE2b-256 aae71a18412cba87bd7761ad1d02d63d6796d860ac48fe09775a40ac61574042

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ipycalc-0.0.51-py3-none-any.whl
  • Upload date:
  • Size: 132.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for ipycalc-0.0.51-py3-none-any.whl
Algorithm Hash digest
SHA256 2732577a5c28298b1276f27ac71425d0a349ef3d2281d3a73793906072ddec15
MD5 9c6e4cdbf3b4b84599a48627fd13dc8f
BLAKE2b-256 d8b29e2bed776e8d337e13b8dc1edff3303b1cb9439ff0237c7b7d30ef28a4a7

See more details on using hashes here.

Supported by

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