summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@adafruit.com>2020-03-04 11:46:17 -0800
committerGitHub <noreply@github.com>2020-03-04 11:46:17 -0800
commitb4e1955526725ac4701048f148dca9d76f3f446a (patch)
tree1cc7c8bbb77ec55171c197278a38d668598d5653
parent4aec5d1e83580f06364f076d9d683549ddf1ee2c (diff)
parentda31acfcc45e5ad43c8ea515650ef16540de7fbb (diff)
Merge pull request #2583 from jepler/ulab
Add 'ulab' as an extmod; enable on nrf and most samd51 boards
-rw-r--r--.gitmodules5
m---------extmod/ulab0
-rw-r--r--lib/libm/erf_lgamma.c1
-rw-r--r--lib/libm/log1pf.c2
-rw-r--r--lib/libm/math.c3
-rw-r--r--locale/ID.po2
-rw-r--r--locale/circuitpython.pot2
-rw-r--r--locale/de_DE.po2
-rw-r--r--locale/en_US.po2
-rw-r--r--locale/en_x_pirate.po2
-rw-r--r--locale/es.po2
-rw-r--r--locale/fil.po2
-rw-r--r--locale/fr.po2
-rw-r--r--locale/it_IT.po2
-rw-r--r--locale/ko.po2
-rw-r--r--locale/pl.po2
-rw-r--r--locale/pt_BR.po2
-rw-r--r--locale/zh_Latn_pinyin.po2
-rw-r--r--ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/mpconfigport.mk6
-rw-r--r--ports/nrf/mpconfigport.mk1
-rw-r--r--ports/unix/mpconfigport.h3
-rw-r--r--ports/unix/mpconfigport.mk2
-rw-r--r--py/builtin.h7
-rw-r--r--py/circuitpy_defns.mk13
-rw-r--r--py/circuitpy_mpconfig.h6
-rwxr-xr-xpy/mpconfig.h4
-rw-r--r--py/objmodule.c8
-rw-r--r--py/py.mk16
-rw-r--r--shared-bindings/audiocore/RawSample.c2
-rw-r--r--shared-bindings/ulab/__init__.rst450
-rwxr-xr-xtests/run-tests2
32 files changed, 543 insertions, 16 deletions
diff --git a/.gitmodules b/.gitmodules
index 74ba714b2..9130593f2 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -114,9 +114,12 @@
[submodule "frozen/Adafruit_CircuitPython_Register"]
path = frozen/Adafruit_CircuitPython_Register
url = https://github.com/adafruit/Adafruit_CircuitPython_Register.git
+[submodule "extmod/ulab"]
+ path = extmod/ulab
+ url = https://github.com/adafruit/circuitpython-ulab
[submodule "frozen/Adafruit_CircuitPython_ESP32SPI"]
path = frozen/Adafruit_CircuitPython_ESP32SPI
url = https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI
[submodule "frozen/Adafruit_CircuitPython_Requests"]
path = frozen/Adafruit_CircuitPython_Requests
- url = https://github.com/adafruit/Adafruit_CircuitPython_Requests
+ url = https://github.com/adafruit/Adafruit_CircuitPython_Requests \ No newline at end of file
diff --git a/extmod/ulab b/extmod/ulab
new file mode 160000
+Subproject 42d831e1e65b1c75ed90de11b87a1c4a0ebe615
diff --git a/lib/libm/erf_lgamma.c b/lib/libm/erf_lgamma.c
index 877816a0c..fcb1d0a0c 100644
--- a/lib/libm/erf_lgamma.c
+++ b/lib/libm/erf_lgamma.c
@@ -24,6 +24,7 @@
*/
#include "fdlibm.h"
+#pragma GCC diagnostic ignored "-Wfloat-equal"
#define __ieee754_logf logf
diff --git a/lib/libm/log1pf.c b/lib/libm/log1pf.c
index 0d32b0a2f..89ed250b0 100644
--- a/lib/libm/log1pf.c
+++ b/lib/libm/log1pf.c
@@ -18,6 +18,8 @@
#include "libm.h"
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+
static const float
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
diff --git a/lib/libm/math.c b/lib/libm/math.c
index 39c6a68a5..0e53563bc 100644
--- a/lib/libm/math.c
+++ b/lib/libm/math.c
@@ -50,6 +50,9 @@ float copysignf(float x, float y) {
static const float _M_LN10 = 2.30258509299404; // 0x40135d8e
float log10f(float x) { return logf(x) / (float)_M_LN10; }
+#undef _M_LN2
+static const float _M_LN2 = 0.6931472;
+float log2f(float x) { return logf(x) / (float)_M_LN2; }
float tanhf(float x) {
if (isinf(x)) {
diff --git a/locale/ID.po b/locale/ID.po
index 45a310902..4325ac322 100644
--- a/locale/ID.po
+++ b/locale/ID.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index 4c0dabfb1..5494ed932 100644
--- a/locale/circuitpython.pot
+++ b/locale/circuitpython.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/locale/de_DE.po b/locale/de_DE.po
index 35529b768..9f0ff3a43 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
diff --git a/locale/en_US.po b/locale/en_US.po
index c422703c4..3ab55e3e3 100644
--- a/locale/en_US.po
+++ b/locale/en_US.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po
index 1f897f0ce..6e31f7638 100644
--- a/locale/en_x_pirate.po
+++ b/locale/en_x_pirate.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n"
diff --git a/locale/es.po b/locale/es.po
index 3fed75dfe..406d91234 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
diff --git a/locale/fil.po b/locale/fil.po
index be1158ec6..2c79dfe5c 100644
--- a/locale/fil.po
+++ b/locale/fil.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
diff --git a/locale/fr.po b/locale/fr.po
index e06d6336d..220b66de8 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
diff --git a/locale/it_IT.po b/locale/it_IT.po
index a43e4e247..19162faf5 100644
--- a/locale/it_IT.po
+++ b/locale/it_IT.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
diff --git a/locale/ko.po b/locale/ko.po
index 2b2a401aa..067d3491f 100644
--- a/locale/ko.po
+++ b/locale/ko.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
"Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/locale/pl.po b/locale/pl.po
index f6863ca59..a1d47caa6 100644
--- a/locale/pl.po
+++ b/locale/pl.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
"Language-Team: pl\n"
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index 371a6bcf6..f37d75050 100644
--- a/locale/pt_BR.po
+++ b/locale/pt_BR.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po
index 682d6c0e3..465920d5d 100644
--- a/locale/zh_Latn_pinyin.po
+++ b/locale/zh_Latn_pinyin.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-02 11:20-0500\n"
+"POT-Creation-Date: 2020-03-03 20:13-0600\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
index df1a2d8eb..eb3c81485 100644
--- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
@@ -15,3 +15,5 @@ CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_NETWORK = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_AUDIOMP3 = 0
+
+MICROPY_PY_ULAB = 0
diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk
index 354745a2c..7565e41a4 100644
--- a/ports/atmel-samd/mpconfigport.mk
+++ b/ports/atmel-samd/mpconfigport.mk
@@ -62,6 +62,12 @@ ifndef CIRCUITPY_SAMD
CIRCUITPY_SAMD = 1
endif
+ifndef MICROPY_PY_ULAB
+ifneq ($(CIRCUITPY_SMALL_BUILD),1)
+MICROPY_PY_ULAB = 1
+endif
+endif
+
endif # samd51
INTERNAL_LIBM = 1
diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk
index 9b738d4b3..db1b6b03e 100644
--- a/ports/nrf/mpconfigport.mk
+++ b/ports/nrf/mpconfigport.mk
@@ -69,4 +69,5 @@ NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
# Defined here because system_nrf52840.c doesn't #include any of our own include files.
CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS
+MICROPY_PY_ULAB = 1
endif
diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h
index e0f9d9995..3ac7ceaf2 100644
--- a/ports/unix/mpconfigport.h
+++ b/ports/unix/mpconfigport.h
@@ -323,3 +323,6 @@ void mp_unix_mark_exec(void);
// For debugging purposes, make printf() available to any source file.
#include <stdio.h>
#endif
+
+#define MICROPY_PY_BUILTINS_HELP (1)
+#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
diff --git a/ports/unix/mpconfigport.mk b/ports/unix/mpconfigport.mk
index f0aa955c0..4cb1804d4 100644
--- a/ports/unix/mpconfigport.mk
+++ b/ports/unix/mpconfigport.mk
@@ -40,3 +40,5 @@ MICROPY_PY_JNI = 0
# Avoid using system libraries, use copies bundled with MicroPython
# as submodules (currently affects only libffi).
MICROPY_STANDALONE = 0
+
+MICROPY_PY_ULAB = 1
diff --git a/py/builtin.h b/py/builtin.h
index 84b99a8a4..6e0d5d9be 100644
--- a/py/builtin.h
+++ b/py/builtin.h
@@ -117,6 +117,13 @@ extern const mp_obj_module_t mp_module_websocket;
extern const mp_obj_module_t mp_module_webrepl;
extern const mp_obj_module_t mp_module_framebuf;
extern const mp_obj_module_t mp_module_btree;
+extern const mp_obj_module_t ulab_user_cmodule;
+extern mp_obj_module_t ulab_fft_module;
+extern mp_obj_module_t ulab_filter_module;
+extern mp_obj_module_t ulab_linalg_module;
+extern mp_obj_module_t ulab_numerical_module;
+extern mp_obj_module_t ulab_poly_module;
+
extern const char MICROPY_PY_BUILTINS_HELP_TEXT[];
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index 68fa25d8d..92021d0d0 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -431,6 +431,19 @@ $(addprefix lib/,\
libm/atanf.c \
libm/atan2f.c \
)
+ifeq ($(MICROPY_PY_ULAB),1)
+SRC_LIBM += \
+$(addprefix lib/,\
+ libm/acoshf.c \
+ libm/asinhf.c \
+ libm/atanhf.c \
+ libm/erf_lgamma.c \
+ libm/log1pf.c \
+ libm/sf_erf.c \
+ libm/wf_lgamma.c \
+ libm/wf_tgamma.c \
+ )
+endif
endif
ifdef LD_TEMPLATE_FILE
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index 53cd7b0bb..61dd901ed 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -578,6 +578,12 @@ extern const struct _mp_obj_module_t ustack_module;
#define JSON_MODULE
#endif
+#if defined(MICROPY_PY_ULAB) && MICROPY_PY_ULAB
+#define ULAB_MODULE \
+ { MP_ROM_QSTR(MP_QSTR_ulab), MP_ROM_PTR(&ulab_user_cmodule) },
+#else
+#define ULAB_MODULE
+#endif
#if MICROPY_PY_URE
#define RE_MODULE { MP_ROM_QSTR(MP_QSTR_re), MP_ROM_PTR(&mp_module_ure) },
#else
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 1512c7d3a..8f78ade5c 100755
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -1173,6 +1173,10 @@ typedef double mp_float_t;
#define MICROPY_PY_UJSON (0)
#endif
+#ifndef MICROPY_PY_ULAB
+#define MICROPY_PY_ULAB (0)
+#endif
+
#ifndef MICROPY_PY_URE
#define MICROPY_PY_URE (0)
#endif
diff --git a/py/objmodule.c b/py/objmodule.c
index 627ba79e8..c7b080300 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -206,6 +206,14 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
{ MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) },
#endif
#endif
+#if MICROPY_PY_ULAB
+#if CIRCUITPY
+// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here.
+// TODO: move to shared-bindings/
+#else
+ { MP_ROM_QSTR(MP_QSTR_ulab), MP_ROM_PTR(&ulab_user_cmodule) },
+#endif
+#endif
#if MICROPY_PY_URE
#if CIRCUITPY
// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here.
diff --git a/py/py.mk b/py/py.mk
index a73b47f37..5e044947a 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -105,6 +105,22 @@ $(BUILD)/$(BTREE_DIR)/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare
$(BUILD)/extmod/modbtree.o: CFLAGS += $(BTREE_DEFS)
endif
+ifeq ($(MICROPY_PY_ULAB),1)
+SRC_MOD += $(addprefix extmod/ulab/code/, \
+create.c \
+fft.c \
+filter.c \
+linalg.c \
+ndarray.c \
+numerical.c \
+poly.c \
+ulab.c \
+vectorise.c \
+ )
+CFLAGS_MOD += -DMICROPY_PY_ULAB=1 -DMODULE_ULAB_ENABLED=1
+$(BUILD)/extmod/ulab/code/%.o: CFLAGS += -Wno-sign-compare -Wno-missing-prototypes -Wno-unused-parameter -Wno-missing-declarations -Wno-error -Wno-shadow -Wno-maybe-uninitialized -DCIRCUITPY
+endif
+
# External modules written in C.
ifneq ($(USER_C_MODULES),)
# pre-define USERMOD variables as expanded so that variables are immediate
diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c
index 87d410ea1..96af58a4f 100644
--- a/shared-bindings/audiocore/RawSample.c
+++ b/shared-bindings/audiocore/RawSample.c
@@ -49,7 +49,7 @@
//| first sample will be for channel 1, the second sample will be for channel two, the third for
//| channel 1 and so on.
//|
-//| :param array buffer: An `array.array` with samples
+//| :param array.array buffer: An `array.array` with samples
//| :param int channel_count: The number of channels in the buffer
//| :param int sample_rate: The desired playback sample rate
//|
diff --git a/shared-bindings/ulab/__init__.rst b/shared-bindings/ulab/__init__.rst
new file mode 100644
index 000000000..b2933be79
--- /dev/null
+++ b/shared-bindings/ulab/__init__.rst
@@ -0,0 +1,450 @@
+
+:mod:`ulab` --- Manipulate numeric data similar to numpy
+========================================================
+
+.. module:: ulab
+ :synopsis: Manipulate numeric data similar to numpy
+
+`ulab` is a numpy-like module for micropython, meant to simplify and
+speed up common mathematical operations on arrays. The primary goal was to
+implement a small subset of numpy that might be useful in the context of a
+microcontroller. This means low-level data processing of linear (array) and
+two-dimensional (matrix) data.
+
+`ulab` is adapted from micropython-ulab, and the original project's
+documentation can be found at
+https://micropython-ulab.readthedocs.io/en/latest/
+
+`ulab` is modeled after numpy, and aims to be a compatible subset where
+possible. Numpy's documentation can be found at
+https://docs.scipy.org/doc/numpy/index.html
+
+.. contents::
+
+.. attribute:: __version__
+
+The closest corresponding version of micropython-ulab
+
+ulab.array -- 1- and 2- dimensional array
+-----------------------------------------
+
+.. class:: ulab.array(values, \*, dtype=float)
+
+ :param sequence values: Sequence giving the initial content of the array.
+ :param dtype: The type of array values, ``int8``, ``uint8``, ``int16``, ``uint16``, or ``float``
+
+ The `values` sequence can either be a sequence of numbers (in which case a
+ 1-dimensional array is created), or a sequence where each subsequence has
+ the same length (in which case a 2-dimensional array is created).
+
+ In many cases, it is more convenient to create an array from a function
+ like `zeros` or `linspace`.
+
+ `ulab.array` implements the buffer protocol, so it can be used in many
+ places an `array.array` can be used.
+
+ .. attribute:: shape
+
+ The size of the array, a tuple of length 1 or 2
+
+ .. attribute:: size
+
+ The number of elements in the array
+
+ .. attribute:: itemsize
+
+ The number of elements in the array
+
+ .. method:: flatten(\*, order='C')
+
+ :param order: Whether to flatten by rows ('C') or columns ('F')
+
+ Returns a new `ulab.array` object which is always 1 dimensional.
+ If order is 'C' (the default", then the data is ordered in rows;
+ If it is 'F', then the data is ordered in columns. "C" and "F" refer
+ to the typical storage organization of the C and Fortran languages.
+
+ .. method:: sort(\*, axis=1)
+
+ :param axis: Whether to sort elements within rows (0), columns (1), or elements (None)
+
+ .. method:: transpose()
+
+ Swap the rows and columns of a 2-dimensional array
+
+ .. method:: __add__()
+
+ Adds corresponding elements of the two arrays, or adds a number to all
+ elements of the array. A number must be on the right hand side. If
+ both arguments are arrays, their sizes must match.
+
+ .. method:: __sub__()
+
+ Subtracts corresponding elements of the two arrays, or subtracts a
+ number from all elements of the array. A number must be on the right
+ hand side. If both arguments are arrays, their sizes must match.
+
+ .. method:: __mul__()
+
+ Multiplies corresponding elements of the two arrays, or multiplies
+ all elements of the array by a number. A number must be on the right
+ hand side. If both arguments are arrays, their sizes must match.
+
+ .. method:: __div__()
+
+ Multiplies corresponding elements of the two arrays, or divides
+ all elements of the array by a number. A number must be on the right
+ hand side. If both arguments are arrays, their sizes must match.
+
+ .. method:: __getitem__()
+
+ Retrieve an element of the array.
+
+ .. method:: __setitem__()
+
+ Set an element of the array.
+
+Array type codes
+----------------
+.. attribute:: int8
+
+ Type code for signed integers in the range -128 .. 127 inclusive, like the 'b' typecode of `array.array`
+
+.. attribute:: int16
+
+ Type code for signed integers in the range -32768 .. 32767 inclusive, like the 'h' typecode of `array.array`
+
+.. attribute:: float
+
+ Type code for floating point values, like the 'f' typecode of `array.array`
+
+.. attribute:: uint8
+
+ Type code for unsigned integers in the range 0 .. 255 inclusive, like the 'H' typecode of `array.array`
+
+.. attribute:: uint8
+
+ Type code for unsigned integers in the range 0 .. 65535 inclusive, like the 'h' typecode of `array.array`
+
+
+Basic Array defining functions
+------------------------------
+
+.. method:: ones(shape, \*, dtype=float)
+
+ .. param: shape
+ Shape of the array, either an integer (for a 1-D array) or a tuple of 2 integers (for a 2-D array)
+
+ .. param: dtype
+ Type of values in the array
+
+ Return a new array of the given shape with all elements set to 1.
+
+.. method:: zeros
+
+ .. param: shape
+ Shape of the array, either an integer (for a 1-D array) or a tuple of 2 integers (for a 2-D array)
+
+ .. param: dtype
+ Type of values in the array
+
+ Return a new array of the given shape with all elements set to 0.
+
+
+.. method:: eye(size, \*, dtype=float)
+
+ Return a new square array of size, with the diagonal elements set to 1
+ and the other elements set to 0.
+
+.. method:: linspace(start, stop, \*, dtype=float, num=50, endpoint=True)
+
+ .. param: start
+
+ First value in the array
+
+ .. param: stop
+
+ Final value in the array
+
+ .. param int: num
+
+ Count of values in the array
+
+ .. param: dtype
+
+ Type of values in the array
+
+ .. param bool: endpoint
+
+ Whether the ``stop`` value is included. Note that even when
+ endpoint=True, the exact ``stop`` value may not be included due to the
+ inaccuracy of floating point arithmetic.
+
+ Return a new 1-D array with ``num`` elements ranging from ``start`` to ``stop`` linearly.
+
+
+
+:mod:`ulab.vector` --- Element-by-element functions
+===================================================
+
+.. module:: ulab.vector
+
+These functions can operate on numbers, 1-D arrays, or 2-D arrays by
+applying the function to every element in the array. This is typically
+much more efficient than expressing the same operation as a Python loop.
+
+.. method:: acos
+
+ Computes the inverse cosine function
+
+.. method:: acosh
+
+ Computes the inverse hyperbolic cosine function
+
+.. method:: asin
+
+ Computes the inverse sine function
+
+.. method:: asinh
+
+ Computes the inverse hyperbolic sine function
+
+.. method:: atan
+
+ Computes the inverse tangent function
+
+.. method:: atanh
+
+ Computes the inverse hyperbolic tangent function
+
+.. method:: ceil
+
+ Rounds numbers up to the next whole number
+
+.. method:: cos
+
+ Computes the cosine function
+
+.. method:: erf
+
+ Computes the error function, which has applications in statistics
+
+.. method:: erfc
+
+ Computes the complementary error function, which has applications in statistics
+
+.. method:: exp
+
+ Computes the exponent function.
+
+.. method:: expm1
+
+ Computes $e^x-1$. In certain applications, using this function preserves numeric accuracy better than the `exp` function.
+
+.. method:: floor
+
+ Rounds numbers up to the next whole number
+
+.. method:: gamma
+
+ Computes the gamma function
+
+.. method:: lgamma
+
+ Computes the natural log of the gamma function
+
+.. method:: log
+
+ Computes the natural log
+
+.. method:: log10
+
+ Computes the log base 10
+
+.. method:: log2
+
+ Computes the log base 2
+
+.. method:: sin
+
+ Computes the sine
+
+.. method:: sinh
+
+ Computes the hyperbolic sine
+
+.. method:: sqrt
+
+ Computes the square root
+
+.. method:: tan
+
+ Computes the tangent
+
+.. method:: tanh
+
+ Computes the hyperbolic tangent
+
+:mod:`ulab.linalg` - Linear algebra functions
+=============================================
+
+.. module:: ulab.linalg
+
+.. method:: det
+
+ :param: m, a square matrix
+ :return float: The determinant of the matrix
+
+ Computes the eigenvalues and eigenvectors of a square matrix
+
+.. method:: dot(m1, m2)
+
+ :param ~ulab.array m1: a matrix
+ :param ~ulab.array m2: a matrix
+
+ Computes the matrix product of two matrices
+
+ **WARNING:** Unlike ``numpy``, this function cannot be used to compute the dot product of two vectors
+
+.. method:: eig(m)
+
+ :param m: a square matrix
+ :return tuple (eigenvectors, eigenvalues):
+
+ Computes the eigenvalues and eigenvectors of a square matrix
+
+.. method:: inv(m)
+
+ :param ~ulab.array m: a square matrix
+ :return: The inverse of the matrix, if it exists
+ :raises ValueError: if the matrix is not invertible
+
+ Computes the inverse of a square matrix
+
+.. method:: size(array)
+
+ Return the total number of elements in the array, as an integer.
+
+:mod:`ulab.filter` --- Filtering functions
+==========================================
+
+.. module:: ulab.filter
+
+.. method:: convolve(r, c=None)
+
+ :param ulab.array a:
+ :param ulab.array v:
+
+ Returns the discrete, linear convolution of two one-dimensional sequences.
+ The result is always an array of float. Only the ``full`` mode is supported,
+ and the ``mode`` named parameter of numpy is not accepted. Note that all other
+ modes can be had by slicing a ``full`` result.
+
+ Convolution filters can implement high pass, low pass, band pass, etc.,
+ filtering operations. Convolution filters are typically constructed ahead
+ of time. This can be done using desktop python with scipy, or on web pages
+ such as https://fiiir.com/
+
+ Convolution is most time-efficient when both inputs are of float type.
+
+:mod:`ulab.fft` --- Frequency-domain functions
+==============================================
+
+.. module:: ulab.fft
+
+.. method:: fft(r, c=None)
+
+ :param ulab.array r: A 1-dimension array of values whose size is a power of 2
+ :param ulab.array c: An optional 1-dimension array of values whose size is a power of 2, giving the complex part of the value
+ :return tuple (r, c): The real and complex parts of the FFT
+
+ Perform a Fast Fourier Transform from the time domain into the frequency domain
+
+.. method:: ifft(r, c=None)
+
+ :param ulab.array r: A 1-dimension array of values whose size is a power of 2
+ :param ulab.array c: An optional 1-dimension array of values whose size is a power of 2, giving the complex part of the value
+ :return tuple (r, c): The real and complex parts of the inverse FFT
+
+ Perform an Inverse Fast Fourier Transform from the frequeny domain into the time domain
+
+.. method:: spectrum(r):
+
+ :param ulab.array r: A 1-dimension array of values whose size is a power of 2
+
+ Computes the spectrum of the input signal. This is the absolute value of the (complex-valued) fft of the signal.
+
+:mod:`ulab.numerical` --- Numerical and Statistical functions
+=============================================================
+
+.. module:: ulab.numerical
+
+Most of these functions take an "axis" argument, which indicates whether to
+operate over the flattened array (None), rows (0), or columns (1).
+
+.. method:: argmax(array, \*, axis=None)
+
+ Return the index of the maximum element of the 1D array, as an array with 1 element
+
+.. method:: argmin(array, \*, axis=None)
+
+ Return the index of the minimum element of the 1D array, as an array with 1 element
+
+.. method:: argsort(array, \*, axis=None)
+
+ Returns an array which gives indices into the input array from least to greatest.
+
+.. method:: diff(array, \*, axis=1)
+
+ Return the numerical derivative of successive elements of the array, as
+ an array. axis=None is not supported.
+
+.. method:: flip(array, \*, axis=None)
+
+ Returns a new array that reverses the order of the elements along the
+ given axis, or along all axes if axis is None.
+
+.. method:: max(array, \*, axis=None)
+
+ Return the maximum element of the 1D array, as an array with 1 element
+
+.. method:: mean(array, \*, axis=None)
+
+ Return the mean element of the 1D array, as a number if axis is None, otherwise as an array.
+
+.. method:: min(array, \*, axis=None)
+
+ Return the minimum element of the 1D array, as an array with 1 element
+
+.. method:: roll(array, distance, \*, axis=None)
+
+ Shift the content of a vector by the positions given as the second
+ argument. If the ``axis`` keyword is supplied, the shift is applied to
+ the given axis. The array is modified in place.
+
+.. method:: std(array, \*, axis=None)
+
+ Return the standard deviation of the array, as a number if axis is None, otherwise as an array.
+
+.. method:: sum(array, \*, axis=None)
+
+ Return the sum of the array, as a number if axis is None, otherwise as an array.
+
+.. method:: sort(array, \*, axis=0)
+
+ Sort the array along the given axis, or along all axes if axis is None.
+ The array is modified in place.
+
+:mod:`ulab.poly` --- Polynomial functions
+=========================================
+
+.. module:: ulab.poly
+
+.. method:: polyfit([x, ] y, degree)
+
+ Return a polynomial of given degree that approximates the function
+ f(x)=y. If x is not supplied, it is the range(len(y)).
+
+.. method:: polyval(p, x)
+
+ Evaluate the polynomial p at the points x. x must be an array.
diff --git a/tests/run-tests b/tests/run-tests
index 94e1591e8..f6c727a8a 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -579,7 +579,7 @@ the last matching regex is used:
# run PC tests
test_dirs = (
'basics', 'micropython', 'float', 'import', 'io', 'misc',
- 'stress', 'unicode', 'extmod', 'unix', 'cmdline',
+ 'stress', 'unicode', 'extmod', '../extmod/ulab/tests', 'unix', 'cmdline',
)
else:
# run tests from these directories