mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
* replace unnecessary elements from hello_world example and replace with py-tutor tag * add py_tutor plugin * port altair example * add code for more granular tutor mode * add support for including modules source in pytutor * remove js dependencies in hello_world * put antigravity on a diet ;) * use py-tutor on antigravity example * use py-tutor on d3 example * use py-tutor on bokeh example * use py-tutor on bokeh_interactive example * fix issue when module_paths is undefined * remove prism js dependency leftovers * ooops, really remove prism js dependency leftovers * port follium example to pytutor * port pymarkdown and matplotlib example to pytutor * port message_passing and numpy_convas_fractals examples to pytutor * port the panel complex examples to pytutor * port the panel complex examples to pytutor * port last examples to py-tutor * remove prism * remore most debugging logs and replace log with info * add new d3.py file * add comments to connect method * clean pyscript class from logs * revert class pySrc attribute * add check_tutor_generated_code to test code inspector plugin in examples * add doctsting to PyTutor connect * add check for tutor code inspection on all examples * Update pyscriptjs/src/plugins/python/py_tutor.py fix template indentation Co-authored-by: Fábio Rosado <fabioglrosado@gmail.com> * Update examples/todo-pylist.html fix typo (stray = ) Co-authored-by: Fábio Rosado <fabioglrosado@gmail.com> * fix pymarkdown example Co-authored-by: Fabio Pliger <fpliger@anaconda.com> Co-authored-by: Fábio Rosado <fabioglrosado@gmail.com>
67 lines
1.7 KiB
HTML
67 lines
1.7 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<link rel="icon" type="image/x-icon" href="./favicon.png">
|
|
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
|
|
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
|
|
|
|
<link rel="stylesheet" href="./assets/css/examples.css" />
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<py-tutor>
|
|
<py-config>
|
|
packages = [
|
|
"numpy",
|
|
"networkx",
|
|
"matplotlib"
|
|
]
|
|
plugins = [
|
|
"../build/plugins/python/py_tutor.py"
|
|
]
|
|
</py-config>
|
|
|
|
<py-script>
|
|
import numpy as np
|
|
import networkx as nx
|
|
</py-script>
|
|
|
|
<p>Message passing with linear algebra: a demo.</p>
|
|
<p>Imagine we have a chain graph that looks like this:</p>
|
|
<pre><code>O --> 1 --> 2 --> 3</code></pre>
|
|
<p>In NetworkX this graph would look like the following:</p>
|
|
<pre>
|
|
<py-script>
|
|
G = nx.Graph()
|
|
nodes = list(range(4))
|
|
G.add_edges_from(zip(nodes[0:-1], nodes[1:]))
|
|
print(G.edges())
|
|
</py-script>
|
|
</pre>
|
|
<p>This chain graph has the following adjacency matrix:</p>
|
|
<pre>
|
|
<py-script>
|
|
adj_mat = np.eye(4, k=1)
|
|
print(f"A: {adj_mat}")
|
|
</py-script>
|
|
</pre>
|
|
<p>And imagine that we have a message that lives on the graph:</p>
|
|
<pre>
|
|
<py-script>
|
|
message = np.array([1.0, 0.0, 0.0, 0.0])
|
|
print(f"message: {message}")
|
|
</py-script>
|
|
</pre>
|
|
<p>Try out message passing below by doing any one of the following steps:</p>
|
|
<pre><code>message @ adj_mat</code></pre>
|
|
<pre><code>message @ adj_mat @ adj_mat</code></pre>
|
|
<pre><code>message @ adj_mat @ adj_mat @ adj_mat</code></pre>
|
|
<div>
|
|
<py-repl id="my-repl" auto-generate="true"> </py-repl>
|
|
</div>
|
|
</py-tutor>
|
|
</body>
|
|
|
|
</html>
|