From 527ca3425b088c2930fd29c354e69c41eaf0907b Mon Sep 17 00:00:00 2001 From: ctarnold <113149895+ctarnold@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:35:37 -0500 Subject: [PATCH 1/7] Update examples.ipynb Duplicating last block to then add a new example --- examples/examples.ipynb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/examples/examples.ipynb b/examples/examples.ipynb index dd1aaf8..6538faa 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -138,6 +138,34 @@ "greek" ] }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$$ \\displaystyle \\frac{-b + \\sqrt{b^{{2}} - {4}ac}}{{2}a} $$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# latexify.expression works similarly, but the result does not contain the signature.\n", + "@latexify.expression\n", + "def solve(a, b, c):\n", + " return (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)\n", + "\n", + "solve" + ] + }, { "cell_type": "code", "execution_count": 6, From 5519c503ea1a23000c697ba20acd965eca35efea Mon Sep 17 00:00:00 2001 From: ctarnold <113149895+ctarnold@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:37:23 -0500 Subject: [PATCH 2/7] Update examples.ipynb Adding example of printing to a .tex file in solve1, the duplicated solve function. --- examples/examples.ipynb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/examples.ipynb b/examples/examples.ipynb index 6538faa..633e792 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -186,12 +186,14 @@ } ], "source": [ - "# latexify.expression works similarly, but the result does not contain the signature.\n", + "# We can also print the output to a .tex file\n", "@latexify.expression\n", - "def solve(a, b, c):\n", + "def solve1(a, b, c):\n", " return (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)\n", "\n", - "solve" + "file1 = open('latexifyExample.tex', 'w')\n", + "file1.write(str(solve1))\n", + "file1.close()\n" ] } ], From 6e3fbd44b432643c278640969bb35fbb717966f4 Mon Sep 17 00:00:00 2001 From: ctarnold <113149895+ctarnold@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:40:09 -0500 Subject: [PATCH 3/7] Update examples.ipynb Changing output data in notebook under solve1 to explain to user the functionality of printing to the .tex file --- examples/examples.ipynb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/examples.ipynb b/examples/examples.ipynb index 633e792..22c3434 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -173,11 +173,14 @@ "outputs": [ { "data": { - "text/latex": [ + "text/plain": [ "$$ \\displaystyle \\frac{-b + \\sqrt{b^{{2}} - {4}ac}}{{2}a} $$" ], "text/plain": [ "" + ], + "text/plain": [ + "The above equation is sent to a new file, latexifyExample.txt" ] }, "execution_count": 6, From edc013da5d4789d96b3cc2a657804f0648365022 Mon Sep 17 00:00:00 2001 From: ctarnold <113149895+ctarnold@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:17:34 -0500 Subject: [PATCH 4/7] Update examples.ipynb Modifying print example to align with common python practice by @odashi 's recommendation. --- examples/examples.ipynb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/examples.ipynb b/examples/examples.ipynb index 22c3434..9199504 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -180,7 +180,7 @@ "" ], "text/plain": [ - "The above equation is sent to a new file, latexifyExample.txt" + "The above equation is sent to a new file, latexifyExample.tex" ] }, "execution_count": 6, @@ -194,9 +194,8 @@ "def solve1(a, b, c):\n", " return (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)\n", "\n", - "file1 = open('latexifyExample.tex', 'w')\n", - "file1.write(str(solve1))\n", - "file1.close()\n" + "with open('latexifyExample.tex', 'w') as fp: \n", + "\t print(solve1, file = fp) \n", ] } ], From a11164e537a30129d85566627cabb16637b30a20 Mon Sep 17 00:00:00 2001 From: ctarnold <113149895+ctarnold@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:19:50 -0500 Subject: [PATCH 5/7] Update examples.ipynb Fixing typo in JSON file representation of examples.ipynb --- examples/examples.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/examples.ipynb b/examples/examples.ipynb index 9199504..a51217d 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -195,7 +195,7 @@ " return (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)\n", "\n", "with open('latexifyExample.tex', 'w') as fp: \n", - "\t print(solve1, file = fp) \n", + "\t print(solve1, file = fp) \n" ] } ], From 4d06d3207df1c008630c55a7d33399661f2f6670 Mon Sep 17 00:00:00 2001 From: ctarnold <113149895+ctarnold@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:20:55 -0500 Subject: [PATCH 6/7] Update examples.ipynb Previous JSON file worked, fixing display of the code by removing \t from the added printing example. --- examples/examples.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/examples.ipynb b/examples/examples.ipynb index a51217d..facf5e1 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -195,7 +195,7 @@ " return (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)\n", "\n", "with open('latexifyExample.tex', 'w') as fp: \n", - "\t print(solve1, file = fp) \n" + " print(solve1, file = fp) \n" ] } ], From a680a234d0d82ef6a09fc9ef3ea43760d4ffb9c6 Mon Sep 17 00:00:00 2001 From: ctarnold <113149895+ctarnold@users.noreply.github.com> Date: Thu, 7 Dec 2023 10:29:43 -0500 Subject: [PATCH 7/7] Update examples.ipynb Removing plain text from output field in JSON description of the .tex output example. --- examples/examples.ipynb | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/examples.ipynb b/examples/examples.ipynb index facf5e1..86a71d7 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -178,9 +178,6 @@ ], "text/plain": [ "" - ], - "text/plain": [ - "The above equation is sent to a new file, latexifyExample.tex" ] }, "execution_count": 6,