Commit 71f17284 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Fix slider

parent 7d740015
......@@ -2,7 +2,11 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
"# Course of Dario Trevisan: Optimal transport\n"
]
......@@ -36,18 +40,21 @@
"source": [
"%matplotlib inline\n",
"from matplotlib import rcParams\n",
"from matplotlib import pyplot as plt\n",
"from ipywidgets import interact, fixed, FloatSlider, RadioButtons\n",
"rcParams['figure.figsize'] = (8., 6.) # Enlarge figure\n",
"# A slider for p\n",
"slider = FloatSlider(min=-1., max=2., step=0.1, value=1.1, continuous_update=False)\n",
"sliderd = dict(min=-1., max=2., step=0.1, value=1.1, continuous_update=False)\n",
"\n",
"from earth_movers import EarthMovers1D, EarthMovers2D"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
"## 1D case\n",
"\n",
......@@ -64,12 +71,16 @@
"outputs": [],
"source": [
"em1D = EarthMovers1D(50)\n",
"interact(em1D.plot_ot, p=slider, plot_points=fixed(True));"
"interact(em1D.plot_ot, p=FloatSlider(**sliderd), plot_points=fixed(True));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
"## 2D case\n",
"\n",
......@@ -83,12 +94,16 @@
"outputs": [],
"source": [
"em2D = EarthMovers2D(100)\n",
"interact(em2D.plot_ot, p=slider, plot_points=fixed(True));"
"interact(em2D.plot_ot, p=FloatSlider(**sliderd), plot_points=fixed(True));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
"Solve the earth movers problem for 1000-position samples."
]
......@@ -100,12 +115,16 @@
"outputs": [],
"source": [
"em2D_large = EarthMovers2D(1000)\n",
"interact(em2D_large.plot_ot, p=slider, plot_points=fixed(False));"
"interact(em2D_large.plot_ot, p=FloatSlider(**sliderd), plot_points=fixed(False));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
"## Histogram of distance"
]
......@@ -130,7 +149,7 @@
" em = EarthMovers1D(nsim) if dimension == 1 else EarthMovers2D(nsim)\n",
" return em.plot_distance_histogram(p, bins=20)\n",
"\n",
"interact(plot_histogram, dimension=RadioButtons(options=[1, 2], value=2), p=slider);"
"interact(plot_histogram, dimension=RadioButtons(options=[1, 2], value=2), p=FloatSlider(**sliderd));"
]
},
{
......@@ -150,6 +169,7 @@
}
],
"metadata": {
"celltoolbar": "Format de la Cellule Texte Brut",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
......@@ -165,7 +185,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.6"
},
"name": "mc2020.ipynb",
"toc": {
......
......@@ -37,7 +37,7 @@
"from matplotlib import pyplot as plt\n",
"from ipywidgets import interact, FloatSlider, RadioButtons\n",
"rcParams['figure.figsize'] = (8., 6.) # Enlarge figure\n",
"slider = FloatSlider(min=0., max=1., step=0.1, value=0.5, continuous_update=False)\n",
"sliderd = dict(min=0., max=1., step=0.1, value=0.5, continuous_update=False)\n",
"\n",
"from percolation import PercolationRect, PercolationHex, percolation_vs_p, PercolationRectDual"
]
......@@ -60,7 +60,7 @@
"outputs": [],
"source": [
"percorect = PercolationRect(20, 10)\n",
"interact(percorect.plot, p=slider);"
"interact(percorect.plot, p=FloatSlider(**sliderd));"
]
},
{
......@@ -96,7 +96,7 @@
"outputs": [],
"source": [
"percohex15 = PercolationHex(30, 30)\n",
"interact(percohex15.plot, p=slider);"
"interact(percohex15.plot, p=FloatSlider(**sliderd));"
]
},
{
......@@ -135,7 +135,7 @@
"outputs": [],
"source": [
"perco = PercolationRectDual(5)\n",
"interact(perco.plot_graph, p=slider,\n",
"interact(perco.plot_graph, p=FloatSlider(**sliderd),\n",
" graph_type=RadioButtons(options=['initial', 'dual', 'both']));"
]
},
......@@ -182,7 +182,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.6"
},
"name": "mc2020.ipynb",
"toc": {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment