Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf16b1d8

Browse files
authored
Merge branch 'main' into docs
2 parentsc3345b3 +442af7b commitf16b1d8

File tree

7 files changed

+68
-5
lines changed

7 files changed

+68
-5
lines changed

‎CODE_OF_CONDUCT.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Code of Conduct
2+
3+
The Code of Conduct is available in the pyscript Governance repo.
4+
Seehttps://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md

‎GETTING-STARTED.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pi = wallis(100000)
6767
s = f"π is approximately {pi:.3f}"
6868
print(s)
6969
</py-script>
70+
</body>
7071
</html>
7172
```
7273

@@ -113,6 +114,7 @@ pyscript.write('pi', f'π is approximately {pi:.3f}')
113114

114115
In addition to the[Python Standard Library](https://docs.python.org/3/library/) and
115116
the`pyscript` module, many 3rd-party OSS packages will work out-of-the-box with PyScript.
117+
116118
In order to use them you will need to delcare the dependencies using the`<py-env>` in the
117119
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)
118120

@@ -122,7 +124,10 @@ HTML head. You can also link to `.whl` files directly on disk like in our [toga
122124
</py-env>
123125
```
124126

125-
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 herehttps://github.com/pyodide/pyodide/tree/main/packages
127+
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 herehttps://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.
128+
129+
In order to use them you will need to declare the dependencies using the`<py-env>` in the
130+
HTML head.
126131

127132
For example, NumPy and Matplotlib are available. Notice here we're using`<py-script output="plot">`
128133
as a shortcut, which takes the expression on the last line of the script and runs`pyscript.write('plot', fig)`.

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To get started see [GETTING-STARTED][GETTING-STARTED.md]
1010
For examples see[the pyscript folder](pyscriptjs/README.md).
1111

1212
###Longer Version
13-
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 highlyintegrate with the way the DOM works in the browser and allows users to add logic, in Python, in a way thatfeel natural to web as well as Python developers.
13+
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 highlyintegrates with the way the DOM works in the browser and allows users to add logic, in Python, in a way thatfeels natural to web as well as Python developers.
1414

1515
##Try PyScript
1616

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<html>
2+
3+
<head>
4+
<linkrel="stylesheet"href="https://pyscript.net/alpha/pyscript.css"/>
5+
<scriptdefersrc="https://pyscript.net/alpha/pyscript.js"></script>
6+
</head>
7+
8+
<body>
9+
<py-env>
10+
- numpy
11+
- networkx
12+
- matplotlib
13+
</py-env>
14+
<py-script>
15+
import numpy as np
16+
import networkx as nx
17+
</py-script>
18+
19+
<p>Message passing with linear algebra: a demo.</p>
20+
<p>Imagine we have a chain graph that looks like this:</p>
21+
<pre><code>O --> 1 --> 2 --> 3</code></pre>
22+
<p>In NetworkX this graph would look like the following:</p>
23+
<pre>
24+
<py-script>
25+
G = nx.Graph()
26+
nodes = list(range(4))
27+
G.add_edges_from(zip(nodes[0:-1], nodes[1:]))
28+
print(G.edges())
29+
</py-script></pre>
30+
<p>This chain graph has the following adjacency matrix:</p>
31+
<pre>
32+
<py-script>
33+
adj_mat = np.eye(4, k=1)
34+
print(f"A: {adj_mat}")
35+
</py-script>
36+
</pre>
37+
<p>And imagine that we have a message that lives on the graph:</p>
38+
<pre>
39+
<py-script>
40+
message = np.array([1.0, 0.0, 0.0, 0.0])
41+
print(f"message: {message}")
42+
</py-script>
43+
</pre>
44+
<p>Try out message passing below by doing any one of the following steps:</p>
45+
<pre><code>message @ adj_mat</code></pre>
46+
<pre><code>message @ adj_mat @ adj_mat</code></pre>
47+
<pre><code>message @ adj_mat @ adj_mat @ adj_mat</code></pre>
48+
<div>
49+
<py-replid="my-repl"auto-generate="true"></py-repl>
50+
</div>
51+
</body>
52+
53+
</html>

‎pyscriptjs/examples/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def now(fmt = "%m/%d/%Y, %H:%M:%S"):
77
returnformat_date(dt.now(),fmt)
88

99
defremove_class(element,className):
10-
element.element.classList.remove("line-through")
10+
element.element.classList.remove(className)
1111

1212
defadd_class(element,className):
13-
element.element.classList.add("line-through")
13+
element.element.classList.add(className)

‎pyscriptjs/public/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

‎pyscriptjs/src/components/pybox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class PyBox extends HTMLElement {
5454

5555
this.widths.forEach((width,index)=>{
5656
constnode:ChildNode=mainDiv.childNodes[index];
57-
addClasses(node,[width,'mx-1'])
57+
addClasses(nodeasHTMLElement,[width,'mx-1'])
5858

5959
})
6060

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp