Created
June 14, 2018 07:14
-
-
Save jkarakas/e8f1ec281fe7b8bc92650973fd44bda4 to your computer and use it in GitHub Desktop.
Import(run) a ipynb file from another folder in a jupyter notebook
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
{ | |
"cells": [ | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "\n### Import(run) a ipynb file from another folder in a jupyter notebook" | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2018-06-14T07:05:04.585393Z", | |
"end_time": "2018-06-14T07:05:04.593834Z" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "# Example import\nfrom math import log2", | |
"execution_count": 4, | |
"outputs": [] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "Importing a noteboook that converts calculations into latex equations that is two levels up in the path by using the `%run` ipython magic command" | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2018-06-14T07:05:04.974363Z", | |
"end_time": "2018-06-14T07:05:05.009871Z" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "%run '../../NumericToLatex.ipynb'", | |
"execution_count": 5, | |
"outputs": [] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "And testing if the Equation class that was imported works.." | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2018-06-14T07:05:05.365258Z", | |
"end_time": "2018-06-14T07:05:05.371853Z" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "e = Equation('log2(x)')", | |
"execution_count": 6, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"ExecuteTime": { | |
"start_time": "2018-06-14T07:05:05.699919Z", | |
"end_time": "2018-06-14T07:05:05.709400Z" | |
} | |
}, | |
"cell_type": "code", | |
"source": "x = 5\ne.calculate()", | |
"execution_count": 7, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "log2(x) = \\operatorname{log_{2}}{\\left (x \\right )} = 2.321928094887362\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2018-06-14T07:10:18.473112Z", | |
"end_time": "2018-06-14T07:10:18.499390Z" | |
} | |
}, | |
"cell_type": "markdown", | |
"source": "\n$ \\operatorname{log_{2}}{\\left (x \\right )} $" | |
} | |
], | |
"metadata": { | |
"hide_input": false, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3", | |
"language": "python" | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.6.4", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": false, | |
"title_cell": "Table of Contents", | |
"title_sidebar": "Contents", | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": true, | |
"toc_window_display": false | |
}, | |
"varInspector": { | |
"window_display": false, | |
"cols": { | |
"lenName": 16, | |
"lenType": 16, | |
"lenVar": 40 | |
}, | |
"kernels_config": { | |
"python": { | |
"library": "var_list.py", | |
"delete_cmd_prefix": "del ", | |
"delete_cmd_postfix": "", | |
"varRefreshCmd": "print(var_dic_list())" | |
}, | |
"r": { | |
"library": "var_list.r", | |
"delete_cmd_prefix": "rm(", | |
"delete_cmd_postfix": ") ", | |
"varRefreshCmd": "cat(var_dic_list()) " | |
} | |
}, | |
"types_to_exclude": [ | |
"module", | |
"function", | |
"builtin_function_or_method", | |
"instance", | |
"_Feature" | |
] | |
}, | |
"gist": { | |
"id": "", | |
"data": { | |
"description": " Import(run) a ipynb file from another folder in a jupyter notebook", | |
"public": true | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment