create render
This commit is contained in:
135
render.ipynb
Normal file
135
render.ipynb
Normal file
@@ -0,0 +1,135 @@
|
||||
{
|
||||
"metadata": {
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.7-final"
|
||||
},
|
||||
"orig_nbformat": 2,
|
||||
"kernelspec": {
|
||||
"name": "python3",
|
||||
"display_name": "Python 3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2,
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import handcalcs.render"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"text/plain": "<IPython.core.display.Latex object>",
|
||||
"text/latex": "\\[\n\\begin{aligned}\na &= 2\\;\n\\\\[10pt]\nb &= 3\\;\n\\\\[10pt]\nc &= 2 \\cdot a + \\frac{ b }{ 3 } = 2 \\cdot 2 + \\frac{ 3 }{ 3 } &= 5.0\n\\end{aligned}\n\\]"
|
||||
},
|
||||
"metadata": {}
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%render\n",
|
||||
"a = 2\n",
|
||||
"b = 3\n",
|
||||
"c = 2*a + b/3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from math import sqrt, pi"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"name": "stdout",
|
||||
"text": "\\[\n\\begin{aligned}\na &= \\frac{ 2 }{ 3 } \\cdot \\sqrt{ \\pi } = \\frac{ 2 }{ 3 } \\cdot \\sqrt{ 3.142 } &= 1.182\n\\end{aligned}\n\\]\n"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%tex\n",
|
||||
"a = 2 / 3 * sqrt(pi)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from handcalcs.decorator import handcalc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"@handcalc()\n",
|
||||
"def my_calc(x, y, z):\n",
|
||||
" a = 2*x / y\n",
|
||||
" b = 3*a\n",
|
||||
" c = (a + b) / z\n",
|
||||
" return locals()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "display_data",
|
||||
"data": {
|
||||
"text/plain": "<IPython.core.display.Latex object>",
|
||||
"text/latex": "\\[\n\\begin{aligned}\nX &= ('\\n\\\\begin{aligned}\\na &&= 2 \\\\cdot \\\\frac{ x }{ y } &= 2 \\\\cdot \\\\frac{ 4 }{ 5 } &&= 1.6\\n\\\\\\\\[10pt]\\nb &&= 3 \\\\cdot a &= 3 \\\\cdot 1.6 &&= 4.8\\n\\\\\\\\[10pt]\\nc &&= \\\\frac{ a + b }{ z } &= \\\\frac{ 1.6 + 4.8 }{ 6 } &&= 1.067\\n\\\\end{aligned}\\n', {'x': 4, 'y': 5, 'z': 6, 'a': 1.6, 'b': 4.800000000000001, 'c': 1.0666666666666667})\\;\n\\end{aligned}\n\\]"
|
||||
},
|
||||
"metadata": {}
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%render\n",
|
||||
"X=my_calc(4,5,6)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user