diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..14e7620f --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,4 @@ +# Code of Conduct + +The Code of Conduct is available in the pyscript Governance repo. +See https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md index a7b21406..68658aeb 100644 --- a/GETTING-STARTED.md +++ b/GETTING-STARTED.md @@ -67,6 +67,7 @@ pi = wallis(100000) s = f"π is approximately {pi:.3f}" print(s) + ``` @@ -113,6 +114,7 @@ pyscript.write('pi', f'π is approximately {pi:.3f}') In addition to the [Python Standard Library](https://docs.python.org/3/library/) and the `pyscript` module, many 3rd-party OSS packages will work out-of-the-box with PyScript. + In order to use them you will need to delcare the dependencies using the `` in the HTML head. You can also link to `.whl` files directly on disk like in our [toga example](https://github.com/pyscript/pyscript/blob/main/pyscriptjs/examples/toga/freedom.html) @@ -122,7 +124,10 @@ HTML head. You can also link to `.whl` files directly on disk like in our [toga ``` -If your `.whl` is not a pure Python wheel then open a PR or issue with [pyodide](https://github.com/pyodide/pyodide) to get it added here https://github.com/pyodide/pyodide/tree/main/packages +If your `.whl` is not a pure Python wheel then open a PR or issue with [pyodide](https://github.com/pyodide/pyodide) to get it added here https://github.com/pyodide/pyodide/tree/main/packages. If there's enough popular demand the pyodide team will likely work on supporting your package, regardless things will likely move faster if you make the PR and consult with the team to get unblocked. + +In order to use them you will need to declare the dependencies using the `` in the +HTML head. For example, NumPy and Matplotlib are available. Notice here we're using `` as a shortcut, which takes the expression on the last line of the script and runs `pyscript.write('plot', fig)`. diff --git a/README.md b/README.md index 46bf566f..5b94cd01 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ To get started see [GETTING-STARTED][GETTING-STARTED.md] For examples see [the pyscript folder](pyscriptjs/README.md). ### Longer Version -PyScript is a meta project that aims to combine multiple open technologies to create a framework for users to use Python (and other languages) to create sophisticated applications in the browser. It highly integrate with the way the DOM works in the browser and allows users to add logic, in Python, in a way that feel natural to web as well as Python developers. +PyScript is a meta project that aims to combine multiple open technologies to create a framework for users to use Python (and other languages) to create sophisticated applications in the browser. It highly integrates with the way the DOM works in the browser and allows users to add logic, in Python, in a way that feels natural to web as well as Python developers. ## Try PyScript diff --git a/pyscriptjs/examples/message_passing.html b/pyscriptjs/examples/message_passing.html new file mode 100644 index 00000000..ee10a74a --- /dev/null +++ b/pyscriptjs/examples/message_passing.html @@ -0,0 +1,53 @@ + + + + + + + + + + - numpy + - networkx + - matplotlib + + +import numpy as np +import networkx as nx + + +

Message passing with linear algebra: a demo.

+

Imagine we have a chain graph that looks like this:

+
O --> 1 --> 2 --> 3
+

In NetworkX this graph would look like the following:

+
+        
+G = nx.Graph()
+nodes = list(range(4))
+G.add_edges_from(zip(nodes[0:-1], nodes[1:]))
+print(G.edges())
+
+

This chain graph has the following adjacency matrix:

+
+
+adj_mat = np.eye(4, k=1)
+print(f"A: {adj_mat}")
+
+        
+

And imagine that we have a message that lives on the graph:

+
+            
+message = np.array([1.0, 0.0, 0.0, 0.0])
+print(f"message: {message}")
+            
+        
+

Try out message passing below by doing any one of the following steps:

+
message @ adj_mat
+
message @ adj_mat @ adj_mat
+
message @ adj_mat @ adj_mat @ adj_mat
+
+ +
+ + + diff --git a/pyscriptjs/examples/utils.py b/pyscriptjs/examples/utils.py index 2a48a4fe..83feddb9 100644 --- a/pyscriptjs/examples/utils.py +++ b/pyscriptjs/examples/utils.py @@ -7,7 +7,7 @@ def now(fmt = "%m/%d/%Y, %H:%M:%S"): return format_date(dt.now(), fmt) def remove_class(element, className): - element.element.classList.remove("line-through") + element.element.classList.remove(className) def add_class(element, className): - element.element.classList.add("line-through") \ No newline at end of file + element.element.classList.add(className) \ No newline at end of file diff --git a/pyscriptjs/public/.gitkeep b/pyscriptjs/public/.gitkeep new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/pyscriptjs/public/.gitkeep @@ -0,0 +1 @@ + diff --git a/pyscriptjs/src/components/pybox.ts b/pyscriptjs/src/components/pybox.ts index 308f1136..c00856da 100644 --- a/pyscriptjs/src/components/pybox.ts +++ b/pyscriptjs/src/components/pybox.ts @@ -54,7 +54,7 @@ export class PyBox extends HTMLElement { this.widths.forEach((width, index)=>{ const node: ChildNode = mainDiv.childNodes[index]; - addClasses(node, [width, 'mx-1']) + addClasses(node as HTMLElement, [width, 'mx-1']) })