j1-template 2022.2.2 → 2022.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/themes/j1/blocks/footer/boxes/contacts_box.proc +46 -18
  3. data/_includes/themes/j1/blocks/footer/boxes/links_box.proc +1 -0
  4. data/assets/data/fab.html +2 -2
  5. data/assets/data/footer.html +2 -2
  6. data/assets/themes/j1/adapter/js/analytics.js +13 -13
  7. data/assets/themes/j1/adapter/js/cookieConsent.js +1 -1
  8. data/assets/themes/j1/adapter/js/nbinteract.js +366 -120
  9. data/assets/themes/j1/core/css/themes/unodark/bootstrap.css +30 -40
  10. data/assets/themes/j1/core/css/themes/unodark/bootstrap.min.css +1 -1
  11. data/assets/themes/j1/core/css/themes/unolight/bootstrap.css +85 -216
  12. data/assets/themes/j1/core/css/themes/unolight/bootstrap.min.css +2 -2
  13. data/assets/themes/j1/core/js/template.js +1 -1
  14. data/assets/themes/j1/core/js/template.min.js +1 -1
  15. data/assets/themes/j1/core/js/template.min.js.map +1 -1
  16. data/assets/themes/j1/modules/carousel/css/theme/uno.css +5 -0
  17. data/assets/themes/j1/modules/carousel/css/theme/uno.min.css +1 -1
  18. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +1 -0
  19. data/assets/themes/j1/modules/justifiedGallery/css/justifiedGallery.css +6 -0
  20. data/assets/themes/j1/modules/justifiedGallery/css/justifiedGallery.min.css +1 -1
  21. data/assets/themes/j1/modules/mmenuLight/css/mmenu-light.css +2 -2
  22. data/assets/themes/j1/modules/mmenuLight/css/mmenu-light.min.css +1 -2
  23. data/assets/themes/j1/modules/nbInteract/README.md +169 -0
  24. data/assets/themes/j1/modules/nbInteract/css/nbinteract-core.css +4 -0
  25. data/assets/themes/j1/modules/nbInteract/css/nbinteract-core.min.css +4 -0
  26. data/assets/themes/j1/modules/nbInteract/css/theme/uno/nbinteract-core.css +33 -33
  27. data/assets/themes/j1/modules/nbInteract/css/theme/uno/nbinteract-core.min.css +1 -1
  28. data/assets/themes/j1/modules/nbInteract/js/requireJS/require.js +2068 -0
  29. data/assets/themes/j1/modules/nbInteract/js/requireJS/require.min.js +36 -0
  30. data/assets/themes/j1/modules/plotly/LICENSE +21 -0
  31. data/assets/themes/j1/modules/plotly/README.md +32 -0
  32. data/assets/themes/j1/modules/plotly/js/plotly.js +265345 -0
  33. data/assets/themes/j1/modules/plotly/js/plotly.min.js +65 -0
  34. data/assets/themes/j1/modules/requirejs/LICENSE +45 -0
  35. data/assets/themes/j1/modules/requirejs/README.md +79 -0
  36. data/assets/themes/j1/modules/requirejs/js/require.js +2068 -0
  37. data/assets/themes/j1/modules/requirejs/js/require.min.js +36 -0
  38. data/lib/j1/version.rb +1 -1
  39. data/lib/starter_web/Gemfile +1 -1
  40. data/lib/starter_web/_config.yml +1 -1
  41. data/lib/starter_web/_data/blocks/defaults/footer.yml +25 -17
  42. data/lib/starter_web/_data/blocks/footer.yml +78 -65
  43. data/lib/starter_web/_data/modules/analytics.yml +8 -23
  44. data/lib/starter_web/_data/modules/defaults/analytics.yml +1 -1
  45. data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +4 -1
  46. data/lib/starter_web/_data/modules/justifiedGallery.yml +14 -8
  47. data/lib/starter_web/_data/modules/navigator_menu.yml +6 -3
  48. data/lib/starter_web/_data/modules/nbinteract.yml +12 -48
  49. data/lib/starter_web/_data/resources.yml +52 -18
  50. data/lib/starter_web/_includes/attributes.asciidoc +25 -0
  51. data/lib/starter_web/_plugins/lunr_index.rb +1 -1
  52. data/lib/starter_web/assets/images/pages/nbinteract/mandelbrot-menge-1920x1200.jpg +0 -0
  53. data/lib/starter_web/assets/images/pages/nbinteract/mandelbrot-menge.png +0 -0
  54. data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_bar.jpg +0 -0
  55. data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_hist.jpg +0 -0
  56. data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_line.jpg +0 -0
  57. data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_multiple_choice.jpg +0 -0
  58. data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_scatter.jpg +0 -0
  59. data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_scatter_drag.jpg +0 -0
  60. data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_short_answer.jpg +0 -0
  61. data/lib/starter_web/assets/images/pages/nbinteract/nbi-textbook-example.jpg +0 -0
  62. data/lib/starter_web/assets/videos/gallery/kick-it-old-school-poster.jpg +0 -0
  63. data/lib/starter_web/assets/videos/gallery/nye-party-shop-poster.jpg +0 -0
  64. data/lib/starter_web/assets/videos/gallery/stay-colorful-poster.jpg +0 -0
  65. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-01-post-wiki-series.adoc +1 -0
  66. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-02-post-wiki-series.adoc +1 -0
  67. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-03-post-wiki-series.adoc +1 -0
  68. data/lib/starter_web/package.json +1 -2
  69. data/lib/starter_web/pages/public/jupyter/docs/_includes/documents/j1_docs_example_static.asciidoc +232 -232
  70. data/lib/starter_web/pages/public/jupyter/docs/j1-nbinteract-doc.adoc +165 -149
  71. data/lib/starter_web/pages/public/jupyter/docs/nbi-widget-manual.adoc +156 -11
  72. data/lib/starter_web/pages/public/jupyter/docs/nbinteract-doc.adoc +11 -6
  73. data/lib/starter_web/pages/public/jupyter/examples/j1-circular-times-table.adoc +136 -0
  74. data/lib/starter_web/pages/public/jupyter/examples/j1-interactive-widgets.adoc +9 -5
  75. data/lib/starter_web/pages/public/jupyter/examples/j1-odes-in-python.adoc +16 -7
  76. data/lib/starter_web/pages/public/jupyter/examples/j1-testing-plotly.adoc +95 -0
  77. data/lib/starter_web/pages/public/jupyter/examples/j1_climate-change-forecast.adoc +4 -4
  78. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/{algebra_with_sympy-checkpoint.ipynb → j1_circular_times_table-checkpoint.ipynb} +5190 -7291
  79. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_climate_change_forecast-checkpoint.ipynb +2 -2
  80. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_docs_example_dynamic-checkpoint.ipynb +1 -1
  81. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_interactive_widgets-checkpoint.ipynb +170 -15
  82. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_ode_selected-checkpoint.ipynb +1 -1
  83. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_odes_in_python-checkpoint.ipynb +520 -111
  84. data/lib/starter_web/pages/public/jupyter/notebooks/j1/factor_by_factor.mp4 +0 -0
  85. data/lib/starter_web/pages/public/jupyter/notebooks/j1/{.ipynb_checkpoints/j1_algebra_with_sympy-checkpoint.ipynb → j1_circular_times_table.ipynb} +5178 -7308
  86. data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_climate_change_forecast.ipynb +2 -2
  87. data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_docs_example_dynamic.ipynb +1 -1
  88. data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_interactive_widgets.ipynb +170 -15
  89. data/lib/starter_web/pages/public/jupyter/notebooks/j1/{j1_ode_selected.ipynb → j1_odes_in_python.ipynb} +783 -34
  90. data/lib/starter_web/pages/public/jupyter/notebooks/j1/line_by_line.mp4 +0 -0
  91. data/lib/starter_web/pages/public/jupyter/notebooks/j1/point_by_point.mp4 +0 -0
  92. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_interactive_questions-checkpoint.ipynb +185 -0
  93. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_tutorial_interact-checkpoint.ipynb +254 -0
  94. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_tutorial_monty_hall-checkpoint.ipynb +732 -0
  95. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/nbi_docs_recipes_interactive_questions.ipynb +19 -22
  96. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/nbi_docs_tutorial_monty_hall.ipynb +25 -26
  97. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_circular_times_table.html +746 -0
  98. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_climate_change_forecast.html +2 -2
  99. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_interactive_widgets.html +217 -0
  100. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_odes_in_python.html +955 -0
  101. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_recipes_interactive_questions.html +1 -2
  102. data/lib/starter_web/pages/public/jupyter/{apis/binderhub-api.adoc → services/binderhub.adoc} +25 -28
  103. data/lib/starter_web/pages/public/jupyter/{apis/jupyterhub-api.adoc → services/jupyterhub.adoc} +8 -9
  104. data/lib/starter_web/pages/public/learn/roundtrip/100_present_images.adoc +1 -1
  105. data/lib/starter_web/pages/public/learn/roundtrip/100_present_videos.adoc +9 -15
  106. data/lib/starter_web/pages/public/learn/roundtrip/200_typography.adoc +1 -1
  107. data/lib/starter_web/pages/public/learn/roundtrip/300_icon_fonts.adoc +12 -1
  108. data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +1 -1
  109. data/lib/starter_web/pages/public/learn/roundtrip/410_bs_modals_extentions.adoc +1 -1
  110. data/lib/starter_web/pages/public/learn/roundtrip/420_responsive_tables_extensions.adoc +1 -1
  111. data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +117 -12
  112. data/lib/starter_web/pages/public/se/se-fake.adoc +47 -0
  113. data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
  114. data/lib/starter_web/utilsrv/package.json +1 -1
  115. metadata +41 -41
  116. data/lib/starter_web/_data/_resources.yml +0 -1668
  117. data/lib/starter_web/assets/images/pages/nbinteract/binderhub-architecture.png +0 -0
  118. data/lib/starter_web/assets/videos/gallery/adriana-lima-poster.jpg +0 -0
  119. data/lib/starter_web/pages/public/jupyter/notebooks/binder/binder-launches.ipynb +0 -385
  120. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/Untitled-checkpoint.ipynb +0 -6
  121. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/binder-launches-checkpoint.ipynb +0 -385
  122. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/climate-change-forecast-checkpoint.ipynb +0 -916
  123. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/google_altair-checkpoint.ipynb +0 -33
  124. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/ipympl_test_plots-checkpoint.ipynb +0 -14517
  125. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_interactive-checkpoint.ipynb +0 -16493
  126. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_interactive_test-checkpoint.ipynb +0 -14697
  127. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_visualization-checkpoint.ipynb +0 -15358
  128. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_visualization_full-checkpoint.ipynb +0 -2576
  129. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_climate_change_forecast.ipynb +0 -1060
  130. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_docs_hist-checkpoint.ipynb +0 -98
  131. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_interactive-checkpoint.ipynb +0 -560
  132. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_ipympl_test_plots-checkpoint.ipynb +0 -14511
  133. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_pandas_creating_reading_and_writing-checkpoint.ipynb +0 -328
  134. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_recipes_layout-checkpoint.ipynb +0 -341
  135. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/nbi_docs_recipes_graphing-checkpoint.ipynb +0 -98
  136. data/lib/starter_web/pages/public/jupyter/notebooks/j1/binder-launches.ipynb +0 -411
  137. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_examples_correlation-checkpoint.ipynb +0 -651
  138. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/binder-launches.html +0 -546
  139. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_ode_selected.html +0 -186
  140. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/excel.py +0 -55
  141. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/ggplot.py +0 -108
  142. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/ggplot2.py +0 -108
  143. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/husky.py +0 -121
  144. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/latimes.py +0 -149
  145. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/pcolor.py +0 -6
  146. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/quartz.py +0 -55
  147. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/spacy_base.py +0 -94
  148. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/spacy_mono.py +0 -158
  149. data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/sunsentinel.py +0 -125
@@ -1,98 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 1,
6
- "metadata": {},
7
- "outputs": [],
8
- "source": [
9
- "import nbinteract as nbi\n",
10
- "import numpy as np"
11
- ]
12
- },
13
- {
14
- "cell_type": "markdown",
15
- "metadata": {},
16
- "source": [
17
- "#### `nbinteract.hist`"
18
- ]
19
- },
20
- {
21
- "cell_type": "markdown",
22
- "metadata": {},
23
- "source": [
24
- "`hist` generates a histogram that allows interaction with the parameters for the response function. \n",
25
- "\n",
26
- "`hist` takes in a single response function. The response function returns the array of numerical values that will be shown in the histogram. The `hist` function allows interaction with the response function's parameters by specifying them as keyword arguments in the same format as `ipywidgets.interact`. Any argument that can be used for `ipywidgets.interact` can be used for `hist`."
27
- ]
28
- },
29
- {
30
- "cell_type": "code",
31
- "execution_count": 2,
32
- "metadata": {},
33
- "outputs": [],
34
- "source": [
35
- "def hist_response_function(mean, sd, size=1000):\n",
36
- " '''\n",
37
- " Returns 1000 values picked at random from the normal\n",
38
- " distribution with the mean and SD given.\n",
39
- " '''\n",
40
- " return np.random.normal(loc=mean, scale=sd, size=1000)"
41
- ]
42
- },
43
- {
44
- "cell_type": "code",
45
- "execution_count": 3,
46
- "metadata": {
47
- "scrolled": false
48
- },
49
- "outputs": [
50
- {
51
- "data": {
52
- "application/vnd.jupyter.widget-view+json": {
53
- "model_id": "cbe5115416b64b71af47b269a37e2f79",
54
- "version_major": 2,
55
- "version_minor": 0
56
- },
57
- "text/plain": [
58
- "VBox(children=(interactive(children=(IntSlider(value=5, description='mean', max=10), FloatSlider(value=1.0, de…"
59
- ]
60
- },
61
- "metadata": {},
62
- "output_type": "display_data"
63
- }
64
- ],
65
- "source": [
66
- "nbi.hist(hist_response_function, mean=(0, 10), sd=(0, 2.0, 0.2))"
67
- ]
68
- },
69
- {
70
- "cell_type": "markdown",
71
- "metadata": {},
72
- "source": [
73
- "If you interact with the above plot, you may notice that the plot's x and y-axes will automatically scale to match the input data. You can change plot parameters like the axes limits through the `options` parameter of the plotting functions:"
74
- ]
75
- }
76
- ],
77
- "metadata": {
78
- "kernelspec": {
79
- "display_name": "Python 3",
80
- "language": "python",
81
- "name": "python3"
82
- },
83
- "language_info": {
84
- "codemirror_mode": {
85
- "name": "ipython",
86
- "version": 3
87
- },
88
- "file_extension": ".py",
89
- "mimetype": "text/x-python",
90
- "name": "python",
91
- "nbconvert_exporter": "python",
92
- "pygments_lexer": "ipython3",
93
- "version": "3.7.9"
94
- }
95
- },
96
- "nbformat": 4,
97
- "nbformat_minor": 2
98
- }
@@ -1,560 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "metadata": {},
6
- "source": [
7
- "### Interactive widgets from ipywidgets"
8
- ]
9
- },
10
- {
11
- "cell_type": "code",
12
- "execution_count": 1,
13
- "metadata": {},
14
- "outputs": [],
15
- "source": [
16
- "import matplotlib.pyplot as plt\n",
17
- "import ipywidgets as widgets\n",
18
- "from ipywidgets import interact\n",
19
- "import nbinteract as nbi\n",
20
- "import numpy as np\n",
21
- "from numpy import arange,sin,pi"
22
- ]
23
- },
24
- {
25
- "cell_type": "code",
26
- "execution_count": 2,
27
- "metadata": {},
28
- "outputs": [
29
- {
30
- "data": {
31
- "application/vnd.jupyter.widget-view+json": {
32
- "model_id": "1e238ae902be4a9a8c6c7b3ecd13d771",
33
- "version_major": 2,
34
- "version_minor": 0
35
- },
36
- "text/plain": [
37
- "interactive(children=(IntSlider(value=10, description='x', max=30, min=-10), Output()), _dom_classes=('widget-…"
38
- ]
39
- },
40
- "metadata": {},
41
- "output_type": "display_data"
42
- }
43
- ],
44
- "source": [
45
- "# Testing Interact from ipywidgets\n",
46
- "def square(x):\n",
47
- " return x * x\n",
48
- "\n",
49
- "interact(square, x=10);"
50
- ]
51
- },
52
- {
53
- "cell_type": "code",
54
- "execution_count": 3,
55
- "metadata": {},
56
- "outputs": [
57
- {
58
- "data": {
59
- "application/vnd.jupyter.widget-view+json": {
60
- "model_id": "1f356e161f304e1da85a8e375dc57eb7",
61
- "version_major": 2,
62
- "version_minor": 0
63
- },
64
- "text/plain": [
65
- "interactive(children=(FloatSlider(value=7.0685834705770345, description='xmax', max=12.566370614359172, min=1.…"
66
- ]
67
- },
68
- "metadata": {},
69
- "output_type": "display_data"
70
- }
71
- ],
72
- "source": [
73
- "# Definiere myplot-Funktion \n",
74
- "def myplot(xmax): \n",
75
- " x = arange(0, xmax, 0.01);y = sin(2*pi*x); \n",
76
- " plt.plot(x,y); \n",
77
- "\n",
78
- "# Erstelle ein Widget für den Plot mit Hilfe von interact \n",
79
- "interact(myplot, xmax = (pi/2,4*pi)); "
80
- ]
81
- },
82
- {
83
- "cell_type": "code",
84
- "execution_count": 4,
85
- "metadata": {},
86
- "outputs": [
87
- {
88
- "data": {
89
- "application/vnd.jupyter.widget-view+json": {
90
- "model_id": "9d428c51cffc414192aef9cbd006d402",
91
- "version_major": 2,
92
- "version_minor": 0
93
- },
94
- "text/plain": [
95
- "interactive(children=(Dropdown(description='name', options=('Jim', 'Emma', 'Bond'), value='Jim'), Output()), _…"
96
- ]
97
- },
98
- "metadata": {},
99
- "output_type": "display_data"
100
- }
101
- ],
102
- "source": [
103
- "def say_my_name(name):\n",
104
- " \"\"\"\n",
105
- " Print the current widget value in short sentence\n",
106
- " \"\"\"\n",
107
- " print(f'My name is {name}')\n",
108
- " \n",
109
- "widgets.interact(say_my_name, name=[\"Jim\", \"Emma\", \"Bond\"]);"
110
- ]
111
- },
112
- {
113
- "cell_type": "code",
114
- "execution_count": 5,
115
- "metadata": {},
116
- "outputs": [
117
- {
118
- "data": {
119
- "application/vnd.jupyter.widget-view+json": {
120
- "model_id": "41eb9d2d6455486795a15eb7dc2fe7de",
121
- "version_major": 2,
122
- "version_minor": 0
123
- },
124
- "text/plain": [
125
- "interactive(children=(Dropdown(description='x', options=(0, 1, 2, 3), value=0), Output()), _dom_classes=('widg…"
126
- ]
127
- },
128
- "metadata": {},
129
- "output_type": "display_data"
130
- },
131
- {
132
- "data": {
133
- "application/vnd.jupyter.widget-view+json": {
134
- "model_id": "44c2db9ff9384e31912e66f6643f5dde",
135
- "version_major": 2,
136
- "version_minor": 0
137
- },
138
- "text/plain": [
139
- "interactive(children=(IntSlider(value=5, description='x', max=10), Output()), _dom_classes=('widget-interact',…"
140
- ]
141
- },
142
- "metadata": {},
143
- "output_type": "display_data"
144
- },
145
- {
146
- "data": {
147
- "application/vnd.jupyter.widget-view+json": {
148
- "model_id": "966d938de20c4e2db6904cb63b385623",
149
- "version_major": 2,
150
- "version_minor": 0
151
- },
152
- "text/plain": [
153
- "interactive(children=(FloatSlider(value=5.0, description='x', max=10.0, step=0.5), Output()), _dom_classes=('w…"
154
- ]
155
- },
156
- "metadata": {},
157
- "output_type": "display_data"
158
- },
159
- {
160
- "data": {
161
- "application/vnd.jupyter.widget-view+json": {
162
- "model_id": "de8c6791100c40dfbbe144fdfce0b8e3",
163
- "version_major": 2,
164
- "version_minor": 0
165
- },
166
- "text/plain": [
167
- "interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))"
168
- ]
169
- },
170
- "metadata": {},
171
- "output_type": "display_data"
172
- }
173
- ],
174
- "source": [
175
- "def say_something(x):\n",
176
- " \"\"\"\n",
177
- " Print the current widget value in short sentence\n",
178
- " \"\"\"\n",
179
- " print(f'Widget says: {x}')\n",
180
- " \n",
181
- "widgets.interact(say_something, x=[0, 1, 2, 3])\n",
182
- "widgets.interact(say_something, x=(0, 10, 1))\n",
183
- "widgets.interact(say_something, x=(0, 10, .5))\n",
184
- "_ = widgets.interact(say_something, x=True)"
185
- ]
186
- },
187
- {
188
- "cell_type": "code",
189
- "execution_count": 6,
190
- "metadata": {},
191
- "outputs": [
192
- {
193
- "data": {
194
- "application/vnd.jupyter.widget-view+json": {
195
- "model_id": "62fd5867fd3e4e03a06ddce7a97f9c0e",
196
- "version_major": 2,
197
- "version_minor": 0
198
- },
199
- "text/plain": [
200
- "interactive(children=(IntSlider(value=5, description='x', max=10), Output()), _dom_classes=('widget-interact',…"
201
- ]
202
- },
203
- "metadata": {},
204
- "output_type": "display_data"
205
- }
206
- ],
207
- "source": [
208
- "@widgets.interact(x=(0, 10, 1))\n",
209
- "def foo(x):\n",
210
- " \"\"\"\n",
211
- " Print the current widget value in short sentence\n",
212
- " \"\"\"\n",
213
- " print(f'Slider says: {x}')"
214
- ]
215
- },
216
- {
217
- "cell_type": "code",
218
- "execution_count": 7,
219
- "metadata": {},
220
- "outputs": [
221
- {
222
- "data": {
223
- "application/vnd.jupyter.widget-view+json": {
224
- "model_id": "78411536462646ae85176bc2fd008068",
225
- "version_major": 2,
226
- "version_minor": 0
227
- },
228
- "text/plain": [
229
- "VBox(children=(IntSlider(value=5, description='slider', max=10), IntRangeSlider(value=(20, 40), description='r…"
230
- ]
231
- },
232
- "metadata": {},
233
- "output_type": "display_data"
234
- }
235
- ],
236
- "source": [
237
- "int_slider = widgets.IntSlider(\n",
238
- " value=5, \n",
239
- " min=0, max=10, step=1, \n",
240
- " description='slider'\n",
241
- ")\n",
242
- " \n",
243
- "int_range_slider = widgets.IntRangeSlider(\n",
244
- " value=(20, 40), \n",
245
- " min=0, max=100, step=2, \n",
246
- " description='range slider'\n",
247
- ")\n",
248
- " \n",
249
- "dropdown = widgets.Dropdown(\n",
250
- " value='feb', \n",
251
- " options=['jan', 'feb', 'mar', 'apr'], \n",
252
- " description='dropdown'\n",
253
- ")\n",
254
- " \n",
255
- "radiobuttons = widgets.RadioButtons(\n",
256
- " value='feb', \n",
257
- " options=['jan', 'feb', 'mar', 'apr'], \n",
258
- " description='radio buttons'\n",
259
- ")\n",
260
- " \n",
261
- "combobox = widgets.Combobox(\n",
262
- " placeholder='start typing... (e.g. L or o)',\n",
263
- " options=['Amsterdam', 'Athens', 'Lisbon', 'London', 'Ljubljana'], \n",
264
- " description='combo box'\n",
265
- ")\n",
266
- " \n",
267
- "checkbox = widgets.Checkbox(\n",
268
- " description='checkbox',\n",
269
- " value=True\n",
270
- ")\n",
271
- " \n",
272
- " \n",
273
- "# a VBox container to pack widgets vertically\n",
274
- "widgets.VBox(\n",
275
- " [\n",
276
- " int_slider, \n",
277
- " int_range_slider, \n",
278
- " dropdown, \n",
279
- " radiobuttons,\n",
280
- " checkbox,\n",
281
- " combobox,\n",
282
- " ]\n",
283
- ")\n"
284
- ]
285
- },
286
- {
287
- "cell_type": "code",
288
- "execution_count": 8,
289
- "metadata": {},
290
- "outputs": [
291
- {
292
- "data": {
293
- "application/vnd.jupyter.widget-view+json": {
294
- "model_id": "3ffc9bd466bd4fe7a02213aabae85f0f",
295
- "version_major": 2,
296
- "version_minor": 0
297
- },
298
- "text/plain": [
299
- "VBox(children=(IntSlider(value=5, description='slider 1', max=10), IntSlider(value=5, description='slider 2', …"
300
- ]
301
- },
302
- "metadata": {},
303
- "output_type": "display_data"
304
- }
305
- ],
306
- "source": [
307
- "sl1 = widgets.IntSlider(description='slider 1', min=0, max=10)\n",
308
- "sl2 = widgets.IntSlider(description='slider 2', min=0, max=10)\n",
309
- " \n",
310
- "link = widgets.link(\n",
311
- " (sl1, 'value'), \n",
312
- " (sl2, 'min')\n",
313
- ")\n",
314
- " \n",
315
- "sl1.value = 5\n",
316
- "widgets.VBox([sl1, sl2])"
317
- ]
318
- },
319
- {
320
- "cell_type": "markdown",
321
- "metadata": {},
322
- "source": [
323
- "### Interactive widgets from nbinteract"
324
- ]
325
- },
326
- {
327
- "cell_type": "markdown",
328
- "metadata": {},
329
- "source": [
330
- "#### `nbinteract.hist`\n",
331
- "\n",
332
- "The widget hist generates a histogram that allows interaction with the parameters for the response function. The widget takes in a single response function. The response function returns the array of numerical values that will be shown in the histogram. The hist function allows interaction with the response function's parameters by specifying them as keyword arguments in the same format as ipywidgets.interact. Any argument that can be used for ipywidgets.interact can be used for hist.\n"
333
- ]
334
- },
335
- {
336
- "cell_type": "code",
337
- "execution_count": 9,
338
- "metadata": {},
339
- "outputs": [
340
- {
341
- "data": {
342
- "application/vnd.jupyter.widget-view+json": {
343
- "model_id": "d94f51e8a78243488d4d5cb058aefca7",
344
- "version_major": 2,
345
- "version_minor": 0
346
- },
347
- "text/plain": [
348
- "VBox(children=(interactive(children=(IntSlider(value=5, description='mean', max=10), FloatSlider(value=1.0, de…"
349
- ]
350
- },
351
- "metadata": {},
352
- "output_type": "display_data"
353
- }
354
- ],
355
- "source": [
356
- "def hist_response_function(mean, sd, size=1000):\n",
357
- " '''\n",
358
- " Returns 1000 values picked at random from the normal\n",
359
- " distribution with the mean and SD given.\n",
360
- " '''\n",
361
- " return np.random.normal(loc=mean, scale=sd, size=1000)\n",
362
- "\n",
363
- "nbi.hist(hist_response_function, mean=(0, 10), sd=(0, 2.0, 0.2))"
364
- ]
365
- },
366
- {
367
- "cell_type": "markdown",
368
- "metadata": {},
369
- "source": [
370
- "#### `nbinteract.bar`\n",
371
- "\n",
372
- "The widgetr bar generates an bar plot that allows interaction with the parameters for the response functions.\n",
373
- "\n",
374
- "The first two arguments of bar are response functions that return the x and y-axis data arrays, respectively. Either argument can be arrays themselves. Arguments for the response functions must be passed in as keyword arguments to bar in the format expected by interact. The response function for the y-axis data will be called with the x-axis data as its first argument.\n",
375
- "\n",
376
- "For example, in the bar plot below categories generates the categories to plot on the x-axis and heights generates the y-axis heights. The heights function uses the parameter xs which is the array of x-axis data points."
377
- ]
378
- },
379
- {
380
- "cell_type": "code",
381
- "execution_count": 10,
382
- "metadata": {},
383
- "outputs": [
384
- {
385
- "data": {
386
- "application/vnd.jupyter.widget-view+json": {
387
- "model_id": "d7789fc2460e45ff836179322c79a531",
388
- "version_major": 2,
389
- "version_minor": 0
390
- },
391
- "text/plain": [
392
- "VBox(children=(interactive(children=(IntSlider(value=5, description='n', max=10), IntSlider(value=5, descripti…"
393
- ]
394
- },
395
- "metadata": {},
396
- "output_type": "display_data"
397
- }
398
- ],
399
- "source": [
400
- "def categories(n): \n",
401
- " return np.arange(n)\n",
402
- "\n",
403
- "def heights(xs, offset):\n",
404
- " return xs + offset\n",
405
- "\n",
406
- "opts = {\n",
407
- " 'ylim': (0, 20),\n",
408
- "}\n",
409
- "\n",
410
- "nbi.bar(categories, heights, n=(0, 10), offset=(1, 10), options=opts)"
411
- ]
412
- },
413
- {
414
- "cell_type": "markdown",
415
- "metadata": {},
416
- "source": [
417
- "#### nbinteract.scatter_drag\n",
418
- "\n",
419
- "The widget scatter_drag generates a scatter plot that allows interaction through clicking and dragging the points on the graph.\n",
420
- "\n",
421
- "scatter_drag takes in two lists/arrays consisting of the x-coordinates and y-coordinates of the points to plot. It generates an interactive scatter plot where the points can be dragged by the user and a best fit line is updated automatically according to the placement of the points.\n",
422
- "\n",
423
- "scatter_drag does not allow response functions as inputs."
424
- ]
425
- },
426
- {
427
- "cell_type": "code",
428
- "execution_count": 11,
429
- "metadata": {},
430
- "outputs": [
431
- {
432
- "data": {
433
- "application/vnd.jupyter.widget-view+json": {
434
- "model_id": "9ad5dc1a5e41496191120f076ce76bef",
435
- "version_major": 2,
436
- "version_minor": 0
437
- },
438
- "text/plain": [
439
- "VBox(children=(Label(value='y = 1.02x + 0.31'), Figure(animation_duration=250, axes=[Axis(scale=LinearScale(ma…"
440
- ]
441
- },
442
- "metadata": {},
443
- "output_type": "display_data"
444
- }
445
- ],
446
- "source": [
447
- "x_coords = np.arange(10)\n",
448
- "y_coords = np.arange(10) + np.random.rand(10)\n",
449
- "\n",
450
- "opts = {'xlim': (0, 9), 'ylim': (0, 11), 'animation_duration': 250}\n",
451
- "\n",
452
- "nbi.scatter_drag(x_coords, y_coords, options=opts)"
453
- ]
454
- },
455
- {
456
- "cell_type": "markdown",
457
- "metadata": {},
458
- "source": [
459
- "#### `nbinteract.scatter`\n",
460
- "\n",
461
- "The scatter widgetr generates a scatter plot that allows interaction with the parameters to the response functions. This is different from scatter_drag which facilitates interaction using click and drag actions.\n",
462
- "\n",
463
- "The first two arguments of scatter are response functions that return the x and y-axis coordinates, respectively. Either argument can be arrays themselves. Arguments for the response functions must be passed in as keyword arguments to scatter in the format expected by interact. The response function for the y-coordinates will be called with the x-coordinates as its first argument."
464
- ]
465
- },
466
- {
467
- "cell_type": "code",
468
- "execution_count": 12,
469
- "metadata": {},
470
- "outputs": [
471
- {
472
- "data": {
473
- "application/vnd.jupyter.widget-view+json": {
474
- "model_id": "847f4331eff64e2782a651485f2f078b",
475
- "version_major": 2,
476
- "version_minor": 0
477
- },
478
- "text/plain": [
479
- "VBox(children=(interactive(children=(IntSlider(value=100, description='n', max=200), Output()), _dom_classes=(…"
480
- ]
481
- },
482
- "metadata": {},
483
- "output_type": "display_data"
484
- }
485
- ],
486
- "source": [
487
- "def x_values(n): return np.random.choice(100, n)\n",
488
- "def y_values(xs): return np.random.choice(100, len(xs))\n",
489
- "\n",
490
- "nbi.scatter(x_values, y_values, n=(0,200))"
491
- ]
492
- },
493
- {
494
- "cell_type": "markdown",
495
- "metadata": {},
496
- "source": [
497
- "#### `nbinteract.line`\n",
498
- "\n",
499
- "The line widget generates a line plot that allows interaction with the parameters to the response functions.\n",
500
- "\n",
501
- "The first two arguments of line are response functions that return the x and y-axis coordinates, respectively. Either argument can be arrays themselves. Arguments for the response functions must be passed in as keyword arguments to line in the format expected by interact. The response function for the y-coordinates will be called with the x-coordinates as its first argument."
502
- ]
503
- },
504
- {
505
- "cell_type": "code",
506
- "execution_count": 13,
507
- "metadata": {},
508
- "outputs": [
509
- {
510
- "data": {
511
- "application/vnd.jupyter.widget-view+json": {
512
- "model_id": "4e76e56bdc994cb88ecda69b4588ad17",
513
- "version_major": 2,
514
- "version_minor": 0
515
- },
516
- "text/plain": [
517
- "VBox(children=(interactive(children=(IntSlider(value=30, description='max', max=50, min=10), IntSlider(value=5…"
518
- ]
519
- },
520
- "metadata": {},
521
- "output_type": "display_data"
522
- }
523
- ],
524
- "source": [
525
- "def x_values(max): return np.arange(0, max)\n",
526
- "def y_values(xs, sd):\n",
527
- " return xs + np.random.normal(0, scale=sd, size=len(xs))\n",
528
- "\n",
529
- "opts = {\n",
530
- " 'xlim': (0, 50),\n",
531
- " 'ylim': (0, 55),\n",
532
- " 'animation_duration': 250,\n",
533
- "}\n",
534
- "\n",
535
- "nbi.line(x_values, y_values, max=(10, 50), sd=(1, 10), options=opts)"
536
- ]
537
- }
538
- ],
539
- "metadata": {
540
- "kernelspec": {
541
- "display_name": "Python 3",
542
- "language": "python",
543
- "name": "python3"
544
- },
545
- "language_info": {
546
- "codemirror_mode": {
547
- "name": "ipython",
548
- "version": 3
549
- },
550
- "file_extension": ".py",
551
- "mimetype": "text/x-python",
552
- "name": "python",
553
- "nbconvert_exporter": "python",
554
- "pygments_lexer": "ipython3",
555
- "version": "3.7.9"
556
- }
557
- },
558
- "nbformat": 4,
559
- "nbformat_minor": 4
560
- }