Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

chore: reorganize examples (#2162)

Akshay Agrawale93956254b54
diff --git a/.gitignore b/.gitignore
index a309e21596..631f791898 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
*.txt
# Byte-compiled / optimized / DLL files
+__pycache__
__pycache__/
*.py[cod]
*$py.class
diff --git a/examples/model_comparison/model_comparison.py b/examples/ai/model_comparison/model_comparison.py
similarity index 100%
rename from examples/model_comparison/model_comparison.py
rename to examples/ai/model_comparison/model_comparison.py
diff --git a/examples/integrations/google_cloud_bigquery.py b/examples/google/google_cloud_bigquery.py
similarity index 100%
rename from examples/integrations/google_cloud_bigquery.py
rename to examples/google/google_cloud_bigquery.py
diff --git a/examples/integrations/google_cloud_storage.py b/examples/google/google_cloud_storage.py
similarity index 100%
rename from examples/integrations/google_cloud_storage.py
rename to examples/google/google_cloud_storage.py
diff --git a/examples/integrations/google_sheets.py b/examples/google/google_sheets.py
similarity index 100%
rename from examples/integrations/google_sheets.py
rename to examples/google/google_sheets.py
diff --git a/examples/arrays_and_dicts.py b/examples/marimo/arrays_and_dicts.py
similarity index 100%
rename from examples/arrays_and_dicts.py
rename to examples/marimo/arrays_and_dicts.py
diff --git a/examples/batch_and_form.py b/examples/marimo/batch_and_form.py
similarity index 100%
rename from examples/batch_and_form.py
rename to examples/marimo/batch_and_form.py
diff --git a/examples/character_count.py b/examples/marimo/character_count.py
similarity index 100%
rename from examples/character_count.py
rename to examples/marimo/character_count.py
diff --git a/examples/data_explorer.py b/examples/marimo/data_explorer.py
similarity index 100%
rename from examples/data_explorer.py
rename to examples/marimo/data_explorer.py
diff --git a/examples/layout.py b/examples/marimo/layout.py
similarity index 100%
rename from examples/layout.py
rename to examples/marimo/layout.py
diff --git a/examples/third_party/mermaid.py b/examples/marimo/mermaid.py
similarity index 100%
rename from examples/third_party/mermaid.py
rename to examples/marimo/mermaid.py
diff --git a/examples/reactive_plots.py b/examples/marimo/reactive_plots.py
similarity index 100%
rename from examples/reactive_plots.py
rename to examples/marimo/reactive_plots.py
diff --git a/examples/refresh.py b/examples/marimo/refresh.py
similarity index 100%
rename from examples/refresh.py
rename to examples/marimo/refresh.py
diff --git a/examples/table.py b/examples/marimo/table.py
similarity index 100%
rename from examples/table.py
rename to examples/marimo/table.py
diff --git a/examples/tabs.py b/examples/marimo/tabs.py
similarity index 100%
rename from examples/tabs.py
rename to examples/marimo/tabs.py
diff --git a/examples/task_list.py b/examples/marimo/task_list.py
similarity index 100%
rename from examples/task_list.py
rename to examples/marimo/task_list.py
diff --git a/examples/sine_wave.py b/examples/sine_wave.py
deleted file mode 100644
index 499e1ac79b..0000000000
--- a/examples/sine_wave.py
+++ /dev/null
@@ -1,63 +0,0 @@
-import marimo
-
-__generated_with = "0.1.0"
-app = marimo.App()
-
-
-def __(mo):
- mo.md("# Plotting a Sine Wave")
- return
-
-
-def __(mo, np):
- period = mo.ui.slider(start=np.pi, stop=2*np.pi, label="period")
- amplitude = mo.ui.slider(start=1, stop=2, step=0.1, label="amplitude")
-
- [period, amplitude]
- return amplitude, period
-
-
-def __(amplitude, mo, period):
- mo.md(
- rf"""
- Here's a plot of
- $f(x) = {amplitude.value:.02f}\sin((2\pi/{period.value:.02f}) x)$:
- """
- )
- return
-
-
-def __(amplitude, period, plot_sine_wave):
- plot_sine_wave(period.value, amplitude.value)
- return
-
-
-def __(np, plt):
- def plot_sine_wave(period, amplitude):
- x = np.linspace(0, 2*np.pi, num=100)
- plt.figure(figsize=(6.7, 2.5))
- plt.plot(x, amplitude*np.sin(x*2*np.pi / period))
- plt.xlabel('$x$')
- plt.xlim(0, 2*np.pi)
- plt.ylim(-2, 2)
- plt.tight_layout()
- return plt.gca()
- return plot_sine_wave,
-
-
-def __():
- import marimo as mo
-
- import numpy as np
- import matplotlib.pyplot as plt
- return mo, np, plt
-
-
-if __name__ == "__main__":
- app.run()
diff --git a/examples/anywidget/reactive_quak.py b/examples/third_party/anywidget/reactive_quak.py
similarity index 85%
rename from examples/anywidget/reactive_quak.py
rename to examples/third_party/anywidget/reactive_quak.py
index b7694596dc..a5c8f48d91 100644
--- a/examples/anywidget/reactive_quak.py
+++ b/examples/third_party/anywidget/reactive_quak.py
@@ -1,6 +1,17 @@
+# /// script
+# requires-python = ">=3.12"
+# dependencies = [
+# "altair",
+# "polars",
+# "marimo",
+# "quak",
+# "pandas",
+# ]
+# ///
+
import marimo
-__generated_with = "0.7.13"
+__generated_with = "0.8.2"
app = marimo.App(width="medium")
@@ -20,7 +31,7 @@ def __(mo, pl, quak):
return df, widget
[email protected](hide_code=True)
def __(grouped_selection, mo):
import altair as alt
@@ -48,7 +59,6 @@ def __(widget):
def __(selection):
selection["count"] = 1
grouped_selection = selection[["nationality", "count"]].groupby(["nationality"]).agg("count").reset_index()
- grouped_selection
return grouped_selection,
diff --git a/examples/anywidget/tldraw_colorpicker.py b/examples/third_party/anywidget/tldraw_colorpicker.py
similarity index 100%
rename from examples/anywidget/tldraw_colorpicker.py
rename to examples/third_party/anywidget/tldraw_colorpicker.py
diff --git a/examples/optimization/regularization_and_sparsity.py b/examples/third_party/cvxpy/regularization_and_sparsity.py
similarity index 100%
rename from examples/optimization/regularization_and_sparsity.py
rename to examples/third_party/cvxpy/regularization_and_sparsity.py
diff --git a/examples/optimization/signals/app.py b/examples/third_party/cvxpy/signals/app.py
similarity index 100%
rename from examples/optimization/signals/app.py
rename to examples/third_party/cvxpy/signals/app.py
diff --git a/examples/optimization/signals/assets/solar_power_soiling_reference.png b/examples/third_party/cvxpy/signals/assets/solar_power_soiling_reference.png
similarity index 100%
rename from examples/optimization/signals/assets/solar_power_soiling_reference.png
rename to examples/third_party/cvxpy/signals/assets/solar_power_soiling_reference.png
diff --git a/examples/optimization/signals/examples.py b/examples/third_party/cvxpy/signals/examples.py
similarity index 100%
rename from examples/optimization/signals/examples.py
rename to examples/third_party/cvxpy/signals/examples.py
diff --git a/examples/optimization/signals/modules/__init__.py b/examples/third_party/cvxpy/signals/modules/__init__.py
similarity index 100%
rename from examples/optimization/signals/modules/__init__.py
rename to examples/third_party/cvxpy/signals/modules/__init__.py
diff --git a/examples/optimization/signals/modules/components.py b/examples/third_party/cvxpy/signals/modules/components.py
similarity index 100%
rename from examples/optimization/signals/modules/components.py
rename to examples/third_party/cvxpy/signals/modules/components.py
diff --git a/examples/optimization/signals/modules/dataloaders.py b/examples/third_party/cvxpy/signals/modules/dataloaders.py
similarity index 100%
rename from examples/optimization/signals/modules/dataloaders.py
rename to examples/third_party/cvxpy/signals/modules/dataloaders.py
diff --git a/examples/optimization/signals/modules/explainer.py b/examples/third_party/cvxpy/signals/modules/explainer.py
similarity index 100%
rename from examples/optimization/signals/modules/explainer.py
rename to examples/third_party/cvxpy/signals/modules/explainer.py
diff --git a/examples/optimization/signals/modules/intro_problem.py b/examples/third_party/cvxpy/signals/modules/intro_problem.py
similarity index 100%
rename from examples/optimization/signals/modules/intro_problem.py
rename to examples/third_party/cvxpy/signals/modules/intro_problem.py
diff --git a/examples/optimization/signals/modules/layout.py b/examples/third_party/cvxpy/signals/modules/layout.py
similarity index 100%
rename from examples/optimization/signals/modules/layout.py
rename to examples/third_party/cvxpy/signals/modules/layout.py
diff --git a/examples/optimization/signals/modules/problems.py b/examples/third_party/cvxpy/signals/modules/problems.py
similarity index 100%
rename from examples/optimization/signals/modules/problems.py
rename to examples/third_party/cvxpy/signals/modules/problems.py
diff --git a/examples/optimization/signals/modules/solutions.py b/examples/third_party/cvxpy/signals/modules/solutions.py
similarity index 100%
rename from examples/optimization/signals/modules/solutions.py
rename to examples/third_party/cvxpy/signals/modules/solutions.py
diff --git a/examples/optimization/smallest_enclosing_circle.py b/examples/third_party/cvxpy/smallest_enclosing_circle.py
similarity index 100%
rename from examples/optimization/smallest_enclosing_circle.py
rename to examples/third_party/cvxpy/smallest_enclosing_circle.py
diff --git a/examples/third_party/duckdb_example.py b/examples/third_party/duckdb/duckdb_example.py
similarity index 100%
rename from examples/third_party/duckdb_example.py
rename to examples/third_party/duckdb/duckdb_example.py
diff --git a/examples/tables/coffee-sales.json b/examples/third_party/great_tables/coffee-sales.json
similarity index 100%
rename from examples/tables/coffee-sales.json
rename to examples/third_party/great_tables/coffee-sales.json
diff --git a/examples/tables/great_tables_example.py b/examples/third_party/great_tables/great_tables_example.py
similarity index 100%
rename from examples/tables/great_tables_example.py
rename to examples/third_party/great_tables/great_tables_example.py
diff --git a/examples/third_party/leafmap_example.py b/examples/third_party/leafmap/leafmap_example.py
similarity index 100%
rename from examples/third_party/leafmap_example.py
rename to examples/third_party/leafmap/leafmap_example.py
diff --git a/examples/geometry/mandelbrot.py b/examples/third_party/matplotlib/mandelbrot.py
similarity index 100%
rename from examples/geometry/mandelbrot.py
rename to examples/third_party/matplotlib/mandelbrot.py
diff --git a/examples/geometry/surfaces.py b/examples/third_party/matplotlib/surfaces.py
similarity index 100%
rename from examples/geometry/surfaces.py
rename to examples/third_party/matplotlib/surfaces.py
diff --git a/examples/third_party/plotly_image_selection.py b/examples/third_party/plotly/image_selection.py
similarity index 100%
rename from examples/third_party/plotly_image_selection.py
rename to examples/third_party/plotly/image_selection.py
diff --git a/examples/third_party/mapbox.py b/examples/third_party/plotly/mapbox.py
similarity index 100%
rename from examples/third_party/mapbox.py
rename to examples/third_party/plotly/mapbox.py
diff --git a/examples/third_party/polars_example.py b/examples/third_party/polars/polars_example.py
similarity index 100%
rename from examples/third_party/polars_example.py
rename to examples/third_party/polars/polars_example.py
diff --git a/examples/ai/substrate-run.py b/examples/third_party/substrate/video_generation.py
similarity index 100%
rename from examples/ai/substrate-run.py
rename to examples/third_party/substrate/video_generation.py