Created
July 27, 2021 13:00
-
-
Save iampramodyadav/bfba31115a95bd674007ae60fecfc69d to your computer and use it in GitHub Desktop.
Running python code in colab from github.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Running python code in colab from github.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyP/ZJ60SpZXabDsxlSLOjjI", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/iampramodyadav/bfba31115a95bd674007ae60fecfc69d/running-python-code-in-colab-from-github.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "7sHO91F320AI" | |
}, | |
"source": [ | |
"\n", | |
"\n", | |
"---\n", | |
"\n", | |
"\n", | |
"# Running .py file in IPython notebook cell from Git Hub\n", | |
"\n", | |
"Pramod Kumar Yadav (@iampramodyadav)\n", | |
"\n", | |
"---\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "WEjm4diF3bc4" | |
}, | |
"source": [ | |
"## Clone the containing folder" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "ceqfjZlR1v-3", | |
"outputId": "235b02d5-63bb-49bd-95eb-332e552b2e21" | |
}, | |
"source": [ | |
" !git clone https://github.com/iampramodyadav/FEA" | |
], | |
"execution_count": 15, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Cloning into 'FEA'...\n", | |
"remote: Enumerating objects: 49, done.\u001b[K\n", | |
"remote: Counting objects: 100% (49/49), done.\u001b[K\n", | |
"remote: Compressing objects: 100% (48/48), done.\u001b[K\n", | |
"remote: Total 49 (delta 12), reused 0 (delta 0), pack-reused 0\u001b[K\n", | |
"Unpacking objects: 100% (49/49), done.\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "DBRBINpH_7_K", | |
"outputId": "9c4750d8-762e-4506-b6e0-d9eeef0c5e49" | |
}, | |
"source": [ | |
"!ls FEA #list all files in FEA" | |
], | |
"execution_count": 31, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Gauss_Legendre_Quadrature.ipynb README.md\t test2.py\n", | |
"LICENSE\t\t\t\t Shape_Function.ipynb test.py\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "ziERueunBzbk" | |
}, | |
"source": [ | |
"## RUN .py file" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "jxA7O-l-B4_E" | |
}, | |
"source": [ | |
"### Method-1 ([Magic Function](http://ipython.org/ipython-doc/dev/interactive/tutorial.html#magic-functions))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "Bk5rrVhF18YX" | |
}, | |
"source": [ | |
"%run FEA/test.py " | |
], | |
"execution_count": 18, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "XrZfrnNx2YRe", | |
"outputId": "9bbf3475-3ea0-46be-a6fb-53be662decea" | |
}, | |
"source": [ | |
"print(Legendre.__doc__)" | |
], | |
"execution_count": 19, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"\n", | |
" n: Order of polynomial\n", | |
" x: Variable\n", | |
" This function print Legendre polynomial of order n\n", | |
" \n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 51 | |
}, | |
"id": "eFUWXKgb2kN2", | |
"outputId": "1f5835a4-034f-418e-bbbf-0baf0692521e" | |
}, | |
"source": [ | |
"x=symbols('x')\n", | |
"Legendre(3,x)" | |
], | |
"execution_count": 20, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/latex": "$\\displaystyle 1.66666666666667 x \\left(1.5 x^{2} - 0.5\\right) - \\frac{2 x}{3}$", | |
"text/plain": [ | |
"1.66666666666667*x*(1.5*x**2 - 0.5) - 2*x/3" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 20 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "TdCkwjePAlFS" | |
}, | |
"source": [ | |
"%run FEA/test2.py" | |
], | |
"execution_count": 23, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "jDrpL1thAtf6", | |
"outputId": "ac5039eb-51f0-48f6-d948-2eed87ecb273" | |
}, | |
"source": [ | |
"z=symbols('z')\n", | |
"SHAPE(2,z)" | |
], | |
"execution_count": 27, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"[-1.0*z*(0.5 - 0.5*z), (1.0 - 1.0*z)*(1.0*z + 1.0), 1.0*z*(0.5*z + 0.5)]" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 27 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "5cIgGqqeB9TK" | |
}, | |
"source": [ | |
"### Method-2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "mNRNyoFH4hze" | |
}, | |
"source": [ | |
"!python FEA/test.py" | |
], | |
"execution_count": 16, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 38 | |
}, | |
"id": "v--DUK9W5spG", | |
"outputId": "66463dde-7f1d-4b4b-cb7f-d35d50d8715c" | |
}, | |
"source": [ | |
"Legendre(2,x)" | |
], | |
"execution_count": 17, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/latex": "$\\displaystyle 1.5 x^{2} - 0.5$", | |
"text/plain": [ | |
"1.5*x**2 - 0.5" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 17 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "eJrcR1ODA48N" | |
}, | |
"source": [ | |
"!python FEA/test2.py" | |
], | |
"execution_count": 29, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "09Nkr67pA40a", | |
"outputId": "a1d1661c-7444-4b70-abb4-baf984c003e7" | |
}, | |
"source": [ | |
"z=symbols('z')\n", | |
"SHAPE(2,z)" | |
], | |
"execution_count": 30, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"[-1.0*z*(0.5 - 0.5*z), (1.0 - 1.0*z)*(1.0*z + 1.0), 1.0*z*(0.5*z + 0.5)]" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 30 | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment