j1-template 2022.2.2 → 2022.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) 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/core/css/themes/unolight/bootstrap.css +64 -206
  7. data/assets/themes/j1/core/css/themes/unolight/bootstrap.min.css +2 -2
  8. data/assets/themes/j1/modules/nbInteract/README.md +169 -0
  9. data/assets/themes/j1/modules/nbInteract/css/nbinteract-core.css +4 -0
  10. data/assets/themes/j1/modules/nbInteract/css/nbinteract-core.min.css +4 -0
  11. data/lib/j1/version.rb +1 -1
  12. data/lib/starter_web/Gemfile +1 -1
  13. data/lib/starter_web/_config.yml +1 -1
  14. data/lib/starter_web/_data/blocks/defaults/footer.yml +25 -17
  15. data/lib/starter_web/_data/blocks/footer.yml +78 -65
  16. data/lib/starter_web/_data/resources.yml +0 -22
  17. data/lib/starter_web/_includes/attributes.asciidoc +14 -0
  18. data/lib/starter_web/_plugins/lunr_index.rb +1 -1
  19. data/lib/starter_web/assets/images/pages/nbinteract/nbi-textbook-example.jpg +0 -0
  20. data/lib/starter_web/package.json +1 -1
  21. data/lib/starter_web/pages/public/jupyter/docs/_includes/documents/j1_docs_example_static.asciidoc +232 -232
  22. data/lib/starter_web/pages/public/jupyter/docs/j1-nbinteract-doc.adoc +135 -134
  23. data/lib/starter_web/pages/public/jupyter/docs/nbi-widget-manual.adoc +2 -4
  24. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_interactive_widgets-checkpoint.ipynb +170 -15
  25. data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_interactive_widgets.ipynb +170 -15
  26. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_interactive_questions-checkpoint.ipynb +185 -0
  27. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/nbi_docs_recipes_interactive_questions.ipynb +19 -22
  28. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/binder-launches.html +670 -546
  29. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_docs_example_dynamic.html +186 -186
  30. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_interactive_widgets.html +919 -702
  31. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_ode_selected.html +186 -186
  32. data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_recipes_interactive_questions.html +242 -243
  33. data/lib/starter_web/pages/public/jupyter/{apis/binderhub-api.adoc → services/binderhub.adoc} +22 -25
  34. data/lib/starter_web/pages/public/jupyter/{apis/jupyterhub-api.adoc → services/jupyterhub.adoc} +2 -2
  35. data/lib/starter_web/pages/public/learn/roundtrip/300_icon_fonts.adoc +11 -0
  36. data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
  37. data/lib/starter_web/utilsrv/package.json +1 -1
  38. metadata +7 -28
  39. data/lib/starter_web/_data/_resources.yml +0 -1668
  40. data/lib/starter_web/assets/images/pages/nbinteract/binderhub-architecture.png +0 -0
  41. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/algebra_with_sympy-checkpoint.ipynb +0 -14488
  42. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/climate-change-forecast-checkpoint.ipynb +0 -916
  43. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/ipympl_test_plots-checkpoint.ipynb +0 -14517
  44. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_algebra_with_sympy-checkpoint.ipynb +0 -14517
  45. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_interactive-checkpoint.ipynb +0 -16493
  46. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_visualization-checkpoint.ipynb +0 -15358
  47. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_visualization_full-checkpoint.ipynb +0 -2576
  48. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_climate_change_forecast-checkpoint.ipynb +0 -1058
  49. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_climate_change_forecast.ipynb +0 -1060
  50. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_docs_example_dynamic-checkpoint.ipynb +0 -14478
  51. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_docs_hist-checkpoint.ipynb +0 -98
  52. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_interactive-checkpoint.ipynb +0 -560
  53. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_ipympl_test_plots-checkpoint.ipynb +0 -14511
  54. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_ode_selected-checkpoint.ipynb +0 -14478
  55. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_odes_in_python-checkpoint.ipynb +0 -14818
  56. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_pandas_creating_reading_and_writing-checkpoint.ipynb +0 -328
  57. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_recipes_layout-checkpoint.ipynb +0 -341
  58. data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/nbi_docs_recipes_graphing-checkpoint.ipynb +0 -98
  59. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_examples_correlation-checkpoint.ipynb +0 -651
  60. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_examples_variability_of_the_sample_mean-checkpoint.ipynb +0 -323
  61. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_graphing-checkpoint.ipynb +0 -387
  62. data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_layout-checkpoint.ipynb +0 -384
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: J1 NBI
3
- tagline: textbook integration
3
+ tagline: jupyter notebook integration
4
4
  date: 2022-04-17 00:00:00
5
5
  description: >
6
6
  The package nbinteract aims to enable authors and educators to create and
@@ -38,7 +38,7 @@ personalization: true
38
38
  permalink: /pages/public/jupyter/docs/j1-nbinteract-docs/
39
39
  regenerate: true
40
40
 
41
- resources: [ animate, clipboard, lightbox, nbinteract, rouge ]
41
+ resources: [ animate, clipboard, nbinteract, rouge ]
42
42
  resource_options:
43
43
  - attic:
44
44
  padding_top: 400
@@ -94,6 +94,128 @@ endif::[]
94
94
 
95
95
  // info: https://en.wikipedia.org/wiki/Galileo_Galilei
96
96
 
97
+ The Jupyter Project is a non-profit organization founded in 2014 by
98
+ _Fernando Perez_. The Jupyter project supports interactive scientific
99
+ Data evaluations and scientific calculations. The main applications provided
100
+ by the Jupyter Project are:
101
+
102
+ * Jupyter Notebook (JN)
103
+ * JupyterHub (JH)
104
+
105
+ NOTE: The name _Jupyter_ refers to the three main programming languages
106
+ _Julia_, _Python_ and _R_ supported by the Jupyter Notebook App. The
107
+ name _Jupyter_ is a homage to the notebook entries by _Galileo Galilei_
108
+ on the discovery of the moons of Jupiter, where he made his observations
109
+ and the measurement data together.
110
+
111
+ Jupyter Notebook (JN) is an open source web application that allows data
112
+ scientists to create and share documents that include live code, equations,
113
+ and other multimedia resources. JN combines two components:
114
+
115
+ Web application::
116
+ a browser-based tool for interactive authoring of documents which combine
117
+ explanatory text, mathematics, computations and their rich media output.
118
+
119
+ Notebook documents::
120
+ a representation of all content visible in the web application, including
121
+ inputs and outputs of the computations, explanatory text, mathematics,
122
+ images, and rich media representations of objects.
123
+
124
+ == Jupyter Basics
125
+
126
+ To understand this documentation better, below you find a brief description
127
+ of JupyterHub (JH) and the three base components of Jupyter Notebook (JN).
128
+
129
+ === Jupyter Notebook App
130
+
131
+ The Jupyter Notebook *App* is a server-client application that allows editing
132
+ and running notebook documents via a web browser. The Notebook App can be
133
+ executed on a local desktop requiring no internet access or can be installed
134
+ on a remote server and accessed through the internet.
135
+
136
+ === Notebook documents
137
+
138
+ Notebook documents (or *notebooks* for short) are documents created by the
139
+ Notebook App, and both computer code (e.g., Python) and rich text may contain
140
+ elements (paragraphs, equations, figures, links, etc.). Notebook documents are
141
+ human-readable documents, alongside code descriptions and results (figures,
142
+ tables, etc.).
143
+
144
+ === Kernels
145
+
146
+ Generally, a notebook *kernel* is a *calculating machine* that lives in the
147
+ Jupyter Notebook App to process a Notebook document and executes its
148
+ code. The *Ipython* kernel, used for the NBI integration, runs _Python_
149
+ code, and produces the results.
150
+
151
+ === JupyterHub
152
+
153
+ _JupyterHub_ (JH) brings the power of notebooks to *groups* of users. It
154
+ gives users access to computational environments and resources without
155
+ burdening the users with installation and maintenance tasks. Users can get
156
+ their work done in their own workspaces on shared resources which can be
157
+ managed efficiently by system administrators without having the Jupyter
158
+ Notebook App (JN) locally installed on their systems.
159
+
160
+ JupyterHub runs in the cloud or on hardware hosted on your own and makes
161
+ it possible to serve a pre-configured data science environment to any user.
162
+ It is customizable and scalable and is suitable for small and large teams,
163
+ academic courses, and large-scale infrastructure (for example like the
164
+ Binder service).
165
+
166
+
167
+ == The Package nbInteract (NBI)
168
+
169
+ As a web technology, _Jupyter Notebook_ provides a platform for authoring
170
+ interactive scientific documents. For example, the popular `ipywidgets`
171
+ Python library allows users to create web-based user interfaces to interact
172
+ with arbitrary Python functions. Users can create these interfaces using
173
+ Python directly in the notebook instead of HTML and JavaScript, significantly
174
+ lowering the time needed to create these interfaces.
175
+
176
+ This ease of use encourages instructors and researchers to create interactive
177
+ explanations of their work. Unfortunately, it isn't easy to *share* these
178
+ interactive notebooks with the public. Sharing the notebook file itself
179
+ retains full interactivity but requires *viewers* to have Jupyter, Python,
180
+ and all other packages used in the notebook installed on their machines.
181
+
182
+ The freely available Binder service circumvents this by hosting notebook
183
+ servers pre-packaged with the necessary software. However, both of these
184
+ options still require readers to have prior familiarity with the Jupyter
185
+ environment, making them less suitable for use with non-technical people.
186
+
187
+ Authors can convert a Jupyter notebook to a static HTML document and host
188
+ the document as a publicly-accessible web page. However, this method does
189
+ not preserve the interactive elements of the notebook. The resulting web
190
+ page only contains text and images.
191
+
192
+ .NBI textbook (excerpt)
193
+ // lightbox::nbi-textbook--excerpt[ 800, {data-nbi-textbook--excerpt}, role="mt-3 mb-4" ]
194
+ image::pages/nbinteract/nbi-textbook-example.jpg["NBI textbook (excerpt)", 800]
195
+
196
+ The Python package `nbinteract` allows authors to convert Jupyter notebooks
197
+ into *interactive*, standalone HTML pages: the textbooks. The interactive
198
+ elements can use arbitrary Python code to generate output, including Python
199
+ libraries that use C extensions (e.g., _NumPy_ and _Pandas_) and libraries
200
+ that create images (e.g., _Matplotlib_).
201
+
202
+ Anyone with a modern web browser can use the resulting web pages even if
203
+ the viewer does *not* have Python or Jupyter installed on their computer.
204
+ To make this possible, NBI uses the freely available cloud service _Binder_.
205
+ Two communication libraries are used to interact with the _BinderHub_ and the
206
+ _JupyterHub_ services
207
+
208
+ You can find an overview of these services and their communication interfaces
209
+ at:
210
+
211
+ * link:{url-j1--binderhub}[BinderHub, {browser-window--new}]
212
+ * link:{url-j1--jupyterhub}[JupyterHub, {browser-window--new}]
213
+
214
+ TIP: The `nbinteract` package also includes additional methods for interactive
215
+ plots (widgets) designed for very fast interaction prototyping in the notebook
216
+ and smooth interaction on static HTML web pages.
217
+
218
+ == J1 NBI Integration
97
219
 
98
220
  The integration of NBI consists of the following components:
99
221
 
@@ -121,18 +243,17 @@ NOTE: Recent library updates are more than a year ago, and the current
121
243
  version of the Jupyter Notebook *JupyterLab* application, unfortunately,
122
244
  *not* supported (yet).
123
245
 
124
- == Notebooks vs. Textbooks
246
+ === Notebooks vs. Textbooks
125
247
 
126
- Jupyter Notebooks with the extension `.ipynb` are (data) files in JSON
127
- format and can only be run using the *App* of Jupyter Notebook. On the
248
+ Jupyter Notebook documents with the extension `.ipynb` are (data) files in
249
+ JSON format and can only be run using the *App* of Jupyter Notebook. On the
128
250
  other hand, Textbooks are HTML exports with the extension `.html` from
129
251
  Jupyter Notebooks to be viewed in a web browser.
130
252
 
131
253
  For integrating textbooks in webpages, the notebooks with the extension
132
- `.ipynb` are to be *exported* to HTML (text) files using the
133
- (Python) program nbinteract. Textbooks that have already been exported
134
- can be found for the *Starter Web* in the folder
135
- `~/pages/public/jupyter/notebooks/textbooks`.
254
+ `.ipynb` are to be *exported* to HTML (text) files using the (Python)
255
+ program nbinteract. Textbooks that have already been exported can be found
256
+ for the *Starter Web* in the folder `~/pages/public/jupyter/notebooks/textbooks`.
136
257
 
137
258
  == J1 NBI Configuration
138
259
 
@@ -319,7 +440,7 @@ settings:
319
440
  The use of J1 NBI requires a valid Binder configuration. The binder
320
441
  configuration is to be provided via a public Git repo. An example of such a
321
442
  Git repo you find on Github at
322
- https://github.com/jekyll-one/nbinteract-notebooks[Binder Repo, {browser-window--new}].
443
+ link:{url-j1--gh-binder-repo}[J1 Binder Repo, {browser-window--new}].
323
444
  The configuration settings are described in the <<Default settings>> section.
324
445
 
325
446
  === Textbook configuration
@@ -379,13 +500,13 @@ textbook::<notebook-id>[]
379
500
  Einbinden des Textbooks mit der ID `j1_docs_example_dynamic` in eine Webseite.
380
501
 
381
502
  .Example
382
- [source, conf, role="noclip"]
503
+ [source, conf]
383
504
  ----
384
505
  textbook::j1_docs_example_dynamic[]
385
506
  ----
386
507
 
387
508
 
388
- == Textbook Examples
509
+ == NBI Textbook Examples
389
510
 
390
511
  For the J1 template, textbooks are typically integrated as *dynamic* HTML
391
512
  pages. In addition to the dynamic pages, textbooks can also be integrated as
@@ -400,7 +521,7 @@ various *static* formats. For more details, refer to
400
521
  link:{url-nbconvert--doc}[nbconvert - usage, {browser-window--new}].
401
522
 
402
523
  .Generate a static Textbook
403
- [source, bash]
524
+ [source, sh]
404
525
  ----
405
526
  jupyter nbconvert --execute --to html <full_path_to>/<notebook.ipynb>
406
527
  ----
@@ -414,7 +535,7 @@ include::{documentdir}/j1_docs_example_static.asciidoc[]
414
535
  *Dynamic* Textbooks are generated using `nbinteract`:
415
536
 
416
537
  .Generate a dynamic Textbook (J1 Version)
417
- [source, bash]
538
+ [source, sh]
418
539
  ----
419
540
  nbinteract <full_path_to>/<notebook.ipynb> -t plain -s fake/fake
420
541
  ----
@@ -426,123 +547,3 @@ textbook::j1_docs_example_dynamic[]
426
547
  Compare both textbook versions, dynamic versus static, in terms of
427
548
  *interactivity*. Again, compare the _Evaluation_ section at section
428
549
  <<Dynamic Textbook>> with the static conterpart at <<Static Textbook>>.
429
-
430
-
431
-
432
-
433
-
434
-
435
- /////
436
- == Backgrounds
437
-
438
- lorem:sentences[5]
439
-
440
- === Jupyter
441
-
442
- Das Jupyter Projekt ist eine Non-Profit-Organisation, gegründet im Jahr 2014
443
- von *Fernando Pérez*. Das Projekt Jupyter unterstützt interaktive wissenschaftliche
444
- Datenauswertungen und wissenschaftliche Berechnungen.
445
-
446
- Der Name Jupyter bezieht sich auf die drei wesentlichen Programmiersprachen
447
- Julia, Python und R die von der Anwendung <<Jupyter Notebook App>> unterstützt
448
- werden. Die Bezeichnung *Jupyter* ist eine Hommage an die *Notizbucheinträge*
449
- von Galileo Galilei zur Entdeckung der Jupitermonde, bei denen er seine
450
- Beobachtungen und die Messdaten zusammen aufgeschrieben hatte.
451
-
452
- ==== Jupyter Notebook App
453
-
454
- Die App *Jupyter Notebook* ist eine Server-Client-Anwendung, mit der
455
- Notebook-Dokumente über einen Webbrowser bearbeitet und ausgeführt werden
456
- können. Jupyter Notebook kann auf einem lokalen Desktop ausgeführt
457
- werden der keinen Internetzugang erfordert. Alternativ kann die Anwendung auf
458
- einem Remote-Server installiert und über das Internet aufgerufen werden, die
459
- dann *keine* Installation erforderlich macht.
460
-
461
- ==== Notebook documents
462
-
463
- Notebook-Dokumente (oder kurz: *notebooks*) sind Dokumente, die von der Notebook
464
- App erstellt wurden und sowohl Computercode (z. B. Python) als auch Rich-Text
465
- Elemente (Absätze, Gleichungen, Abbildungen, Links usw.) enthalten können.
466
- Notebook Dokumente sind menschenlesbare Dokumente, die neben Code Beschreibungen
467
- und deren Ergebnisse (Abbildungen, Tabellen usw.) enthalten.
468
-
469
- ==== Kernels
470
-
471
- Ein Notebook Kernel ist ganz allgemein eine *Rechenmaschine*, die den in einem
472
- Notebook-Dokument enthaltenen Code ausführt. Der *Ipython* Kernel, der für die
473
- NBI Integration verwendet wird, führt Python-Code aus erzeugt die Ergebnisse.
474
-
475
- === nbinteract
476
-
477
- Der Name der Library `nbinteract` deutet zwei generelle Funktionen für
478
- Jupyter Notebooks an:
479
-
480
- `nb`, textbook::
481
- Verarbeitung von Notebooks
482
- // (als HTML Darstellung)
483
-
484
- `interact`::
485
- Ausführen von Notebooks in Zusammenarbeit mit einem (remoten) Verarbeitungs
486
- System und Darstellung der Ergebnisse
487
-
488
-
489
- ==== Requirements
490
-
491
- Für die Entwicklung eigener Jupyter Notebooks ist eine *lokale*
492
- Installation der Programmiersprache *Python* erforderlich. Zur Entwicklung
493
- von Notebooks wird zusätzlich das Paket *Jupyter* sowie die Installation der
494
- Python Library *nbinteract* erwartet.
495
-
496
- ==== Widgets
497
-
498
- Ein Widget ist ein Element einer grafischen Benutzeroberfläche (GUI), das
499
- Informationen anzeigt oder einem Benutzer eine bestimmte Möglichkeit bietet,
500
- mit dem Betriebssystem oder einer Anwendung zu interagieren.
501
-
502
- Zu den Widgets gehören Symbole, Pulldown-Menüs, Schaltflächen, Auswahlfelder,
503
- Fortschrittsanzeigen, Ein-Aus-Häkchen, Bildlaufleisten, Fenster, Fensterränder
504
- (mit denen Sie die Größe des Fensters ändern können), Umschaltflächen,
505
- Formulare und viele andere Geräte zum Anzeigen von Informationen und zum
506
- Einladen, Akzeptieren und Reagieren auf Benutzeraktionen.
507
-
508
-
509
- ==== BinderHub
510
-
511
- // UserGuide: https://mybinder.readthedocs.io/en/latest/about/about.html
512
-
513
- Mit Binder (myBinder) können Sie benutzerdefinierte (virtuelle) Computerumgebungen
514
- erstellen, die von vielen Benutzern remote aus einer Cloud gemeinsam genutzt
515
- werden können.
516
-
517
- // erzeugt Docker Container
518
- // installiert Python Software
519
- // installiert Jupyter Lab als Notebook App
520
-
521
- .Binderhub Architecture
522
- lightbox::binderhub--architecture[ 800, {data-binderhub--architecture}, role="mt-3 mb-4" ]
523
-
524
- ////
525
- Ein Binder-Dienst wird von BinderHub
526
- unterstützt, einem Open-Source-Tool, das auf Kubernetes ausgeführt wird,
527
- einer tragbaren, erweiterbaren Open-Source-Plattform zum Verwalten von
528
- containerisierten Diensten. Eine solche Bereitstellung befindet sich auf
529
- mybinder.org und kann kostenlos verwendet werden.
530
- ////
531
-
532
- ==== JupyterHub
533
-
534
- JupyterHub bringt die Leistung von Notebooks für Benutzergruppen. Es gibt
535
- Benutzern Zugriff auf Rechenumgebungen und Ressourcen, ohne die Benutzer mit
536
- Installations- und Wartungsaufgaben zu belasten. Benutzer, einschließlich
537
- Studenten, Forscher und Datenwissenschaftler, können ihre Arbeit in ihren
538
- eigenen Arbeitsbereichen auf gemeinsam genutzten Ressourcen erledigen, die
539
- von Systemadministratoren effizient verwaltet werden können.
540
-
541
- .JupyterLab Architecture
542
- lightbox::jupyterlab--architecture[ 800, {data-jupyterlab--architecture}, role="mt-3 mb-4" ]
543
-
544
- JupyterHub läuft in der Cloud oder auf Ihrer eigenen Hardware und ermöglicht
545
- es, jedem Benutzer weltweit eine vorkonfigurierte Data-Science-Umgebung
546
- bereitzustellen. Es ist anpassbar und skalierbar und eignet sich für kleine
547
- und große Teams, akademische Kurse und große Infrastrukturen.
548
- /////
@@ -31,14 +31,12 @@ keywords: >
31
31
  categories: [ Software, Python ]
32
32
  tags: [ Binder, API ]
33
33
 
34
- scrollbar: true
34
+ scrollbar: false
35
35
 
36
36
  permalink: /pages/public/jupyter/docs/nbi-widgets/
37
37
  regenerate: false
38
38
 
39
- resources: [
40
- animate, clipboard, lightbox, rouge
41
- ]
39
+ resources: [ animate, clipboard, lightbox, rouge ]
42
40
  resource_options:
43
41
  - attic:
44
42
  padding_top: 400
@@ -41,7 +41,7 @@
41
41
  {
42
42
  "data": {
43
43
  "application/vnd.jupyter.widget-view+json": {
44
- "model_id": "8b72ae22d66a48fa8928f0957b50720a",
44
+ "model_id": "80e67011ebc84f819837e00a9a151d93",
45
45
  "version_major": 2,
46
46
  "version_minor": 0
47
47
  },
@@ -76,7 +76,7 @@
76
76
  {
77
77
  "data": {
78
78
  "application/vnd.jupyter.widget-view+json": {
79
- "model_id": "1acaeb097d9c4ab198ddc396f3d7ef58",
79
+ "model_id": "20e6d0d9cac14ebab29bda33d4d07025",
80
80
  "version_major": 2,
81
81
  "version_minor": 0
82
82
  },
@@ -113,7 +113,7 @@
113
113
  {
114
114
  "data": {
115
115
  "application/vnd.jupyter.widget-view+json": {
116
- "model_id": "88f7491f8c974a97a44a12748e7a12c4",
116
+ "model_id": "bdfdc73016c74c08833477aed43de354",
117
117
  "version_major": 2,
118
118
  "version_minor": 0
119
119
  },
@@ -150,7 +150,7 @@
150
150
  {
151
151
  "data": {
152
152
  "application/vnd.jupyter.widget-view+json": {
153
- "model_id": "22e9aee944914093873cbf29bc3e9535",
153
+ "model_id": "96cfd375bcd84467b6ab5714dab866ff",
154
154
  "version_major": 2,
155
155
  "version_minor": 0
156
156
  },
@@ -164,7 +164,7 @@
164
164
  {
165
165
  "data": {
166
166
  "application/vnd.jupyter.widget-view+json": {
167
- "model_id": "eb8ee4f0804648759c96246f58756eb1",
167
+ "model_id": "de20afd9dd5941e1a356c2f98aad1d88",
168
168
  "version_major": 2,
169
169
  "version_minor": 0
170
170
  },
@@ -178,7 +178,7 @@
178
178
  {
179
179
  "data": {
180
180
  "application/vnd.jupyter.widget-view+json": {
181
- "model_id": "4fbcf95029144f6d9242ac6b17863ca6",
181
+ "model_id": "c60655e5c5824bc9a8cd6d9fc9654fae",
182
182
  "version_major": 2,
183
183
  "version_minor": 0
184
184
  },
@@ -192,7 +192,7 @@
192
192
  {
193
193
  "data": {
194
194
  "application/vnd.jupyter.widget-view+json": {
195
- "model_id": "c037d1ead9c94822b15414efb213550a",
195
+ "model_id": "2b3c300ad62d4e7f8ce50e66c8e3685d",
196
196
  "version_major": 2,
197
197
  "version_minor": 0
198
198
  },
@@ -232,7 +232,7 @@
232
232
  {
233
233
  "data": {
234
234
  "application/vnd.jupyter.widget-view+json": {
235
- "model_id": "5762b3ed32cb409ea453efae4114d8b6",
235
+ "model_id": "5f48de7d6d504bbb8efe421d05030f87",
236
236
  "version_major": 2,
237
237
  "version_minor": 0
238
238
  },
@@ -309,7 +309,7 @@
309
309
  {
310
310
  "data": {
311
311
  "application/vnd.jupyter.widget-view+json": {
312
- "model_id": "c5f30fddfd0d4b74a0f0b93aa55d3581",
312
+ "model_id": "640034312037443a86719cbda69dc6db",
313
313
  "version_major": 2,
314
314
  "version_minor": 0
315
315
  },
@@ -363,7 +363,7 @@
363
363
  {
364
364
  "data": {
365
365
  "application/vnd.jupyter.widget-view+json": {
366
- "model_id": "63920792634c4cfcb3aad7c51a9fc555",
366
+ "model_id": "22f14116bf2640cbb1d89c62e72c39dc",
367
367
  "version_major": 2,
368
368
  "version_minor": 0
369
369
  },
@@ -407,7 +407,7 @@
407
407
  {
408
408
  "data": {
409
409
  "application/vnd.jupyter.widget-view+json": {
410
- "model_id": "ad696a70d17c40509478b375a99fea37",
410
+ "model_id": "a2fc988f50b24e8ebb8694b59ca6b7ec",
411
411
  "version_major": 2,
412
412
  "version_minor": 0
413
413
  },
@@ -454,12 +454,12 @@
454
454
  {
455
455
  "data": {
456
456
  "application/vnd.jupyter.widget-view+json": {
457
- "model_id": "fa6b7bb55b55465d86b0294e8f7e1e89",
457
+ "model_id": "53d035e1b2774af382452721ecd593dc",
458
458
  "version_major": 2,
459
459
  "version_minor": 0
460
460
  },
461
461
  "text/plain": [
462
- "VBox(children=(Label(value='y = 0.98x + 0.71'), Figure(animation_duration=250, axes=[Axis(scale=LinearScale(ma…"
462
+ "VBox(children=(Label(value='y = 1.01x + 0.50'), Figure(animation_duration=250, axes=[Axis(scale=LinearScale(ma…"
463
463
  ]
464
464
  },
465
465
  "metadata": {},
@@ -494,7 +494,7 @@
494
494
  {
495
495
  "data": {
496
496
  "application/vnd.jupyter.widget-view+json": {
497
- "model_id": "62e1d524b6694436a5d50ec945c77351",
497
+ "model_id": "c81a6645722a45f79685c75a3d0f208b",
498
498
  "version_major": 2,
499
499
  "version_minor": 0
500
500
  },
@@ -532,7 +532,7 @@
532
532
  {
533
533
  "data": {
534
534
  "application/vnd.jupyter.widget-view+json": {
535
- "model_id": "0b24f585ea384d1a8c89e302f7c66319",
535
+ "model_id": "3921246d9d9b445f9fb0dc0c6a2ec2b8",
536
536
  "version_major": 2,
537
537
  "version_minor": 0
538
538
  },
@@ -557,6 +557,161 @@
557
557
  "\n",
558
558
  "nbi.line(x_values, y_values, max=(10, 50), sd=(1, 10), options=opts)"
559
559
  ]
560
+ },
561
+ {
562
+ "cell_type": "markdown",
563
+ "metadata": {},
564
+ "source": [
565
+ "## Interactive Questions from nbinteract\n",
566
+ "nbinteract also provides built-in methods to easily create multiple choice and short answer questions.\n"
567
+ ]
568
+ },
569
+ {
570
+ "cell_type": "markdown",
571
+ "metadata": {},
572
+ "source": [
573
+ "### nbinteract.multiple_choice\n",
574
+ "\n",
575
+ "`nbinteract.multiple_choice` takes a question, a list of possible answer choices, and the correct answer. Clicking the buttons shows whether the choice was correct."
576
+ ]
577
+ },
578
+ {
579
+ "cell_type": "code",
580
+ "execution_count": 13,
581
+ "metadata": {},
582
+ "outputs": [
583
+ {
584
+ "data": {
585
+ "application/vnd.jupyter.widget-view+json": {
586
+ "model_id": "801dde29de334eb39603b878ebf4f3d0",
587
+ "version_major": 2,
588
+ "version_minor": 0
589
+ },
590
+ "text/plain": [
591
+ "VBox(children=(HTML(value='<p style=\"line-height:18px;\">What is 10 + 2 * 5?</p>'), HBox(children=(Button(layou…"
592
+ ]
593
+ },
594
+ "metadata": {},
595
+ "output_type": "display_data"
596
+ }
597
+ ],
598
+ "source": [
599
+ "nbi.multiple_choice(question=\"What is 10 + 2 * 5?\",\n",
600
+ " choices=['12', '60', '20'],\n",
601
+ " answers=2)"
602
+ ]
603
+ },
604
+ {
605
+ "cell_type": "code",
606
+ "execution_count": 14,
607
+ "metadata": {
608
+ "scrolled": true
609
+ },
610
+ "outputs": [
611
+ {
612
+ "data": {
613
+ "application/vnd.jupyter.widget-view+json": {
614
+ "model_id": "4fef9b0a8cae4cf4a22ac74d8221f695",
615
+ "version_major": 2,
616
+ "version_minor": 0
617
+ },
618
+ "text/plain": [
619
+ "VBox(children=(HTML(value='<p style=\"line-height:18px;\">Select all prime numbers.</p>'), HBox(children=(Button…"
620
+ ]
621
+ },
622
+ "metadata": {},
623
+ "output_type": "display_data"
624
+ }
625
+ ],
626
+ "source": [
627
+ "nbi.multiple_choice(question=\"Select all prime numbers.\",\n",
628
+ " choices=['12', '3', '31'],\n",
629
+ " answers=[1, 2])"
630
+ ]
631
+ },
632
+ {
633
+ "cell_type": "markdown",
634
+ "metadata": {},
635
+ "source": [
636
+ "### nbinteract.short_answer\n",
637
+ "\n",
638
+ "`nbinteract.short_answer` takes a question and an answer.\n",
639
+ "\n",
640
+ "The answer can either be a string, a list of strings, or a function that returns `True` when called with the user's input. If the function errors, an error message will be displayed."
641
+ ]
642
+ },
643
+ {
644
+ "cell_type": "code",
645
+ "execution_count": 15,
646
+ "metadata": {},
647
+ "outputs": [
648
+ {
649
+ "data": {
650
+ "application/vnd.jupyter.widget-view+json": {
651
+ "model_id": "867f68ecb6eb4b0a8c45ab598ae0471e",
652
+ "version_major": 2,
653
+ "version_minor": 0
654
+ },
655
+ "text/plain": [
656
+ "VBox(children=(HTML(value='<p style=\"line-height:18px;\">What is 1+1?</p>'), HBox(children=(Text(value='', plac…"
657
+ ]
658
+ },
659
+ "metadata": {},
660
+ "output_type": "display_data"
661
+ }
662
+ ],
663
+ "source": [
664
+ "nbi.short_answer('What is 1+1?', answers='2', explanation='1+1 is 2')"
665
+ ]
666
+ },
667
+ {
668
+ "cell_type": "code",
669
+ "execution_count": 16,
670
+ "metadata": {},
671
+ "outputs": [
672
+ {
673
+ "data": {
674
+ "application/vnd.jupyter.widget-view+json": {
675
+ "model_id": "01f92e3dbe7148729b04e85d1946a750",
676
+ "version_major": 2,
677
+ "version_minor": 0
678
+ },
679
+ "text/plain": [
680
+ "VBox(children=(HTML(value='<p style=\"line-height:18px;\">Enter the first name of a member of the Beatles.</p>')…"
681
+ ]
682
+ },
683
+ "metadata": {},
684
+ "output_type": "display_data"
685
+ }
686
+ ],
687
+ "source": [
688
+ "nbi.short_answer('Enter the first name of a member of the Beatles.',\n",
689
+ " ['John', 'Paul', 'George', 'Ringo'])"
690
+ ]
691
+ },
692
+ {
693
+ "cell_type": "code",
694
+ "execution_count": 17,
695
+ "metadata": {},
696
+ "outputs": [
697
+ {
698
+ "data": {
699
+ "application/vnd.jupyter.widget-view+json": {
700
+ "model_id": "a4fc0e9264374e7b9c8dbb3e4122f8d5",
701
+ "version_major": 2,
702
+ "version_minor": 0
703
+ },
704
+ "text/plain": [
705
+ "VBox(children=(HTML(value='<p style=\"line-height:18px;\">Enter an even number.</p>'), HBox(children=(Text(value…"
706
+ ]
707
+ },
708
+ "metadata": {},
709
+ "output_type": "display_data"
710
+ }
711
+ ],
712
+ "source": [
713
+ "nbi.short_answer('Enter an even number.', lambda x: int(x) % 2 == 0)"
714
+ ]
560
715
  }
561
716
  ],
562
717
  "metadata": {