Commit graph

1364 commits

Author SHA1 Message Date
KB Sriram
84f99f17fc
numpy/vector.c: remove usage of fpclassify (#636)
Fixes https://github.com/v923z/micropython-ulab/issues/635

Verified by re-compiling circuitpython with this change.
2023-07-17 22:03:30 +02:00
d025aa3cf6
Per github docs, run apt-get update (#637)
https://docs.github.com/en/actions/using-github-hosted-runners/customizing-github-hosted-runners
2023-07-17 10:10:23 +02:00
Zoltán Vörös
d072086c56
allow function iterator in math functions (#633)
* allow function iterator in math functions

* increment version number
2023-07-02 10:02:29 +02:00
38caf84b2d
Fix -Wunused-variable diagnostic when !ULAB_SUPPORTS_COMPLEX (#631)
* Fix -Wunused-variable diagnostic when !ULAB_SUPPORTS_COMPLEX

`o_in` is only used in the SUPPORTS_COMPLEX case, so the variable
definition needs to be moved accordingly.

* update version and changelog
2023-06-28 21:52:04 +02:00
HugoNumworks
112d4f82d3
Polyval handles non-array as second argument (#601)
* Factorize polynomial evaluation

* Polyval handles non-array as second argument

---------

Co-authored-by: Zoltán Vörös <zvoros@gmail.com>
2023-06-27 21:13:53 +02:00
FelixNumworks
319df10cfe
[ndarray] Fix ndarray_from_tuple reading out of _shape->items bounds (#630) 2023-06-26 22:21:50 +02:00
FelixNumworks
26051d70d2
Int overflow (#629)
* Prevent ndarray from overflowing size_t

* Use size_t for polyval array len

* Fix infinite arange

* 6.3.1 version
2023-06-22 14:55:16 +02:00
Derfies
2cde1280a4
Bitwise (#628)
* add bitwise operators

* add build to requirements

* [EDIT] - Tweaked test data and saved test results.

* Tweaked test values for and / or

* [EDIT] - Setting print options to be verbose for test comparisons.

* [EDIT] - Removed call to set_printoptions and added output from ulab instead of numpy. Of note - there seems to be a discrepancy between the numpy and ulab output for one of the left_shift cases.

* [EDIT] - Added newline at end of file for diffing purposes.

* [EDIT] - Added print options back in as output seemed truncated.

---------

Co-authored-by: Zoltán Vörös <zvoros@gmail.com>
Co-authored-by: JamieDouugh <jamie.davies@douugh.com>
2023-06-21 13:46:30 +02:00
Zoltán Vörös
ef248b684d
add bitwise operators (#616)
* add bitwise operators

* add build to requirements
2023-06-20 21:44:58 +02:00
38a4976b58
fix fetching submodules (cp build process change) (#627) 2023-06-20 13:09:01 +02:00
Zoltán Vörös
73dbbf79bb
add the out keyword argument to universal functions (#621)
* add optional out keyword argument to math functions

* fix the keyword handling in sqrt

* run micropython build on ubuntu 20.04 instead of latest

* fix unused variable error in vector_generic_vector
2023-05-28 17:33:24 +02:00
Zoltán Vörös
3e996d9bd9
fix ndarray subscription method (#619) 2023-05-17 20:45:07 +02:00
6619c20b3b
Merge pull request #617 from jepler/sinc-function
ulab.numpy: implement sinc for creating audio filters
2023-05-16 11:47:29 -05:00
f3e6e1c6d2
include new requirement of circuitpython build 2023-05-16 07:33:20 -05:00
6000743c45
fix docstring of sinc 2023-05-16 07:32:25 -05:00
1150554ad5
ulab.numpy: implement sinc for creating audio filters
This is useful for generating FIR filters using code snippets generated at
https://fiiir.com/ (at least those with a rectangular window type; other
window types need additional functions but we can revisit it later if needed)

I think this will come in handy for folks who are using the advanced
features of our audio synthesizer module, synthio.

e.g., the following block now gives highly similar results on ulab
or numpy:

```py
try:
    import numpy as np
except:
    from ulab import numpy as np

# Example code, computes the coefficients of a low-pass windowed-sinc filter.

# Configuration.
fS = 48000  # Sampling rate.
fL = 4000  # Cutoff frequency.
N = 23  # Filter length, must be odd.

# Compute sinc filter.
h = np.sinc(2 * fL / fS * (np.arange(N) - (N - 1) / 2))

# Normalize to get unity gain.
h /= np.sum(h)

# Applying the filter to a signal s can be as simple as writing
# s = np.convolve(s, h)
2023-05-15 18:00:59 -05:00
Zoltán Vörös
ac2e9954ed
ndarray_from_mp_obj correctly treats Booleans (#613) 2023-05-07 12:09:02 +02:00
Zoltán Vörös
beda4c19f8
implement unknown shape dimension in reshape (#612) 2023-05-07 00:21:16 +02:00
Zoltán Vörös
412b13fb1c
fix binary division (#611) 2023-05-06 20:40:06 +02:00
FelixNumworks
8c3e1058d4
Fix arange crashing when start, stop or step is nan (#605) 2023-04-27 13:26:04 +02:00
FelixNumworks
ad1a1c54aa
Fix create_arange empty range (#604)
* Fix create_arange crashing when stop == start

This is due to len being equal to zero, which made (len - 1) equal to MAX_UINT16

* trailing whitespaces
2023-04-24 18:46:48 +02:00
HugoNumworks
afc8e4e165
Fix unused function compare_equal_helper warning (#603) 2023-04-24 14:58:38 +02:00
Zoltán Vörös
47ad73ab57
Floordiv (#593)
* implement floor division

* fix 3D, 4D loops

* add missing array declaration in 3D, and 4D

* Add test cases for floor division and fix it for ints (#599)

* Add test cases for floor division

* Fix define name in comment

* Fix floor division of ints

---------

Co-authored-by: Maciej Sokołowski <matemaciek@gmail.com>
2023-04-23 21:14:59 +02:00
yamamotomas
4407f8c404
Add a build script for Raspberry Pi Pico W (#598)
* make a build script for pico W

* add build scipt for pico W
2023-04-20 17:46:16 +02:00
HugoNumworks
5fa9b70766
Add missing constant constraints (#594) 2023-04-14 16:43:09 +02:00
Damien George
8585407df9
Use enum instead of const for float consts with repr C (#591)
Older compilers (eg for esp8266) cannot see that "const uint32_t" is a true
constant at compile time, so use an assigned enum instead.

Don't do this for object representation D because that requires a 64-bit
integer.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-04 08:28:01 +01:00
Zoltán Vörös
f2dd2230c4
fix sorting of empty arrays in sort_complex (#583) 2023-01-23 21:53:41 +01:00
Zoltán Vörös
578ca6670d
raise exception in arange, if step size is 0 (#582) 2023-01-23 21:52:37 +01:00
33398e082c
Merge pull request #578 from jepler/issue576
Check that array size doesn't overflow at construction time
2023-01-21 19:32:33 -06:00
20766d16e1
bump version 2023-01-21 08:03:06 -06:00
315c988393
Check that array size doesn't overflow at construction time
Now, requesting to allocate an array that is too big gives the exception
'array is too big', like numpy.

This does depend on a gcc extension, `__builtin_mul_overflow`, present
since at least version 5. This extension is also supported in clang.
msvc is probably the only compiler of note that does not support it.

Closes: #576
2023-01-19 07:15:58 -06:00
Zoltán Vörös
6fcfeda58d increment version number after dot fix 2023-01-15 11:01:15 +01:00
6e6d24ea45
Allocate 1d results of correct size (#577)
Before, it was erroneously allocated as a 1-element array
instead of a 6-element array in the test case.

Closes #574
2023-01-15 10:58:18 +01:00
Zoltán Vörös
7124eaac74
fix concatenate (#575) 2023-01-14 11:02:33 +01:00
Zoltán Vörös
5be42be128
Update bug_report.md
correct misleading instruction on version number
2023-01-14 09:49:01 +01:00
Zoltán Vörös
e68bb707b2
fix vectorize (#568) 2023-01-04 00:27:41 +01:00
HaydenS3
42172c6575
Added note of dimensions argument for ./build.sh 😿 (#567) 2023-01-04 00:04:52 +01:00
Damien George
1a440d7d12
Fix sort when dtype is uint16 (#563)
Prior to this fix the code was using the mp_float_t data type for uint16
and producing incorrect sort results.

Signed-off-by: Damien George <damien@micropython.org>

Signed-off-by: Damien George <damien@micropython.org>
2022-11-29 08:02:35 +01:00
Zoltán Vörös
25a825e41c
fix segmentation fault bug in fft.ifft (#557) 2022-11-07 17:23:04 +01:00
155dad9994
Use python 3.10 during ci (#558)
CircuitPython now requires 3.9 as a minumum
2022-11-06 10:39:10 +01:00
Jim Mussared
38e99c69af
code/ulab.c: Fix missing comma in ulab_dtype_type definition. (#553)
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-10 08:48:17 +02:00
Damien George
41fcf1d4cf
Minor compile fixes: comma and new-line at end of files (#550)
* Fix missing comma in type definition

Signed-off-by: Damien George <damien@micropython.org>

* Make sure all files have a new-line at the end

Some very old compilers don't like files without a new-line at the end.

Signed-off-by: Damien George <damien@micropython.org>

* Use math.isclose for universal_functions expm1 test

Signed-off-by: Damien George <damien@micropython.org>

Signed-off-by: Damien George <damien@micropython.org>
2022-09-30 10:42:49 +02:00
Zoltán Vörös
5ccfa5cdd9
Update build.sh
remove tests from nanbox
2022-09-21 20:10:18 +02:00
Zoltán Vörös
0c807bd912 remove comments from methods.py 2022-09-21 20:00:03 +02:00
Zoltán Vörös
294f9d9ef2 fix test script, bring ulab in line with micropython, bump version number to 6.0.0 2022-09-21 19:59:34 +02:00
Jim Mussared
42f396a992
Update mp_obj_type_t definitions for latest MicroPython. (#549)
* build.sh: Fix unix executable path.

This was updated recently to no longer copy to the ports/unix directory.

Use the version in the build directory instead if available.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>

* Update to new style mp_obj_type_t definitions.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-21 19:46:39 +02:00
Zoltán Vörös
57de23c1fb
fix how arctan2 treats scalars (#546) 2022-08-04 07:35:20 +02:00
Zoltán Vörös
dfed7a844a
implement nonzero (#540)
* implement nonzero for Boolean arrays

* remove axtls from build script

* extend nonzero to ndarrays of arbitrary dtype, and iterable, fix float tests

* temporarily disable circuitpython tests

* add nonzero documentation

* Added test script for np.nonzero()

Co-authored-by: Tejal Ashwini Barnwal <64950661+tejalbarnwal@users.noreply.github.com>
2022-08-03 20:56:45 +02:00
thetazero
a2c5ece991
Add numpy.block snippet (#539) 2022-07-16 18:00:10 +02:00
Damien George
2b4292abcc
Make optimize's bisect,fmin,newton use C stack instead of heap (#536)
Signed-off-by: Damien George <damien.p.george@gmail.com>
2022-07-11 19:18:40 +02:00