This repository has been archived by the owner on Sep 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
numpy.html
91 lines (84 loc) · 3.15 KB
/
numpy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Configurable runtimes</title>
<meta name="theme-color" content="#0b0c0c">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="static/gd.css">
</head>
<body>
<py-config>
{
"interpreter": "micropython",
"files": {
"arrr.py": "/arrr.py"
}
}
</py-config>
<a href="#main-content" class="hide">Skip to main content</a>
<a name="top"></a>
<header>
<nav role="navigation">
<a href="/" style="text-decoration: none!important;";>
<img alt="Anaconda" src="static/logo.svg" width="54" height="54" style="display:inline;">
<img alt="Anaconda" src="static/anaconda.svg" height="54" style="display: inline; height: 42px;">
</a>
<ul>
<li><a href="/">Home</a></li>
<li><a href="https://github.com/pyscript/upys">Download</a></li>
</ul>
</nav>
</header>
<main id="main-content">
<h2>Native Modules</h2>
<p>There are numerous pure-Python modules that work with MicroPython.
However, some of the most interesting involve C-based extensions, with the
most well known being data science tools like
<a href="https://numpy.org/">numpy</a> and
<a href="https://scipy.org/">scipy</a>.</p>
<p>These C-based extensions can be compiled to WASM, in exactly the same
way that Python runtimes (written in C) are compiled to WASM.</p>
<p>The version of MicroPython emebedded in the following REPL also
includes a WASM compiled tool called
<a href="https://micropython-ulab.readthedocs.io/en/latest/index.html">uLab</a> ("micro lab").
This is a small reimplementation of the core functions, for effieciently
working with numeric arrays found, in the numpy
and scipy modules. It is clearly not a complete re-implementation, but
serves to prove that such bespoke C-based extensions can be used with the
MicroPython runtime.</p>
<py-repl></py-repl>
<p>Why not try:</p>
<pre><code>>>> import ulab
>>> np = ulab.numpy
>>> a = np.arange(6)
>>> a
array([0, 1, 2, 3, 4, 5], dtype=int16)
>>> b = a.reshape((2, 3))
>>> b
array([[0, 1, 2],
[3, 4, 5]], dtype=int16)
>>> np.sqrt(b)
array([[0.0, 1.0, 1.414213562373095],
[1.732050807568877, 2.0, 2.23606797749979]], dtype=float64)</code></pre>
<a href="repl.html"><button>Previous: The REPL</button></a>
</main>
<footer>
<main>
<section>
<ul>
<li><a href="/">Home</a></li>
<li><a href="https://github.com/pyscript/upys">Download</a></li>
</ul>
<article>
<p>Made with ❤️ by folks at <a href="https://anaconda.com" rel="noopener">Anaconda Inc</a>.<br>
💡Inspired by the great work at <a href="https://micropython.org/" rel="noopener">MicroPython</a>.<br><br>
</article>
</section>
</main>
</footer>
</body>
<script src="customtags.js"></script>
<script src="pyscript.js" type="module"></script>
</html>