From 35b3c400579518cf348b300d7dccf3452af718f0 Mon Sep 17 00:00:00 2001 From: Jose Borreguero Date: Thu, 12 Apr 2018 14:40:54 -0400 Subject: [PATCH] Refs #47 Remove unused notebook --- notebooks/widget_builder_on_the_fly.ipynb | 189 ---------------------- 1 file changed, 189 deletions(-) delete mode 100644 notebooks/widget_builder_on_the_fly.ipynb diff --git a/notebooks/widget_builder_on_the_fly.ipynb b/notebooks/widget_builder_on_the_fly.ipynb deleted file mode 100644 index d28bbb4..0000000 --- a/notebooks/widget_builder_on_the_fly.ipynb +++ /dev/null @@ -1,189 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.core.display import HTML\n", - "from IPython.core.display import display\n", - "from ipywidgets import widgets\n", - "\n", - "import numpy as np\n", - "\n", - "import matplotlib.pyplot as plt\n", - "%matplotlib notebook" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "726a1be1595849c7bc5bfc91ea5449a6", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "A Jupyter Widget" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "user_input_ui = widgets.HBox([widgets.Label(\"Define Function:\",\n", - " layout=widgets.Layout(width='10%')),\n", - " widgets.Text(value='',\n", - " placeholder=\"Define function here\",\n", - " layout=widgets.Layout(width='60%')),\n", - " widgets.Label(\"Ex: f(a,b,c)=a+b*c\",\n", - " layout=widgets.Layout(width='20%'))])\n", - "display(user_input_ui)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "..." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "At this point, you retrieve the name of the coefficient defined in the function, let's pretend those are \n", - "\n", - " * argument_1\n", - " * argument_2\n", - " * argument_3\n", - " \n", - " ```\n", - " function(x, argument_1, argument_2, argument_3) = 3*argument_1*x + argument_2 * argument_3\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "list_arguments = ['argument_1', 'argument_2', 'argument_3']" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def function(x, argument_1, argument_2, argument_3):\n", - " return 3*argument_1*x*x + argument_2*x + argument_3" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "def value_changed(value):\n", - " # retrieve value of all widgets\n", - " list_value = []\n", - " for _top_widget in vertical_layout.children:\n", - " _text_float = _top_widget.children[1]\n", - " list_value.append(_text_float.value)\n", - "\n", - " x = np.linspace(0,100)\n", - " plt.clf()\n", - " plt.plot(x, function(x, list_value[0], list_value[1], list_value[2]))\n", - " plt.title(\"argument_1: {}, argument_2: {}, argument_3: {}\".format(list_value[0], list_value[1], list_value[2]))" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "2d8bd4928ce143c1b41d1ace62a16e7c", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "A Jupyter Widget" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "\n", - "list_ui = []\n", - "for _argument in list_arguments:\n", - " \n", - " _arg_ui = widgets.HBox([widgets.Label(_argument,\n", - " \n", - " layout=widgets.Layout(width='10%')),\n", - " widgets.FloatText(value=0,\n", - " layout=widgets.Layout(width='20%'))])\n", - " _arg_ui.children[1].observe(value_changed, 'value')\n", - " \n", - " list_ui.append(_arg_ui)\n", - " vertical_layout = widgets.VBox(list_ui)\n", - " \n", - "display(vertical_layout) \n", - "plt.clf()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}