Skip to content

Commit

Permalink
Update jupyter
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Jan 24, 2024
1 parent 0571b89 commit 8ab8ff0
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 308 deletions.
200 changes: 22 additions & 178 deletions docs/examples/jupyter/getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 27,
"id": "e6e2284c-1862-4697-ad94-f535b3682197",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ece4babe53924aa7886553d1b5d53bec",
"model_id": "8424f04853ea4a41ac6a3697349bbd3e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"MapWidget(calls=[['addControl', ('ScaleControl', {'unit': 'metric'}, 'bottom-left')], ['addLayer', ({'id': 'ea…"
]
},
"execution_count": 4,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -94,7 +94,7 @@
"m = Map()\n",
"m.add_control(ScaleControl(), position=\"bottom-left\")\n",
"m.add_layer(earthquake_circles)\n",
"m.add_tooltip(layer_id, \"mag\")\n",
"m.add_tooltip(layer_id)\n",
"m.add_marker(Marker(lng_lat=(100.507, 13.745)))\n",
"m"
]
Expand All @@ -109,39 +109,29 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 28,
"id": "356960fa-b866-42c8-a58e-0c9a417c28eb",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "60ef57a918734016b9766e41615c1935",
"model_id": "7998e7feb14045d6a8dfc637d6775c98",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=5, description='radius', max=15, min=-5), Output()), _dom_classes=('widg"
"interactive(children=(IntSlider(value=4, description='radius', max=8, min=1), Output()), _dom_classes=('widget"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<function __main__.<lambda>(radius)>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"widgets.interact(\n",
"change_radius = widgets.interact(\n",
" lambda radius: m.set_paint_property(layer_id, \"circle-radius\", radius),\n",
" radius=5\n",
" radius=(1, 8, 1)\n",
")"
]
},
Expand All @@ -155,14 +145,14 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 21,
"id": "8ecd93a6-f471-4350-a052-7a9171fa1606",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9b52cdb12c3b4af4ac8bbbfc885aea30",
"model_id": "ca7ad45e679d479795b3c05014c8e6b4",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -172,20 +162,10 @@
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<function __main__.<lambda>(color)>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"widgets.interact(\n",
"change_color = widgets.interact(\n",
" lambda color: m.set_paint_property(layer_id, \"circle-color\", color),\n",
" color=[\"green\", \"yellow\", \"orange\", \"red\"]\n",
")"
Expand All @@ -201,39 +181,29 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 31,
"id": "0b73f056-f35a-46bb-a092-d899c64cd67e",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5a4891d6fb0e418bbfe22c4661363022",
"model_id": "405b4aba579b42248573eaf356f629d4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=3, description='mag_min', max=9, min=-3), Output()), _dom_classes=('widg"
"interactive(children=(IntSlider(value=4, description='mag_min', max=7, min=1), Output()), _dom_classes=('widge"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<function __main__.<lambda>(mag_min)>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"widgets.interact(\n",
"filter_mag = widgets.interact(\n",
" lambda mag_min: m.set_filter(layer_id, [\">=\", [\"get\", \"mag\"], mag_min]),\n",
" mag_min=3\n",
" mag_min=(1,7,1)\n",
")"
]
},
Expand All @@ -247,22 +217,22 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 32,
"id": "a9c5ddf7-074e-45b0-8cfe-15750fd0b4d5",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "119b58c9640f4b058fc218ce17203edf",
"model_id": "3957fc738b2643cfa207f9b62edbfdda",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"execution_count": 8,
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -284,136 +254,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "7ad74d91-1137-45b4-8791-83dc3546535e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on _InteractFactory in module ipywidgets.widgets.interaction object:\n",
"\n",
"class _InteractFactory(builtins.object)\n",
" | _InteractFactory(cls, options, kwargs={})\n",
" | \n",
" | Factory for instances of :class:`interactive`.\n",
" | \n",
" | This class is needed to support options like::\n",
" | \n",
" | >>> @interact.options(manual=True)\n",
" | ... def greeting(text=\"World\"):\n",
" | ... print(\"Hello {}\".format(text))\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | cls : class\n",
" | The subclass of :class:`interactive` to construct.\n",
" | options : dict\n",
" | A dict of options used to construct the interactive\n",
" | function. By default, this is returned by\n",
" | ``cls.default_options()``.\n",
" | kwargs : dict\n",
" | A dict of **kwargs to use for widgets.\n",
" | \n",
" | Methods defined here:\n",
" | \n",
" | __call__(self, _InteractFactory__interact_f=None, **kwargs)\n",
" | Make the given function interactive by adding and displaying\n",
" | the corresponding :class:`interactive` widget.\n",
" | \n",
" | Expects the first argument to be a function. Parameters to this\n",
" | function are widget abbreviations passed in as keyword arguments\n",
" | (``**kwargs``). Can be used as a decorator (see examples).\n",
" | \n",
" | Returns\n",
" | -------\n",
" | f : __interact_f with interactive widget attached to it.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | __interact_f : function\n",
" | The function to which the interactive widgets are tied. The `**kwargs`\n",
" | should match the function signature. Passed to :func:`interactive()`\n",
" | **kwargs : various, optional\n",
" | An interactive widget is created for each keyword argument that is a\n",
" | valid widget abbreviation. Passed to :func:`interactive()`\n",
" | \n",
" | Examples\n",
" | --------\n",
" | Render an interactive text field that shows the greeting with the passed in\n",
" | text::\n",
" | \n",
" | # 1. Using interact as a function\n",
" | def greeting(text=\"World\"):\n",
" | print(\"Hello {}\".format(text))\n",
" | interact(greeting, text=\"Jupyter Widgets\")\n",
" | \n",
" | # 2. Using interact as a decorator\n",
" | @interact\n",
" | def greeting(text=\"World\"):\n",
" | print(\"Hello {}\".format(text))\n",
" | \n",
" | # 3. Using interact as a decorator with named parameters\n",
" | @interact(text=\"Jupyter Widgets\")\n",
" | def greeting(text=\"World\"):\n",
" | print(\"Hello {}\".format(text))\n",
" | \n",
" | Render an interactive slider widget and prints square of number::\n",
" | \n",
" | # 1. Using interact as a function\n",
" | def square(num=1):\n",
" | print(\"{} squared is {}\".format(num, num*num))\n",
" | interact(square, num=5)\n",
" | \n",
" | # 2. Using interact as a decorator\n",
" | @interact\n",
" | def square(num=2):\n",
" | print(\"{} squared is {}\".format(num, num*num))\n",
" | \n",
" | # 3. Using interact as a decorator with named parameters\n",
" | @interact(num=5)\n",
" | def square(num=2):\n",
" | print(\"{} squared is {}\".format(num, num*num))\n",
" | \n",
" | __init__(self, cls, options, kwargs={})\n",
" | Initialize self. See help(type(self)) for accurate signature.\n",
" | \n",
" | options(self, **kwds)\n",
" | Change options for interactive functions.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | A new :class:`_InteractFactory` which will apply the\n",
" | options when called.\n",
" | \n",
" | widget(self, f)\n",
" | Return an interactive function widget for the given function.\n",
" | \n",
" | The widget is only constructed, not displayed nor attached to\n",
" | the function.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | An instance of ``self.cls`` (typically :class:`interactive`).\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | f : function\n",
" | The function to which the interactive widgets are tied.\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data descriptors defined here:\n",
" | \n",
" | __dict__\n",
" | dictionary for instance variables (if defined)\n",
" | \n",
" | __weakref__\n",
" | list of weak references to the object (if defined)\n",
"\n"
]
}
],
"outputs": [],
"source": []
},
{
Expand Down
Loading

0 comments on commit 8ab8ff0

Please sign in to comment.