Greg Wilson commited on
Commit
915ca9b
·
1 Parent(s): 930b7f4

reorganizing tools

Browse files
tools/{03_wiggly.py → 01_wiggly.py} RENAMED
@@ -9,9 +9,10 @@
9
  # "wigglystuff==0.3.1",
10
  # ]
11
  # ///
 
12
  import marimo
13
 
14
- __generated_with = "0.20.4"
15
  app = marimo.App(width="full")
16
 
17
 
@@ -20,8 +21,7 @@ def _(mo):
20
  mo.md(r"""
21
  # wigglystuff Widgets
22
 
23
- This notebook demonstrates four widgets from the [wigglystuff](https://github.com/koaning/wigglystuff) package:
24
- `Slider2D`, `Matrix`, `HoverZoom`, and `TextCompare`.
25
  """)
26
  return
27
 
@@ -36,12 +36,8 @@ def _():
36
  matplotlib.use("Agg")
37
  import matplotlib.pyplot as plt
38
  from wigglystuff import Slider2D, Matrix, HoverZoom, TextCompare
39
- return HoverZoom, Matrix, Slider2D, TextCompare, alt, mo, np, pd, plt
40
-
41
 
42
- # ---------------------------------------------------------------------------
43
- # Slider2D
44
- # ---------------------------------------------------------------------------
45
 
46
 
47
  @app.cell(hide_code=True)
@@ -76,11 +72,6 @@ def _(mo, slider2d):
76
  return
77
 
78
 
79
- # ---------------------------------------------------------------------------
80
- # Matrix
81
- # ---------------------------------------------------------------------------
82
-
83
-
84
  @app.cell(hide_code=True)
85
  def _(mo):
86
  mo.md(r"""
@@ -100,7 +91,7 @@ def _(Matrix, mo, np, pd):
100
  rgb_df = pd.DataFrame(
101
  {"r": rgb_mat[:, 0], "g": rgb_mat[:, 1], "b": rgb_mat[:, 2], "color": color}
102
  )
103
- return color, pca_mat, rgb_df, rgb_mat
104
 
105
 
106
  @app.cell
@@ -117,11 +108,6 @@ def _(alt, color, mo, pca_mat, pd, rgb_mat):
117
  return
118
 
119
 
120
- # ---------------------------------------------------------------------------
121
- # HoverZoom
122
- # ---------------------------------------------------------------------------
123
-
124
-
125
  @app.cell(hide_code=True)
126
  def _(mo):
127
  mo.md(r"""
@@ -157,11 +143,6 @@ def _(HoverZoom, fig, mo):
157
  return
158
 
159
 
160
- # ---------------------------------------------------------------------------
161
- # TextCompare
162
- # ---------------------------------------------------------------------------
163
-
164
-
165
  @app.cell(hide_code=True)
166
  def _(mo):
167
  mo.md(r"""
@@ -188,12 +169,14 @@ def _(TextCompare, mo):
188
 
189
  compare = mo.ui.anywidget(TextCompare(text_a=text_a, text_b=text_b, min_match_words=3))
190
  compare
191
- return compare, text_a, text_b
192
 
193
 
194
  @app.cell
195
  def _(compare, mo):
196
- mo.md(f"**Found {len(compare.matches)} matching passages**")
 
 
197
  return
198
 
199
 
 
9
  # "wigglystuff==0.3.1",
10
  # ]
11
  # ///
12
+
13
  import marimo
14
 
15
+ __generated_with = "0.23.1"
16
  app = marimo.App(width="full")
17
 
18
 
 
21
  mo.md(r"""
22
  # wigglystuff Widgets
23
 
24
+ This notebook demonstrates four widgets from [Vincent van Warmerdam](https://koaning.io/)'s [wigglystuff](https://koaning.github.io/wigglystuff/) package. They are useful in their own right, and also show how easy it is to build custom plugins for marimo using [AnyWidget](https://anywidget.dev/) to meet your teaching needs.
 
25
  """)
26
  return
27
 
 
36
  matplotlib.use("Agg")
37
  import matplotlib.pyplot as plt
38
  from wigglystuff import Slider2D, Matrix, HoverZoom, TextCompare
 
 
39
 
40
+ return HoverZoom, Matrix, Slider2D, TextCompare, alt, mo, np, pd, plt
 
 
41
 
42
 
43
  @app.cell(hide_code=True)
 
72
  return
73
 
74
 
 
 
 
 
 
75
  @app.cell(hide_code=True)
76
  def _(mo):
77
  mo.md(r"""
 
91
  rgb_df = pd.DataFrame(
92
  {"r": rgb_mat[:, 0], "g": rgb_mat[:, 1], "b": rgb_mat[:, 2], "color": color}
93
  )
94
+ return color, pca_mat, rgb_mat
95
 
96
 
97
  @app.cell
 
108
  return
109
 
110
 
 
 
 
 
 
111
  @app.cell(hide_code=True)
112
  def _(mo):
113
  mo.md(r"""
 
143
  return
144
 
145
 
 
 
 
 
 
146
  @app.cell(hide_code=True)
147
  def _(mo):
148
  mo.md(r"""
 
169
 
170
  compare = mo.ui.anywidget(TextCompare(text_a=text_a, text_b=text_b, min_match_words=3))
171
  compare
172
+ return (compare,)
173
 
174
 
175
  @app.cell
176
  def _(compare, mo):
177
+ mo.md(f"""
178
+ **Found {len(compare.matches)} matching passages**
179
+ """)
180
  return
181
 
182
 
tools/{01_widgets.py → 02_formative.py} RENAMED
@@ -3,7 +3,7 @@
3
  # dependencies = [
4
  # "anywidget",
5
  # "marimo",
6
- # "marimo-learn",
7
  # ]
8
  # ///
9
 
@@ -16,7 +16,7 @@ Run with: marimo edit demo.py
16
 
17
  import marimo
18
 
19
- __generated_with = "0.20.4"
20
  app = marimo.App()
21
 
22
 
@@ -24,7 +24,6 @@ app = marimo.App()
24
  def _():
25
  import marimo as mo
26
  from marimo_learn import (
27
- Color,
28
  ConceptMapWidget,
29
  FlashcardWidget,
30
  LabelingWidget,
@@ -33,11 +32,9 @@ def _():
33
  NumericEntryWidget,
34
  OrderingWidget,
35
  PredictThenCheckWidget,
36
- World,
37
  )
38
 
39
  return (
40
- Color,
41
  ConceptMapWidget,
42
  FlashcardWidget,
43
  LabelingWidget,
@@ -46,37 +43,20 @@ def _():
46
  NumericEntryWidget,
47
  OrderingWidget,
48
  PredictThenCheckWidget,
49
- World,
50
  )
51
 
52
 
53
  @app.cell
54
  def _(mo):
55
  mo.md("""
56
- # Educational Widgets Demo
57
 
58
- This notebook demonstrates widgets in marimo_learn.
59
  """)
60
  return
61
 
62
 
63
- # Spiral
64
- @app.cell
65
- def _(Color, World, mo):
66
- _world = World()
67
-
68
- async def _spiral(world, turtle):
69
- colors = list(Color)
70
- for i in range(70):
71
- if i % 10 == 0:
72
- turtle.set_color(colors[(i // 10) % len(colors)])
73
- await turtle.forward(i * 2.8)
74
- turtle.right(91)
75
-
76
- _world.set_coroutine(_spiral)
77
- mo.ui.anywidget(_world)
78
-
79
-
80
  @app.cell
81
  def _(mo):
82
  mo.md("""
@@ -288,7 +268,7 @@ def _(MultipleChoiceWidget, mo):
288
 
289
 
290
  @app.cell
291
- def _(multiple_choice_question, mo):
292
  _val = multiple_choice_question.value.get("value") or {}
293
  if _val.get("answered"):
294
  _msg = "Score: 1/1" if _val.get("correct") else "Score: 0/1"
@@ -427,8 +407,8 @@ def _(
427
  concept_map,
428
  flashcard_deck,
429
  matching_question,
430
- multiple_choice_question,
431
  mo,
 
432
  numeric_entry_question,
433
  ordering_question,
434
  predict_then_check_question,
 
3
  # dependencies = [
4
  # "anywidget",
5
  # "marimo",
6
+ # "marimo-learn==0.13.0",
7
  # ]
8
  # ///
9
 
 
16
 
17
  import marimo
18
 
19
+ __generated_with = "0.23.1"
20
  app = marimo.App()
21
 
22
 
 
24
  def _():
25
  import marimo as mo
26
  from marimo_learn import (
 
27
  ConceptMapWidget,
28
  FlashcardWidget,
29
  LabelingWidget,
 
32
  NumericEntryWidget,
33
  OrderingWidget,
34
  PredictThenCheckWidget,
 
35
  )
36
 
37
  return (
 
38
  ConceptMapWidget,
39
  FlashcardWidget,
40
  LabelingWidget,
 
43
  NumericEntryWidget,
44
  OrderingWidget,
45
  PredictThenCheckWidget,
46
+ mo,
47
  )
48
 
49
 
50
  @app.cell
51
  def _(mo):
52
  mo.md("""
53
+ # Formative Assessment Widgets
54
 
55
+ This notebook demonstrates several widgets from the [marimo-learn](https://pypi.org/project/marimo-learn/) package that you can use to embed formative assessments in your lessons. They also show how easy it is to build custom plugins for the marimo notebook to meet your teaching needs.
56
  """)
57
  return
58
 
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  @app.cell
61
  def _(mo):
62
  mo.md("""
 
268
 
269
 
270
  @app.cell
271
+ def _(mo, multiple_choice_question):
272
  _val = multiple_choice_question.value.get("value") or {}
273
  if _val.get("answered"):
274
  _msg = "Score: 1/1" if _val.get("correct") else "Score: 0/1"
 
407
  concept_map,
408
  flashcard_deck,
409
  matching_question,
 
410
  mo,
411
+ multiple_choice_question,
412
  numeric_entry_question,
413
  ordering_question,
414
  predict_then_check_question,
tools/{02_turtles.py → 03_turtles.py} RENAMED
@@ -3,7 +3,7 @@
3
  # dependencies = [
4
  # "anywidget",
5
  # "marimo",
6
- # "marimo-learn",
7
  # ]
8
  # ///
9
 
@@ -13,7 +13,7 @@ Example Marimo Notebook: Turtle Graphics
13
 
14
  import marimo
15
 
16
- __generated_with = "0.20.4"
17
  app = marimo.App()
18
 
19
 
@@ -25,24 +25,19 @@ def _():
25
  World,
26
  )
27
 
28
- return (
29
- Color,
30
- World,
31
- )
32
 
33
 
34
  @app.cell
35
  def _(mo):
36
  mo.md("""
37
- # Turtle Graphics Demo
38
 
39
- This notebook demonstrates turtle graphics in marimo_learn.
40
- See [the documentation](https://github.com/gvwilson/marimo_learn) for details.
41
  """)
42
  return
43
 
44
 
45
- # Spiral
46
  @app.cell
47
  def _(Color, World, mo):
48
  _world = World()
@@ -57,6 +52,7 @@ def _(Color, World, mo):
57
 
58
  _world.set_coroutine(_spiral)
59
  mo.ui.anywidget(_world)
 
60
 
61
 
62
  if __name__ == "__main__":
 
3
  # dependencies = [
4
  # "anywidget",
5
  # "marimo",
6
+ # "marimo-learn==0.13.0",
7
  # ]
8
  # ///
9
 
 
13
 
14
  import marimo
15
 
16
+ __generated_with = "0.23.1"
17
  app = marimo.App()
18
 
19
 
 
25
  World,
26
  )
27
 
28
+ return Color, World, mo
 
 
 
29
 
30
 
31
  @app.cell
32
  def _(mo):
33
  mo.md("""
34
+ # Turtle Graphics
35
 
36
+ The [marimo-learn](https://pypi.org/project/marimo-learn/) package includes a simple implementation of turtle graphics. Learners can create worlds, and then write functions to make a turtle draw multi-colored shapes. Crucially, this widget was created in only 15 minutes with the assistance of an LLM, which shows just how easy it now is for educators to create tools that meet their specific needs.
 
37
  """)
38
  return
39
 
40
 
 
41
  @app.cell
42
  def _(Color, World, mo):
43
  _world = World()
 
52
 
53
  _world.set_coroutine(_spiral)
54
  mo.ui.anywidget(_world)
55
+ return
56
 
57
 
58
  if __name__ == "__main__":