Skip to content

Commit 9f51cd9

Browse files
committed
Merge branch 'numpy-scipy'
Moving to complete numpy compatibility
2 parents a093b3a + 5a491d4 commit 9f51cd9

File tree

124 files changed

+10888
-6477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+10888
-6477
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,39 @@ jobs:
4646
- name: Run build.sh
4747
run: ./build.sh
4848

49-
circuitpython:
50-
strategy:
51-
matrix:
52-
os:
53-
- ubuntu-16.04
54-
- macos-10.14
55-
runs-on: ${{ matrix.os }}
56-
steps:
57-
- name: Dump GitHub context
58-
env:
59-
GITHUB_CONTEXT: ${{ toJson(github) }}
60-
run: echo "$GITHUB_CONTEXT"
61-
- name: Set up Python 3.5
62-
uses: actions/setup-python@v1
63-
with:
64-
python-version: 3.8
65-
66-
- name: Versions
67-
run: |
68-
gcc --version
69-
python3 --version
70-
71-
- name: Checkout ulab
72-
uses: actions/checkout@v1
73-
74-
- name: Install requirements
75-
run: |
76-
if type -path apt-get; then
77-
sudo apt-get install gettext
78-
else
79-
brew install gettext
80-
echo >>$GITHUB_PATH /usr/local/opt/gettext/bin
81-
fi
82-
83-
- name: Run build-cp.sh
84-
run: ./build-cp.sh
49+
# circuitpython:
50+
# strategy:
51+
# matrix:
52+
# os:
53+
# - ubuntu-16.04
54+
# - macos-10.14
55+
# runs-on: ${{ matrix.os }}
56+
# steps:
57+
# - name: Dump GitHub context
58+
# env:
59+
# GITHUB_CONTEXT: ${{ toJson(github) }}
60+
# run: echo "$GITHUB_CONTEXT"
61+
# - name: Set up Python 3.5
62+
# uses: actions/setup-python@v1
63+
# with:
64+
# python-version: 3.8
65+
#
66+
# - name: Versions
67+
# run: |
68+
# gcc --version
69+
# python3 --version
70+
#
71+
# - name: Checkout ulab
72+
# uses: actions/checkout@v1
73+
#
74+
# - name: Install requirements
75+
# run: |
76+
# if type -path apt-get; then
77+
# sudo apt-get install gettext
78+
# else
79+
# brew install gettext
80+
# echo >>$GITHUB_PATH /usr/local/opt/gettext/bin
81+
# fi
82+
#
83+
# - name: Run build-cp.sh
84+
# run: ./build-cp.sh

README.md

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,68 +14,45 @@ The `float` implementation of `micropython` (`float`, or `double`) is automatica
1414
`ulab` implements `numpy`'s `ndarray` with the `==`, `!=`, `<`, `<=`, `>`, `>=`, `+`, `-`, `/`, `*`, `**`,
1515
`+=`, `-=`, `*=`, `/=`, `**=` binary operators, and the `len`, `~`, `-`, `+`, `abs` unary operators that
1616
operate element-wise. Type-aware `ndarray`s can be initialised from any `micropython` iterable, lists of
17-
iterables, or by means of the `arange`, `concatenate`, `diag`, `eye`, `full`, `linspace`, `logspace`, `ones`, or
17+
iterables, or by means of the `arange`, `concatenate`, `diag`, `eye`, `frombuffer`, `full`, `linspace`, `logspace`, `ones`, or
1818
`zeros` functions.
1919

2020
`ndarray`s can be iterated on, and have a number of their own methods, such as `flatten`, `shape`,
2121
`reshape`, `strides`, `transpose`, `size`, `tobytes`, and `itemsize`.
2222

23-
## Customising the firmware
24-
25-
In addition to the `ndarray`'s operators and methods, seven modules define a great number of functions that can
26-
take `ndarray`s or `micropython` iterables as their arguments. If flash space is a concern, unnecessary sub-modules
27-
or even individual functions can be excluded from the compiled firmware with pre-processor switches.
28-
29-
### approx
30-
31-
The `approx` sub-module contains the implementation of the `interp`, and `trapz` functions of `numpy`, and `newton`, `bisect`,
32-
and `fmin` from `scipy`.
33-
34-
### compare
35-
36-
The `compare` sub-module contains the implementation of the `equal`, `not_equal`, `minimum`, `maximum`, and `clip` functions.
37-
38-
### fft
39-
40-
The `fft` sub-module implements the fast Fourier transform, and its inverse for one-dimensional `ndarray`s,
41-
as well as the `spectrogram` function from `scipy`.
4223

43-
### filter
44-
45-
The `filter` sub-module implements `convolve` for one-dimensional convolution,
46-
as well as the cascaded second-order sections filter, `sosfilt` from `scipy`.
47-
48-
### linalg
49-
50-
The `linalg` sub-module implements functions for matrix inversion, dot product, and the calculation of the
51-
determinant, eigenvalues, eigenvectors, Cholesky decomposition, and trace.
52-
53-
### numerical
54-
55-
The `numerical` sub-module defines the `cross`, `diff`, `flip`, `median`, `roll`, `sort` and `argsort` functions for `ndarray`s, and,
56-
in addition, the `min`, `max`, `argmin`, `argmax`, `sum`, `mean`, `std` functions that work with `ndarray`s, as
57-
well as generic one-dimensional iterables.
24+
## Customising the firmware
5825

59-
### poly
26+
In addition to the `ndarray` operators and methods, `ulab` defines a great number of functions that can
27+
take `ndarray`s or `micropython` iterables as their arguments. If flash space is a concern, unnecessary functions
28+
can be excluded from the compiled firmware with pre-processor switches. Most of the functions are parts of
29+
`numpy`, but several are re-implementations of `scipy` features. For a full list of functions, see
30+
[micropython-ulab](https://micropython-ulab.readthedocs.io/en/latest)!
6031

61-
The `poly` sub-module defines the `polyval`, and `polyfit` functions from `numpy`.
6232

63-
### vector
33+
## Usage
6434

65-
The `vector` sub-module implements all functions of `micropython`'s `math` package (e.g., `acos`, `acosh`, ..., `tan`, `tanh`),
66-
and the `degrees` and `radians` for `ndarray`s and iterables. In addition, it also provided tools for vectorising generic,
67-
user-defined `python` functions.
35+
`ulab` sports a `numpy`-compatible interface, which makes porting of `CPython` code straightforward. The following
36+
snippet should run equally well in `micropython`, or on a PC.
6837

69-
### user
38+
```python
39+
try:
40+
from ulab import numpy as np
41+
from ulab import scipy as spy
42+
except ImportError:
43+
import numpy as np
44+
import scipy as spy
7045

71-
The `user` sub-module is meant as a user-extendable module, and contains a dummy function only.
46+
x = np.array([1, 2, 3])
47+
spy.special.erf(x)
48+
```
7249

7350
# Finding help
7451

7552
Documentation can be found on [readthedocs](https://readthedocs.org/) under
7653
[micropython-ulab](https://micropython-ulab.readthedocs.io/en/latest),
7754
as well as at [circuitpython-ulab](https://circuitpython.readthedocs.io/en/latest/shared-bindings/ulab/__init__.html).
78-
A number of practical examples are listed in the excellent
55+
A number of practical examples are listed in Jeff Epler's excellent
7956
[circuitpython-ulab](https://learn.adafruit.com/ulab-crunch-numbers-fast-with-circuitpython/overview) overview.
8057

8158
# Benchmarks

code/fft/fft.c

Lines changed: 0 additions & 187 deletions
This file was deleted.

code/fft/fft.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)