# 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
Here's a simple example that calculates the flexural strength of a concrete beam:
![Example](/Example.png)
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$`).
* 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/JWock82/ipycalc.git",
"name": "ipycalc",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "D. Craig Brinck, PE, SE",
"author_email": "Building.Code@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/e5/a5/89065b5eb7c4f47a4e03497eb756786ff55e0f6cf12033545b73a03cd6dc/ipycalc-0.0.63.tar.gz",
"platform": null,
"description": "# ipycalc\nSimple Engineering Calculations in Python\n\nTurn the contents of a Jupyter cell into a formatted calculation by following the steps below:\n\n1. Install `ipycalc` using `pip install ipycalc`\n2. Use `from ipycalc import calc` to bring `ipycalc` into your notebook's namespace.\n3. Use `%%calc` as the first line of a cell to indicate that you want to run `ipycalc` on the contents of a cell.\n\nThe basic calculation syntax is:\n\nVariable Description: `variable_name` = `python_expression` -> `result_decimal_places`*`result_unit` # Reference Text\n\nHere's a simple example that calculates the flexural strength of a concrete beam:\n\n![Example](/Example.png)\n\nKey components of the `ipycalc` syntax are:\n\n* `:` (required) The description must come before this character.\n* `=` (optional) Used to assign a python expression to a variable name. Omit this if you simply want to reprint a previously defined variable.\n* `->` (optional) Separates the python expression from the results formatting rules.\n* `*` (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.\n* `#` (optional) Indicates reference text to the side of the calculation - handy for equation references or code references.\n\nHere are a few useful things to keep in mind when using `ipycalc`:\n\n* Subscripts can be added by using the `_` character to indicate the start of a subscript.\n* 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$`).\n* To stack fractions place the numerator and denominater in parentheses: (num)/(denom) yields $\\dfrac{num}{denom}$.\n* `if` statements and `else` statements are available using python's inline `if` statement (terniary) notation.\n* Square roots can be displayed using `sqrt`.\n* Prime characters can be displayed using `^prime`.\n* 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.\n* `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\"\n\nIPycalc 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.\n",
"bugtrack_url": null,
"license": null,
"summary": "Clean looking engineering calculations for IPython",
"version": "0.0.63",
"project_urls": {
"Homepage": "https://github.com/JWock82/ipycalc.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "701a506d0e4708f3f9cc3cec7d4f726ee6d15c0203172c0d2150d46e0be734c5",
"md5": "73fdabbbc048584cf6c0730a614b8dab",
"sha256": "5509de641c795c1011cccdbe95174c198ebe8e28e3a7b430a9eeb827251ab5e0"
},
"downloads": -1,
"filename": "ipycalc-0.0.63-py3-none-any.whl",
"has_sig": false,
"md5_digest": "73fdabbbc048584cf6c0730a614b8dab",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 132750,
"upload_time": "2024-12-11T04:17:11",
"upload_time_iso_8601": "2024-12-11T04:17:11.143469Z",
"url": "https://files.pythonhosted.org/packages/70/1a/506d0e4708f3f9cc3cec7d4f726ee6d15c0203172c0d2150d46e0be734c5/ipycalc-0.0.63-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e5a589065b5eb7c4f47a4e03497eb756786ff55e0f6cf12033545b73a03cd6dc",
"md5": "48913747cf164edb5050715e01f35052",
"sha256": "becf884f9850f5e88d843f31dfb9c60fb808f0443e576164f23036f622533c6b"
},
"downloads": -1,
"filename": "ipycalc-0.0.63.tar.gz",
"has_sig": false,
"md5_digest": "48913747cf164edb5050715e01f35052",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 124847,
"upload_time": "2024-12-11T04:17:12",
"upload_time_iso_8601": "2024-12-11T04:17:12.474821Z",
"url": "https://files.pythonhosted.org/packages/e5/a5/89065b5eb7c4f47a4e03497eb756786ff55e0f6cf12033545b73a03cd6dc/ipycalc-0.0.63.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-11 04:17:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "JWock82",
"github_project": "ipycalc",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "IPython",
"specs": []
},
{
"name": "pint",
"specs": []
},
{
"name": "jupyterlab-mathjax3",
"specs": []
}
],
"lcname": "ipycalc"
}