diff --git a/notebooks/00-preface/01-setup.md b/notebooks/00-preface/01-setup.md index 9505bf5f..c4162019 100644 --- a/notebooks/00-preface/01-setup.md +++ b/notebooks/00-preface/01-setup.md @@ -32,4 +32,4 @@ That's it! The `--sandbox` flag ensures a clean, isolated environment for runnin - The `--sandbox` flag creates an isolated environment for each notebook, preventing dependency conflicts - All required packages are automatically installed when you run the notebook -This approach eliminates the need for manual environment setup, conda environments, or Docker containers while ensuring reproducible execution of the tutorial content. \ No newline at end of file +This approach eliminates the need for manual environment setup, conda environments, or Docker containers while ensuring reproducible execution of the tutorial content. diff --git a/notebooks/00-preface/01-setup.py b/notebooks/00-preface/01-setup.py index b8fc5868..b4ce0f03 100644 --- a/notebooks/00-preface/01-setup.py +++ b/notebooks/00-preface/01-setup.py @@ -52,7 +52,7 @@ def _(mo): Once Marimo is launched, on the bottom, click on "on startup", "on cel change", and "on module change" to disable automatic execution. This will allow us to mimic original Jupyter behaviour, which is advantageous for a teaching setting (but toggle them back to "autorun" ) - + That's it! The `--sandbox` flag ensures a clean, isolated environment for running the notebooks with all necessary dependencies automatically managed. """ ) @@ -79,6 +79,7 @@ def _(mo): @app.cell(hide_code=True) def _(): import marimo as mo + return (mo,) diff --git a/notebooks/00-preface/03-goals.py b/notebooks/00-preface/03-goals.py index 5b3eee93..589cce46 100644 --- a/notebooks/00-preface/03-goals.py +++ b/notebooks/00-preface/03-goals.py @@ -83,8 +83,9 @@ def __(mo): @app.cell(hide_code=True) def __(): import marimo as mo - return mo, + + return (mo,) if __name__ == "__main__": - app.run() \ No newline at end of file + app.run() diff --git a/notebooks/01-introduction/__marimo__/session/02-networkx-intro.py.json b/notebooks/01-introduction/__marimo__/session/02-networkx-intro.py.json index 453ba09f..5aa8b5f7 100644 --- a/notebooks/01-introduction/__marimo__/session/02-networkx-intro.py.json +++ b/notebooks/01-introduction/__marimo__/session/02-networkx-intro.py.json @@ -801,4 +801,4 @@ "console": [] } ] -} \ No newline at end of file +} diff --git a/notebooks/02-algorithms/02-paths.py b/notebooks/02-algorithms/02-paths.py index 32502711..142a0bb4 100644 --- a/notebooks/02-algorithms/02-paths.py +++ b/notebooks/02-algorithms/02-paths.py @@ -140,7 +140,6 @@ def _(mo): def _(____, _____, _________, ___________, _____________, _________________): # FILL IN THE BLANKS BELOW - def path_exists(node1, node2, G): """ This function checks whether a path exists between two nodes (node1, @@ -172,6 +171,7 @@ def path_exists(node1, node2, G): # print('Path does not exist between nodes {0} and {1}'.format(node1, node2)) return False + return (path_exists,) @@ -190,7 +190,6 @@ def _(G, path_exists): from random import sample import networkx as nx - def test_path_exists(N): """ N: The number of times to spot-check. @@ -200,7 +199,6 @@ def test_path_exists(N): assert path_exists(n1, n2, G) == bool(nx.shortest_path(G, n1, n2)) return True - # Uncomment the next line to check the tests. # assert test_path_exists(10) return (nx,) @@ -332,12 +330,10 @@ def _(mo): def _(plt): from nams.solutions.paths import plot_path_with_neighbors - def plot_path_with_neighbors_answer(G, node1, node2): # Your answer here plt.show() - # Now execute `plot_path_with_neighbors_answer` return (plot_path_with_neighbors,) @@ -512,6 +508,7 @@ def _(): @app.cell def _(): import marimo as mo + return (mo,) diff --git a/notebooks/02-algorithms/03-structures.py b/notebooks/02-algorithms/03-structures.py index 354506ca..50c913eb 100644 --- a/notebooks/02-algorithms/03-structures.py +++ b/notebooks/02-algorithms/03-structures.py @@ -148,7 +148,6 @@ def in_triangle(G, node): # Your answer here pass - # COMMENT OUT THE IMPORT LINE TO TEST YOUR ANSWER from nams.solutions.structures import in_triangle @@ -173,13 +172,11 @@ def _(G, in_triangle): from random import sample import networkx as nx - def test_in_triangle(): nodes = sample(list(G.nodes()), 10) for node in nodes: assert in_triangle(G, 3) == bool(nx.triangles(G, 3)) - test_in_triangle() return (nx,) @@ -226,7 +223,6 @@ def get_triangle_neighbors(G, n): # Your answer here pass - # COMMENT OUT THE IMPORT LINE TO TEST YOUR ANSWER from nams.solutions.structures import get_triangle_neighbors @@ -241,7 +237,6 @@ def plot_triangle_relations(G, n): # Your answer here pass - # COMMENT OUT THE IMPORT LINE TO TEST YOUR ANSWER from nams.solutions.structures import plot_triangle_relations @@ -309,7 +304,6 @@ def get_open_triangles_neighbors(G, n): # Your answer here pass - # COMMENT OUT THE IMPORT LINE TO TEST YOUR ANSWER from nams.solutions.structures import get_open_triangles_neighbors @@ -338,7 +332,6 @@ def plot_open_triangle_relations(G, n): # Your answer here pass - # COMMENT OUT THE IMPORT LINE TO TEST YOUR ANSWER from nams.solutions.structures import plot_open_triangle_relations @@ -442,9 +435,9 @@ def size_k_maximal_cliques(G, k): # Your answer here pass - # COMMENT OUT THE IMPORT LINE TO TEST YOUR ANSWER from nams.solutions.structures import size_k_maximal_cliques + return (size_k_maximal_cliques,) @@ -461,7 +454,6 @@ def test_size_k_maximal_cliques(G, k): for clique in clique_generator: assert len(clique) == k - test_size_k_maximal_cliques(G, 5) return @@ -516,16 +508,13 @@ def find_k_cliques(G, k): # your answer here pass - # COMMENT OUT THE IMPORT LINE TO TEST YOUR ANSWER from nams.solutions.structures import find_k_cliques - def test_find_k_cliques(G, k): for clique in find_k_cliques(G, k): assert len(clique) == k - test_find_k_cliques(G, 3) return @@ -642,7 +631,6 @@ def label_connected_component_subgraphs(G): # Your answer here return G - # COMMENT OUT THE IMPORT LINE TO TEST YOUR ANSWER from nams.solutions.structures import label_connected_component_subgraphs @@ -668,12 +656,10 @@ def _(mo): def _(G_labelled): import matplotlib.pyplot as plt - def plot_cc_subgraph(G): # Your answer here pass - # COMMENT OUT THE IMPORT LINE TO TEST YOUR ANSWER from nams.solutions.structures import plot_cc_subgraph from nxviz import annotate @@ -740,6 +726,7 @@ def _(getsource): @app.cell def _(): import marimo as mo + return (mo,) diff --git a/notebooks/03-practical/01-io.py b/notebooks/03-practical/01-io.py index 4cdcef08..1bff58de 100644 --- a/notebooks/03-practical/01-io.py +++ b/notebooks/03-practical/01-io.py @@ -322,7 +322,9 @@ def _(G): @app.cell(hide_code=True) def _(mo): - mo.md(r"""You'll notice that the edge metadata have been added correctly: we have recorded in there the number of trips between stations.""") + mo.md( + r"""You'll notice that the edge metadata have been added correctly: we have recorded in there the number of trips between stations.""" + ) return diff --git a/notebooks/04-advanced/02-linalg.py b/notebooks/04-advanced/02-linalg.py index a8cfd8c1..d686ec90 100644 --- a/notebooks/04-advanced/02-linalg.py +++ b/notebooks/04-advanced/02-linalg.py @@ -476,7 +476,9 @@ def _(mo): @app.cell(hide_code=True) def _(mo): - mo.md(r"""Let's start by looking at a toy bipartite graph, a "customer-product" purchase record graph, with 4 products and 3 customers. The matrix representation might be as follows:""") + mo.md( + r"""Let's start by looking at a toy bipartite graph, a "customer-product" purchase record graph, with 4 products and 3 customers. The matrix representation might be as follows:""" + ) return @@ -489,7 +491,9 @@ def _(np): @app.cell(hide_code=True) def _(mo): - mo.md(r"""From this "bi-adjacency" matrix, one can compute the projection onto the customers, matrix multiplying the matrix with its transpose.""") + mo.md( + r"""From this "bi-adjacency" matrix, one can compute the projection onto the customers, matrix multiplying the matrix with its transpose.""" + ) return @@ -515,7 +519,9 @@ def _(mo): @app.cell(hide_code=True) def _(mo): - mo.md(r"""To get the products matrix, we make the transposed matrix the left side of the matrix multiplication.""") + mo.md( + r"""To get the products matrix, we make the transposed matrix the left side of the matrix multiplication.""" + ) return @@ -528,7 +534,9 @@ def _(cp_mat): @app.cell(hide_code=True) def _(mo): - mo.md(r"""You may now try to convince yourself that the diagonals are the number of times a customer purchased that product, and the off-diagonals are the connectivity matrix of the products, weighted by how similar two customers are.""") + mo.md( + r"""You may now try to convince yourself that the diagonals are the number of times a customer purchased that product, and the off-diagonals are the connectivity matrix of the products, weighted by how similar two customers are.""" + ) return @@ -564,7 +572,9 @@ def _(): @app.cell(hide_code=True) def _(mo): - mo.md(r"""Remember that with bipartite graphs, it is useful to obtain nodes from one of the partitions.""") + mo.md( + r"""Remember that with bipartite graphs, it is useful to obtain nodes from one of the partitions.""" + ) return @@ -655,7 +665,9 @@ def _(degrees, np): @app.cell(hide_code=True) def _(mo): - mo.md(r"""We can verify this independently by sorting the customer nodes by degree.""") + mo.md( + r"""We can verify this independently by sorting the customer nodes by degree.""" + ) return @@ -834,6 +846,7 @@ def _(mo): @app.cell(hide_code=True) def _(): import marimo as mo + return (mo,)