From 474a5330da8c5b7619ef22938c2446be643d66a1 Mon Sep 17 00:00:00 2001 From: Nick Murphy Date: Thu, 25 Jul 2024 21:32:02 -0400 Subject: [PATCH] Clean up particles/formulary notebook --- ...asmapy-particles-formulary-completed.ipynb | 604 ++++++------------ 1 file changed, 193 insertions(+), 411 deletions(-) diff --git a/notebooks/plasmapy-particles-formulary-completed.ipynb b/notebooks/plasmapy-particles-formulary-completed.ipynb index 8d26d21..a5c6e68 100644 --- a/notebooks/plasmapy-particles-formulary-completed.ipynb +++ b/notebooks/plasmapy-particles-formulary-completed.ipynb @@ -16,7 +16,6 @@ "[`astropy.units`]: https://docs.astropy.org/en/stable/units/index.html\n", "[`plasmapy.particles`]: https://docs.plasmapy.org/en/stable/particles/index.html\n", "[`plasmapy.formulary`]: https://docs.plasmapy.org/en/stable/formulary/index.html\n", - "[`plasmapy.dispersion`]: https://docs.plasmapy.org/en/stable/dispersion/index.html\n", "\n", "Thank you for coming to this interactive tutorial. 🌱 We are excited for you to be here! 😺\n", "\n", @@ -29,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "fa326226", "metadata": {}, "outputs": [], @@ -74,10 +73,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "8437650a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$60 \\; \\mathrm{km}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "60 * u.km" ] @@ -1109,14 +1122,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "1f317f40", "metadata": {}, "outputs": [], "source": [ "n = 1 * u.cm ** -3\n", "B = 5 * u.nT\n", - "T = 10 ** 4.5 * u.K" + "T = 30000 * u.K" ] }, { @@ -1173,12 +1186,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "96fee1ef", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'B' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[15], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m gyroradius(B\u001b[38;5;241m=\u001b[39m\u001b[43mB\u001b[49m, particle\u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mp+\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124me-\u001b[39m\u001b[38;5;124m\"\u001b[39m], T\u001b[38;5;241m=\u001b[39mT)\u001b[38;5;241m.\u001b[39mto(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkm\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'B' is not defined" + ] + } + ], "source": [ - "gyroradius(B=B, particle=[\"e-\", \"p+\"], T=T).to(\"km\")" + "gyroradius(B=B, particle=[\"p+\", \"e-\"], T=T).to(\"km\")" ] }, { @@ -1202,7 +1227,7 @@ "id": "fc1a183f", "metadata": {}, "source": [ - "We can also calculate some of the fundamental frequencies associated with magnetospheric plasma. " + "We can calculate some of the fundamental frequencies associated with magnetospheric plasma. " ] }, { @@ -1243,7 +1268,6 @@ "[`lower_hybrid_frequency`]: https://docs.plasmapy.org/en/stable/api/plasmapy.formulary.frequencies.lower_hybrid_frequency.html#lower-hybrid-frequency\n", "[`plasmapy.formulary`]: https://docs.plasmapy.org/en/stable/formulary/index.html\n", "\n", - "\n", "Most of the functions in [`plasmapy.formulary`] have descriptions of the plasma parameters that include the formula and physical interpretation. If we ever forget what the [`lower_hybrid_frequency`] represents, we can check out its documentation page! " ] }, @@ -1260,7 +1284,9 @@ "id": "aac532e4-5249-458b-bf4b-aad05f36fc74", "metadata": {}, "source": [ - "Now that we've gone through how to use `plasmapy.particles` and `plasmapy.formulary`, we'll move on to the process for adding a function to `plasmapy.formulary`. Before that, we need to introduce two capabilities for the Python language:\n", + "[`plasmapy.formulary`]: https://docs.plasmapy.org/en/stable/formulary/index.html\n", + "\n", + "Now that we've gone through how to use [`plasmapy.particles`] and [`plasmapy.formulary`], we'll move on to the process for adding a function to [`plasmapy.formulary`]. Before that, we need to introduce two capabilities for the Python language:\n", "\n", " - Type hint annotations\n", " - Decorators" @@ -1284,18 +1310,18 @@ "\n", "In a _statically typed language_, variable types are explicitly declared. If `s` is declared to be a string, then `s` will always be a string. Type errors are found when code is _compiled_.\n", "\n", - "Python is a [_dynamically typed language_]. Variable types are determined at runtime rather than at compile time, and it's possible for variables to even change types!\n", + "Python is a [_dynamically typed language_]. Variable types are determined at runtime rather than at compile time, and it's possible for variables to even change types! \n", "\n", - "⚖️ As always, there are tradeoffs. Dynamically typed languages offer _flexibility_, but at the cost of _reduced type safety_.\n", + "There are tradeoffs! ⚖️ Dynamically are _more flexible_, but at the cost of _reduced type safety_.\n", "\n", "[Type hint annotations] provide a middle ground between statically vs. dynamically typed languages. \n", "\n", - "Let's define a variable called `name` and provide it with a type hint annotation that says the variable should be a a `str`." + "🏷 Let's define a variable called `name` and provide it with a type hint annotation that says the variable should be a a `str`." ] }, { "cell_type": "code", - "execution_count": 193, + "execution_count": 3, "id": "cd171e0c-7233-479d-9e3d-18d5b71e7c3e", "metadata": {}, "outputs": [], @@ -1315,7 +1341,7 @@ }, { "cell_type": "code", - "execution_count": 180, + "execution_count": 4, "id": "8733b1c7-1d85-463a-9d63-718379032fb0", "metadata": {}, "outputs": [], @@ -1335,7 +1361,7 @@ }, { "cell_type": "code", - "execution_count": 181, + "execution_count": 5, "id": "24b7a377-0370-48ba-a3f6-a64181508a11", "metadata": {}, "outputs": [], @@ -1353,7 +1379,7 @@ }, { "cell_type": "code", - "execution_count": 182, + "execution_count": 6, "id": "1c74d5de-3a75-4ea8-bac9-ac5dcb94f9e6", "metadata": {}, "outputs": [], @@ -1375,7 +1401,7 @@ }, { "cell_type": "code", - "execution_count": 183, + "execution_count": 7, "id": "9190e68f-88d0-4746-93e0-5527f7ea014f", "metadata": {}, "outputs": [], @@ -1394,7 +1420,7 @@ }, { "cell_type": "code", - "execution_count": 184, + "execution_count": 8, "id": "3607d300-7ede-4a6c-a4bd-464877c2ea6a", "metadata": {}, "outputs": [], @@ -1421,7 +1447,7 @@ }, { "cell_type": "code", - "execution_count": 194, + "execution_count": 9, "id": "e8d7e33f-9dd8-4351-a498-cd4ced4ce68c", "metadata": {}, "outputs": [], @@ -1438,7 +1464,7 @@ }, { "cell_type": "code", - "execution_count": 195, + "execution_count": 10, "id": "ef09dad1-3d99-4d36-ae81-795433d25711", "metadata": {}, "outputs": [ @@ -1456,7 +1482,7 @@ }, { "cell_type": "code", - "execution_count": 196, + "execution_count": 11, "id": "ac56c46b-06d5-4296-b9c6-40697f25be11", "metadata": {}, "outputs": [ @@ -1482,7 +1508,7 @@ }, { "cell_type": "code", - "execution_count": 203, + "execution_count": 12, "id": "db188ae4-5ff7-48ff-b335-6d0bbfbe8b2f", "metadata": {}, "outputs": [], @@ -1493,7 +1519,7 @@ }, { "cell_type": "code", - "execution_count": 204, + "execution_count": null, "id": "3cc6dc5c-37f8-45a4-813c-5576b2e326f7", "metadata": {}, "outputs": [], @@ -1503,21 +1529,10 @@ }, { "cell_type": "code", - "execution_count": 205, + "execution_count": null, "id": "2137ef7e-f0ac-4c7a-8a8b-596c98e2402d", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "5" - ] - }, - "execution_count": 205, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "apply_function(max, array)" ] @@ -1536,10 +1551,22 @@ }, { "cell_type": "code", - "execution_count": 212, + "execution_count": 18, "id": "5095d1d9-a6de-401d-994c-83ffd16271c1", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'Callable' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[18], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdecorator\u001b[39m(function: \u001b[43mCallable\u001b[49m):\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdecorated_function\u001b[39m() \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mBefore calling the function.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'Callable' is not defined" + ] + } + ], "source": [ "def decorator(function: Callable):\n", " \n", @@ -1556,7 +1583,7 @@ }, { "cell_type": "code", - "execution_count": 222, + "execution_count": 19, "id": "537d6027-fefc-4117-8c37-44555d38c49c", "metadata": {}, "outputs": [], @@ -1575,17 +1602,29 @@ }, { "cell_type": "code", - "execution_count": 223, + "execution_count": 20, "id": "a5c89a55-260b-46de-bb30-6023e3f90c2c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'decorator' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[20], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m modified_function \u001b[38;5;241m=\u001b[39m \u001b[43mdecorator\u001b[49m(example_function)\n", + "\u001b[0;31mNameError\u001b[0m: name 'decorator' is not defined" + ] + } + ], "source": [ "modified_function = decorator(example_function)" ] }, { "cell_type": "code", - "execution_count": 224, + "execution_count": 21, "id": "d15b8474-7cc1-4e0f-83cc-2f56d2c387ec", "metadata": {}, "outputs": [ @@ -1611,10 +1650,22 @@ }, { "cell_type": "code", - "execution_count": 225, + "execution_count": 22, "id": "2f08b76f-d26b-4124-b453-a04d210366ba", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'decorator' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[22], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;129m@decorator\u001b[39m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21manother_function\u001b[39m():\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInside function2!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'decorator' is not defined" + ] + } + ], "source": [ "@decorator\n", "def another_function():\n", @@ -1623,17 +1674,19 @@ }, { "cell_type": "code", - "execution_count": 226, + "execution_count": 23, "id": "b8f5eec3-136c-4ca8-876f-2a02362a32d1", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "Before calling the function.\n", - "Inside function2!\n", - "After calling the function.\n" + "ename": "NameError", + "evalue": "name 'function2' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[23], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mfunction2\u001b[49m()\n", + "\u001b[0;31mNameError\u001b[0m: name 'function2' is not defined" ] } ], @@ -1659,7 +1712,7 @@ }, { "cell_type": "code", - "execution_count": 227, + "execution_count": null, "id": "27b42156-f06e-484d-ae8c-767d8267fb4d", "metadata": {}, "outputs": [], @@ -1671,66 +1724,20 @@ }, { "cell_type": "code", - "execution_count": 228, + "execution_count": null, "id": "e7ddee57-66fb-4c28-9cd9-30fddd7d0b0b", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Calculating Fibonacci number for n = 2\n", - "Calculating Fibonacci number for n = 1\n", - "Calculating Fibonacci number for n = 0\n" - ] - }, - { - "data": { - "text/plain": [ - "1" - ] - }, - "execution_count": 228, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "fibonacci(2)" ] }, { "cell_type": "code", - "execution_count": 229, + "execution_count": null, "id": "fca36cc4-9349-4433-b13c-e2e2a1e66c23", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Calculating Fibonacci number for n = 4\n", - "Calculating Fibonacci number for n = 3\n", - "Calculating Fibonacci number for n = 2\n", - "Calculating Fibonacci number for n = 1\n", - "Calculating Fibonacci number for n = 0\n", - "Calculating Fibonacci number for n = 1\n", - "Calculating Fibonacci number for n = 2\n", - "Calculating Fibonacci number for n = 1\n", - "Calculating Fibonacci number for n = 0\n" - ] - }, - { - "data": { - "text/plain": [ - "3" - ] - }, - "execution_count": 229, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "fibonacci(4)" ] @@ -1747,7 +1754,7 @@ }, { "cell_type": "code", - "execution_count": 230, + "execution_count": null, "id": "bb8147dc-165d-48e7-a5ae-a325410b2d22", "metadata": {}, "outputs": [], @@ -1762,42 +1769,20 @@ }, { "cell_type": "code", - "execution_count": 231, + "execution_count": null, "id": "c861945a-c8e9-43d9-9dfe-00bde320129c", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "1" - ] - }, - "execution_count": 231, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "fibonacci_decorated(2)" ] }, { "cell_type": "code", - "execution_count": 232, + "execution_count": null, "id": "01f5996f-5218-45c8-9fa1-c97755600a3e", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "5" - ] - }, - "execution_count": 232, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "fibonacci_decorated(5)" ] @@ -1812,21 +1797,10 @@ }, { "cell_type": "code", - "execution_count": 191, + "execution_count": null, "id": "fee0a698-e73e-4f69-a690-68daa39a043c", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "5" - ] - }, - "execution_count": 191, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "fibonacci_decorated(5)" ] @@ -1844,9 +1818,12 @@ "id": "227f37ab-5f1b-4a98-a34f-88ca38afce7c", "metadata": {}, "source": [ - " [`@particle_input`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.decorators.particle_input.html\n", - " [`@validate_quantities`]: https://docs.plasmapy.org/en/stable/api/plasmapy.utils.decorators.validators.validate_quantities.html#validate-quantities\n", - " [`@check_relativistic`]: https://docs.plasmapy.org/en/stable/api/plasmapy.utils.decorators.checks.check_relativistic.html#check-relativistic\n", + "[`@particle_input`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.decorators.particle_input.html\n", + "[`@validate_quantities`]: https://docs.plasmapy.org/en/stable/api/plasmapy.utils.decorators.validators.validate_quantities.html#validate-quantities\n", + "[`@check_relativistic`]: https://docs.plasmapy.org/en/stable/api/plasmapy.utils.decorators.checks.check_relativistic.html#check-relativistic\n", + "[`astropy.units`]: https://docs.astropy.org/en/stable/units/index.html\n", + "[`plasmapy.particles`]: https://docs.plasmapy.org/en/stable/particles/index.html\n", + "[`plasmapy.formulary`]: https://docs.plasmapy.org/en/stable/formulary/index.html\n", "\n", "PlasmaPy has three decorators that help us with writing formulary functions.\n", "\n", @@ -1859,7 +1836,7 @@ }, { "cell_type": "code", - "execution_count": 362, + "execution_count": null, "id": "f2080cc3-2567-4ee1-87c4-a93aea165c47", "metadata": {}, "outputs": [], @@ -1884,13 +1861,14 @@ "metadata": {}, "source": [ "[`@check_relativistic`]: https://docs.plasmapy.org/en/stable/api/plasmapy.utils.decorators.checks.check_relativistic.html#check-relativistic\n", + "[`plasmapy.formulary`]: https://docs.plasmapy.org/en/stable/formulary/index.html\n", "\n", - "Many functions that return velocities in `plasmapy.formulary` assume that relativistic velocities are unimportant. To check for this, we can use the [`@check_relativistic`] decorator. " + "Many functions that return velocities in [`plasmapy.formulary`] assume that relativistic velocities are unimportant. To check for this, we can use the [`@check_relativistic`] decorator. " ] }, { "cell_type": "code", - "execution_count": 377, + "execution_count": null, "id": "09dcca0c-4f88-4788-a901-146238c556c4", "metadata": {}, "outputs": [], @@ -1910,24 +1888,10 @@ }, { "cell_type": "code", - "execution_count": 380, + "execution_count": null, "id": "ed16449c-39e3-4422-9a76-7bbceae478ce", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$2.9979246 \\times 10^{8} \\; \\mathrm{\\frac{m}{s}}$" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 380, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "speed(299792457 * u.m, 1 * u.s)" ] @@ -1942,24 +1906,10 @@ }, { "cell_type": "code", - "execution_count": 379, + "execution_count": null, "id": "a24084ea-f588-44c9-b945-401717acd2ec", "metadata": {}, - "outputs": [ - { - "ename": "RelativityError", - "evalue": "speed is yielding a velocity that is 1.0 times the speed of light.", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mRelativityError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[379], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mspeed\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m299792459\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mu\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mm\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mu\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43ms\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/Projects/PlasmaPy/src/plasmapy/utils/decorators/checks.py:1326\u001b[0m, in \u001b[0;36mcheck_relativistic..decorator..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 1322\u001b[0m \u001b[38;5;129m@preserve_signature\u001b[39m\n\u001b[1;32m 1323\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(f)\n\u001b[1;32m 1324\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 1325\u001b[0m return_ \u001b[38;5;241m=\u001b[39m f(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m-> 1326\u001b[0m \u001b[43m_check_relativistic\u001b[49m\u001b[43m(\u001b[49m\u001b[43mreturn_\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mf\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;18;43m__name__\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbetafrac\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbetafrac\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1327\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m return_\n", - "File \u001b[0;32m/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/Projects/PlasmaPy/src/plasmapy/utils/decorators/checks.py:1400\u001b[0m, in \u001b[0;36m_check_relativistic\u001b[0;34m(V, funcname, betafrac)\u001b[0m\n\u001b[1;32m 1398\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m RelativityError(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfuncname\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m is yielding an infinite velocity.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 1399\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m beta \u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[0;32m-> 1400\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m RelativityError(\n\u001b[1;32m 1401\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfuncname\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m is yielding a velocity that is \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mround\u001b[39m(beta,\u001b[38;5;250m \u001b[39m\u001b[38;5;241m3\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1402\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtimes the speed of light.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1403\u001b[0m )\n\u001b[1;32m 1404\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m beta \u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m betafrac:\n\u001b[1;32m 1405\u001b[0m warnings\u001b[38;5;241m.\u001b[39mwarn(\n\u001b[1;32m 1406\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfuncname\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m is yielding a velocity that is \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1407\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mround\u001b[39m(beta\u001b[38;5;250m \u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;250m \u001b[39m\u001b[38;5;241m100\u001b[39m,\u001b[38;5;250m \u001b[39m\u001b[38;5;241m3\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m% of the speed of \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1408\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlight. Relativistic effects may be important.\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 1409\u001b[0m RelativityWarning,\n\u001b[1;32m 1410\u001b[0m )\n", - "\u001b[0;31mRelativityError\u001b[0m: speed is yielding a velocity that is 1.0 times the speed of light." - ] - } - ], + "outputs": [], "source": [ "speed(299792459 * u.m, 1 * u.s)" ] @@ -1988,7 +1938,7 @@ }, { "cell_type": "code", - "execution_count": 286, + "execution_count": null, "id": "87b09a20-3ea4-4581-a095-f32b67437bb9", "metadata": {}, "outputs": [], @@ -1999,24 +1949,10 @@ }, { "cell_type": "code", - "execution_count": 287, + "execution_count": null, "id": "fa8103a8-a0ac-475c-bb75-ad4b0a7c3066", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$397887.36 \\; \\mathrm{\\frac{A^{2}\\,T^{2}}{N}}$" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 287, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "magnetic_pressure(1 * u.T)" ] @@ -2031,24 +1967,10 @@ }, { "cell_type": "code", - "execution_count": 289, + "execution_count": null, "id": "eb4fd6db-71d6-4427-9c21-0cef9706d699", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$397887.36 \\; \\mathrm{\\frac{A^{2}\\,byte^{2}}{N}}$" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 289, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "magnetic_pressure(1 * u.B)" ] @@ -2065,7 +1987,7 @@ }, { "cell_type": "code", - "execution_count": 290, + "execution_count": null, "id": "bc96b8eb-20e6-4812-921d-cfe4f3935a7a", "metadata": {}, "outputs": [], @@ -2077,74 +1999,32 @@ }, { "cell_type": "code", - "execution_count": 291, + "execution_count": null, "id": "450c05cc-41bd-4d41-bb54-ddc67ac8e421", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$397887.36 \\; \\mathrm{Pa}$" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 291, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "magnetic_pressure(1 * u.T)" ] }, { "cell_type": "code", - "execution_count": 292, + "execution_count": null, "id": "aace6447-013b-4030-90bd-ec725a8ba9a4", "metadata": { "scrolled": true }, - "outputs": [ - { - "ename": "UnitTypeError", - "evalue": "The argument 'B' to function magnetic_pressure() should be an astropy Quantity with the following unit: T", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mUnitTypeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[292], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmagnetic_pressure\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mu\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mB\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/Projects/PlasmaPy/src/plasmapy/utils/decorators/validators.py:199\u001b[0m, in \u001b[0;36mValidateQuantities.__call__..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 196\u001b[0m \u001b[38;5;28;01mcontinue\u001b[39;00m\n\u001b[1;32m 198\u001b[0m \u001b[38;5;66;03m# validate argument & update for conversion\u001b[39;00m\n\u001b[0;32m--> 199\u001b[0m arg \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_validate_quantity\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 200\u001b[0m \u001b[43m \u001b[49m\u001b[43mbound_args\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43marguments\u001b[49m\u001b[43m[\u001b[49m\u001b[43marg_name\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43marg_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalidations\u001b[49m\u001b[43m[\u001b[49m\u001b[43marg_name\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 201\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 202\u001b[0m bound_args\u001b[38;5;241m.\u001b[39marguments[arg_name] \u001b[38;5;241m=\u001b[39m arg\n\u001b[1;32m 204\u001b[0m \u001b[38;5;66;03m# call function\u001b[39;00m\n", - "File \u001b[0;32m/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/Projects/PlasmaPy/src/plasmapy/utils/decorators/validators.py:376\u001b[0m, in \u001b[0;36mValidateQuantities._validate_quantity\u001b[0;34m(self, arg, arg_name, arg_validations)\u001b[0m\n\u001b[1;32m 374\u001b[0m arg \u001b[38;5;241m=\u001b[39m arg\u001b[38;5;241m.\u001b[39mto(unit, equivalencies\u001b[38;5;241m=\u001b[39mequiv)\n\u001b[1;32m 375\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m err \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 376\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m err\n\u001b[1;32m 378\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_value(arg, arg_name, arg_validations)\n\u001b[1;32m 380\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m arg\n", - "\u001b[0;31mUnitTypeError\u001b[0m: The argument 'B' to function magnetic_pressure() should be an astropy Quantity with the following unit: T" - ] - } - ], + "outputs": [], "source": [ "magnetic_pressure(1 * u.B)" ] }, { "cell_type": "code", - "execution_count": 250, + "execution_count": null, "id": "1f64a511-5882-4f6d-8ac6-22dadf422071", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$397887.36 \\; \\mathrm{Pa}$" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 250, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "magnetic_pressure(1)" ] @@ -2164,7 +2044,7 @@ }, { "cell_type": "code", - "execution_count": 350, + "execution_count": null, "id": "b47f2360-1037-4ded-a71e-ea94cd54f757", "metadata": {}, "outputs": [], @@ -2178,24 +2058,10 @@ }, { "cell_type": "code", - "execution_count": 351, + "execution_count": null, "id": "e3f27c37-01b1-4a36-847a-124d752e1342", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$11604.518 \\; \\mathrm{K}$" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 351, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "get_temperature(1 * u.eV)" ] @@ -2230,12 +2096,12 @@ "\n", "Plasma parameters often depend on particle properties. If we want to calculate a gyroradius, then we need a particle's mass and charge. \n", "\n", - "Early in the project, we often wrote functions like this:" + "Early on, we wrote functions like this:" ] }, { "cell_type": "code", - "execution_count": 381, + "execution_count": 13, "id": "b002c4f9-bbdf-4a26-8cae-0d2690d25749", "metadata": {}, "outputs": [], @@ -2247,7 +2113,7 @@ }, { "cell_type": "code", - "execution_count": 382, + "execution_count": 14, "id": "10b511e8-9691-4a11-a6d7-c0bf44dc2d1e", "metadata": {}, "outputs": [ @@ -2260,7 +2126,7 @@ "" ] }, - "execution_count": 382, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -2274,12 +2140,14 @@ "id": "123e5696-8cf5-44a5-a8e1-abe340b6856d", "metadata": {}, "source": [ - "That wasn't that bad. But if we wanted to make a function compatible with `ParticleList` objects too, then it started to become a mess." + "[`ParticleList`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.particle_collections.ParticleList.html\n", + "\n", + "That wasn't that bad. But if we wanted to make a function compatible with [`ParticleList`] objects too, then it started to become a mess." ] }, { "cell_type": "code", - "execution_count": 391, + "execution_count": null, "id": "dead2c8f-d7af-450e-acea-f7eaf2462da1", "metadata": {}, "outputs": [], @@ -2296,24 +2164,10 @@ }, { "cell_type": "code", - "execution_count": 392, + "execution_count": null, "id": "bced4c71-7a29-470b-a54e-d34f6097102a", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$[1.6726219 \\times 10^{-27},~9.1093837 \\times 10^{-31}] \\; \\mathrm{kg}$" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 392, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "get_particle_mass([\"p+\", \"e-\"])" ] @@ -2325,13 +2179,17 @@ "source": [ "[**`@particle_input`**]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.decorators.particle_input.html\n", "[`ParticleLike`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.particle_class.ParticleLike.html#particlelike\n", + "[`ParticleList`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.particle_collections.ParticleList.html\n", + "[`CustomParticle`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.particle_class.CustomParticle.html\n", + "[`Particle`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.particle_class.Particle.html\n", + "\n", "\n", - "The [**`@particle_input`**] decorator transforms arguments annotated with [`ParticleLike`] into a `Particle`, `CustomParticle`, or `ParticleList`. This transformation occurs _before_ the argument gets passed into the decorated function, so we end up with cleaner code!" + "The [**`@particle_input`**] decorator transforms arguments annotated with [`ParticleLike`] into a [`Particle`], [`CustomParticle`], or [`ParticleList`]. This transformation occurs _before_ the argument gets passed into the decorated function, so we end up with cleaner code!" ] }, { "cell_type": "code", - "execution_count": 402, + "execution_count": null, "id": "f1955b73-9714-4280-8aeb-2e6cb3b855b3", "metadata": {}, "outputs": [], @@ -2351,21 +2209,10 @@ }, { "cell_type": "code", - "execution_count": 403, + "execution_count": null, "id": "1fa4d5f6-0670-4c38-9f84-2af55f1f5a01", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Particle(\"p+\")" - ] - }, - "execution_count": 403, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "make_particle(\"p+\")" ] @@ -2375,14 +2222,18 @@ "id": "eb07e7af-52db-4630-afdf-55dd38fa3f67", "metadata": {}, "source": [ - "The argument got converted into a `Particle` object by `@particle_input`.\n", + "[`Particle`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.particle_class.Particle.html\n", + "[`@particle_input`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.decorators.particle_input.html\n", + "\n", + "\n", + "The argument got converted into a [`Particle`] object by [`@particle_input`].\n", "\n", "If we add `Z` and `mass_numb` as parameters, they'll get incorporated into the particle." ] }, { "cell_type": "code", - "execution_count": 412, + "execution_count": null, "id": "b8dc7186-2f24-40f1-af6f-0aea0f6266d5", "metadata": {}, "outputs": [], @@ -2394,21 +2245,10 @@ }, { "cell_type": "code", - "execution_count": 413, + "execution_count": null, "id": "79d4951b-bd64-465f-ab8d-2204a1dba965", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Particle(\"He-4 2+\")" - ] - }, - "execution_count": 413, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "make_particle(\"He\", Z=2, mass_numb=4)" ] @@ -2418,12 +2258,14 @@ "id": "081c1b64-ebc4-4fe0-b76f-a0d36c5faa33", "metadata": {}, "source": [ - "If we name the parameter `element`, `ion`, or `isotope`, then `@particle_input` will make sure that the particle matches that identity. " + "[`@particle_input`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.decorators.particle_input.html\n", + "\n", + "If we name the parameter `element`, `ion`, or `isotope`, then [`@particle_input`] will make sure that the particle matches that identity. " ] }, { "cell_type": "code", - "execution_count": 416, + "execution_count": null, "id": "bba411ee-8825-4056-8fcb-4860171c1cb2", "metadata": {}, "outputs": [], @@ -2435,47 +2277,22 @@ }, { "cell_type": "code", - "execution_count": 417, + "execution_count": null, "id": "4438edbb-ae2e-4733-a7c9-45e59aa4c3e9", "metadata": {}, - "outputs": [ - { - "ename": "InvalidIsotopeError", - "evalue": "The argument isotope = Particle(\"Fe\") to mass_number does not correspond to a valid isotope.", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mInvalidIsotopeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[417], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmass_number\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mFe\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/Projects/PlasmaPy/src/plasmapy/particles/decorators.py:990\u001b[0m, in \u001b[0;36mparticle_input..wrapper\u001b[0;34m(callable__, instance, args, kwargs)\u001b[0m\n\u001b[1;32m 983\u001b[0m \u001b[38;5;129m@wrapt\u001b[39m\u001b[38;5;241m.\u001b[39mdecorator\n\u001b[1;32m 984\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\n\u001b[1;32m 985\u001b[0m callable__: Callable[\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m, Any],\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 988\u001b[0m kwargs: MutableMapping[\u001b[38;5;28mstr\u001b[39m, Any],\n\u001b[1;32m 989\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Callable[\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m, Any]:\n\u001b[0;32m--> 990\u001b[0m bound_arguments \u001b[38;5;241m=\u001b[39m \u001b[43mparticle_validator\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprocess_arguments\u001b[49m\u001b[43m(\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 991\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m callable__( \u001b[38;5;66;03m# type: ignore[no-any-return]\u001b[39;00m\n\u001b[1;32m 992\u001b[0m \u001b[38;5;241m*\u001b[39mbound_arguments\u001b[38;5;241m.\u001b[39margs,\n\u001b[1;32m 993\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mbound_arguments\u001b[38;5;241m.\u001b[39mkwargs,\n\u001b[1;32m 994\u001b[0m )\n", - "File \u001b[0;32m/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/Projects/PlasmaPy/src/plasmapy/particles/decorators.py:673\u001b[0m, in \u001b[0;36m_ParticleInput.process_arguments\u001b[0;34m(self, args, kwargs, instance)\u001b[0m\n\u001b[1;32m 668\u001b[0m mass_numb \u001b[38;5;241m=\u001b[39m bound_arguments\u001b[38;5;241m.\u001b[39marguments\u001b[38;5;241m.\u001b[39mpop(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmass_numb\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[1;32m 670\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mperform_pre_validations(Z, mass_numb)\n\u001b[1;32m 672\u001b[0m processed_kwargs \u001b[38;5;241m=\u001b[39m {\n\u001b[0;32m--> 673\u001b[0m parameter: \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprocess_argument\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparameter\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43margument\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mZ\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmass_numb\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 674\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m parameter, argument \u001b[38;5;129;01min\u001b[39;00m bound_arguments\u001b[38;5;241m.\u001b[39marguments\u001b[38;5;241m.\u001b[39mitems()\n\u001b[1;32m 675\u001b[0m }\n\u001b[1;32m 677\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m parameter \u001b[38;5;129;01min\u001b[39;00m processed_kwargs:\n\u001b[1;32m 678\u001b[0m bound_arguments\u001b[38;5;241m.\u001b[39marguments[parameter] \u001b[38;5;241m=\u001b[39m processed_kwargs[parameter]\n", - "File \u001b[0;32m/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/Projects/PlasmaPy/src/plasmapy/particles/decorators.py:597\u001b[0m, in \u001b[0;36m_ParticleInput.process_argument\u001b[0;34m(self, parameter, argument, Z, mass_numb)\u001b[0m\n\u001b[1;32m 595\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mverify_charge_categorization(particle)\n\u001b[1;32m 596\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mverify_particle_categorization(particle)\n\u001b[0;32m--> 597\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mverify_particle_name_criteria\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparameter\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparticle\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 598\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mverify_allowed_types(particle)\n\u001b[1;32m 600\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m particle\n", - "File \u001b[0;32m/run/media/namurphy/d423d80e-c227-4a33-b50f-545b44160ce3/namurphy/Projects/PlasmaPy/src/plasmapy/particles/decorators.py:492\u001b[0m, in \u001b[0;36m_ParticleInput.verify_particle_name_criteria\u001b[0;34m(self, parameter, particle)\u001b[0m\n\u001b[1;32m 489\u001b[0m meets_name_criteria \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mall\u001b[39m(meets_name_criteria) \u001b[38;5;66;03m# type: ignore[arg-type]\u001b[39;00m\n\u001b[1;32m 491\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m meets_name_criteria:\n\u001b[0;32m--> 492\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exception(\n\u001b[1;32m 493\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThe argument \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparameter\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m = \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparticle\u001b[38;5;132;01m!r}\u001b[39;00m\u001b[38;5;124m to \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 494\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcallable_\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m does not correspond to a \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 495\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvalid \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparameter\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 496\u001b[0m )\n", - "\u001b[0;31mInvalidIsotopeError\u001b[0m: The argument isotope = Particle(\"Fe\") to mass_number does not correspond to a valid isotope." - ] - } - ], - "source": [ - "mass_number(\"Fe\")" - ] - }, - { - "cell_type": "markdown", - "id": "ca6ecc47-3445-4655-a8d0-7fde04dfb32a", - "metadata": {}, + "outputs": [], "source": [ - " - `ParticleLike | None`\n", - " - `Z` and `mass_numb`\n", - " - Categorization\n", - " - Parameters named `element`, `isotope`, or `ion`" + "mass_number(\"Fe-56\")" ] }, { - "cell_type": "markdown", - "id": "77e016ea-65e3-45cf-b6d7-6dc0c128b762", + "cell_type": "code", + "execution_count": null, + "id": "6b7cb398-74d8-487b-900a-d9cbe8b3dcf6", "metadata": {}, + "outputs": [], "source": [ - "If we name a parameter `ion`" + "mass_number(\"e-\")" ] }, { @@ -2491,12 +2308,15 @@ "id": "9994fef5-6c29-4639-a3be-f186e271302d", "metadata": {}, "source": [ - "Let's use both `@particle_input` and `@validate_quantities` to write an Alfvén speed function. The formula is $$ V_A ≡ \\frac{B}{\\sqrt{μ_0 ρ}} $$ where we approximate the mass density as $ρ ≈ m_i n_i$. " + "[`@validate_quantities`]: https://docs.plasmapy.org/en/latest/api/plasmapy.utils.decorators.validators.validate_quantities.html#validate-quantities\n", + "[`@particle_input`]: https://docs.plasmapy.org/en/stable/api/plasmapy.particles.decorators.particle_input.html\n", + "\n", + "Let's use both [`@particle_input`] and [`@validate_quantities`] to write an Alfvén speed function. The formula is $$ V_A ≡ \\frac{B}{\\sqrt{μ_0 ρ}} $$ where we approximate the mass density as $ρ ≈ m_i n_i$. " ] }, { "cell_type": "code", - "execution_count": 389, + "execution_count": null, "id": "827f4dff-cb23-4c06-b45f-0771ddd511a4", "metadata": {}, "outputs": [], @@ -2515,51 +2335,13 @@ }, { "cell_type": "code", - "execution_count": 390, + "execution_count": null, "id": "73efd087-fd5d-482f-b131-e420e8fd2dfb", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$13795142 \\; \\mathrm{\\frac{m}{s}}$" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 390, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "alfven_speed(B = 0.02 * u.T, n = 1e15 * u.m**-3, ion=\"p+\")" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "53b52567-a439-4250-aa97-5ee4881dcb9c", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "664be933-8c10-4b96-a4bc-d4d49c345cb7", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "10c2c6c1-519c-448f-9c71-90be03ff322c", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {