Commit graph

157 commits

Author SHA1 Message Date
Zoltán Vörös
86bed99394 added tobytes method 2020-09-23 20:07:42 +02:00
Zoltán Vörös
c631443971 fixed poly 2020-09-20 21:35:54 +02:00
Zoltán Vörös
fdd5920f7b first implementation of argsort (still has small glitch) 2020-09-14 21:50:35 +02:00
Zoltán Vörös
f681f36bc6 fixed sort 2020-08-29 13:19:11 +02:00
Zoltán Vörös
8f9fc87dff implemented roll 2020-08-21 18:27:33 +02:00
Zoltán Vörös
6b33c912de tabs to spaces 2020-08-15 19:24:49 +02:00
Zoltán Vörös
a97d7a7b7e more linting 2020-08-15 19:02:55 +02:00
Zoltán Vörös
1b9c212899 fixed tabs 2020-08-15 18:57:10 +02:00
Zoltán Vörös
4029c6dd86 fixed tabs 2020-08-15 18:56:07 +02:00
Zoltán Vörös
b24886826f fixed tabs 2020-08-15 18:54:08 +02:00
Zoltán Vörös
378bd4ebab fixed tabs 2020-08-15 18:43:52 +02:00
Zoltán Vörös
b95a0816f0 fixed tabs 2020-08-15 18:43:35 +02:00
Zoltán Vörös
1b7dc263e9 fixed tabs 2020-08-15 18:42:55 +02:00
Zoltán Vörös
fe08d5be1b fixed tabs 2020-08-15 18:42:01 +02:00
Zoltán Vörös
71c73f095a fixed tabs 2020-08-15 18:39:03 +02:00
Zoltán Vörös
0caf03bd3e fixed tabs 2020-08-15 18:38:29 +02:00
Zoltán Vörös
eb696d9d91 factored out associative operators 2020-08-15 18:35:28 +02:00
Zoltán Vörös
382d7a613e numerical sum sort of works now 2020-08-15 00:39:12 +02:00
Zoltán Vörös
a81a77a996 found some flash savings 2020-08-13 22:24:40 +02:00
Zoltán Vörös
506986fcb4 found/fixed bug in iterator 2020-08-13 22:08:12 +02:00
Zoltán Vörös
fca36e6d64 fixed iterator 2020-08-13 22:02:16 +02:00
Zoltán Vörös
76c1a3d242 linalg can now be compiled 2020-08-13 20:16:10 +02:00
Zoltán Vörös
da1d8c2ac1 shaved off 200 bytes for 1D arrays 2020-08-13 15:13:44 +02:00
Zoltán Vörös
80511c13e4 fixed couple of comments 2020-08-13 15:05:26 +02:00
Zoltán Vörös
1b08404975 fixed flatten for views 2020-08-13 14:52:33 +02:00
Zoltán Vörös
5ec64d39ee fft works with views now 2020-08-13 12:45:35 +02:00
Zoltán Vörös
034a8d7b58 fixed unary operators (ndarray_copy_view) 2020-08-13 12:11:12 +02:00
Zoltán Vörös
3be74df891 fixed iteration loops in vectorise 2020-08-12 15:46:59 +02:00
Zoltán Vörös
7e6216a1fc assignment by slices works 2020-08-11 15:12:16 +02:00
Zoltán Vörös
b212bd4cb9 fixed iterator code 2020-08-11 09:28:44 +02:00
Zoltán Vörös
0268f990d7 added ndinfo function 2020-08-08 12:43:57 +02:00
Zoltán Vörös
b1b93994c2 with the exception of pow, binary operators are functional 2020-08-08 11:20:17 +02:00
Zoltán Vörös
20796a10b3 tensor dimension can now be configured 2020-08-07 22:34:24 +02:00
Zoltán Vörös
63efdbf5a3 proof of concept binary function is working 2020-08-07 20:31:43 +02:00
Zoltán Vörös
d59fc169cd made code in printout tighter 2020-08-07 17:54:26 +02:00
Zoltán Vörös
44f0c46839 fixed printout 2020-08-07 17:52:41 +02:00
Zoltán Vörös
8c4d02f755 not entirely functional, safety backup 2020-08-05 22:35:21 +02:00
Zoltán Vörös
c9b7881add pulled in most recent changes from master 2020-07-31 23:25:36 +02:00
Zoltán Vörös
5cd5aaba35 approx is compiles 2020-07-30 22:07:53 +02:00
Zoltán Vörös
b4748dc966 fixed a couple of errors in ndarray.c 2020-07-30 21:16:49 +02:00
Zoltán Vörös
4ddbd8b73f base code can be compiled 2020-07-30 20:49:14 +02:00
Zoltán Vörös
ddfe1754ca switched to size_t length in reshape 2020-07-29 18:18:42 +02:00
Jonathan Hogg
f41d3eeeb7 Add MICROPY_FLOAT_CONST to all fp constants.
In order to get ulab to compile correctly against single floating point 
all of the constants need to switch to single format. Conveniently 
MicroPython has provided a macro to manage this switch. Use this 
througout.

Unfortunately also introduces a bunch of whitespace changes because 
there is a mass of trailing whitespace in the codebase and my editor is 
(correctly) configured to remove this.
2020-07-24 11:58:45 +01:00
23e1ef3b11 Add newlines where required in .rst files 2020-07-22 14:05:46 -05:00
Zoltán Vörös
80503300ad re-organised code, so that circuitpython documentation can automatically be generated 2020-07-22 20:19:14 +02:00
Zoltán Vörös
37140d531e added mp_obj_slice_indices to ndarray.c, so that it compiles for openmv 2020-06-16 19:32:41 +02:00
Zoltán Vörös
077bcc51ab
Merge branch 'master' into approx 2020-05-19 20:53:33 +02:00
Zoltán Vörös
78438727c4
Merge branch 'master' into print 2020-05-19 20:44:54 +02:00
Zoltán Vörös
f00d5dc6de fix for issue 117 2020-05-19 08:56:34 +02:00
Zoltán Vörös
d5e59cc21f no functional change, backup 2020-05-06 21:22:54 +02:00
Zoltán Vörös
70666817ce added set_printoptions/get_printoptions functions 2020-05-01 11:53:39 +02:00
Zoltán Vörös
855384f579 implemented minimum/maximum and clip in the compare module 2020-04-21 22:35:17 +02:00
Zoltán Vörös
f014128595 backup commit 2020-04-20 20:54:24 +02:00
Zoltán Vörös
84150d4166 fix transpose function to conform to numpy 2020-04-09 12:38:19 +02:00
86e7155ab7 generate_slice: Properly fix -Wsign-compare diagnostic
Instead of making the local unsigned--it must be permitted to
contain negative values--make the function parameter signed.
2020-04-06 16:38:51 -05:00
f1f10c27a8 Fix -Wsign-compare diagnostics
.. by adding casts or changing the type of a local variable.
2020-04-06 08:38:43 -05:00
daf4b07ef7 Fix -Wunused-parameter diagnostics
Here we actually get bugs fixed!  At many sites, mp_parse_arg_all's
first argument was the number of positional arguments required, rather
than the number actually supplied.

This fixes e.g., the bug where the linspace third positional argument
was not used as the "num" argmuent, and where too many positional args
were not treated as an error:

    >>> ulab.linspace(0, 1, 9)
    array([0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0], dtype=float)
    >>> ulab.linspace(0, 1, 1, 1)
    TypeError: extra positional arguments given

In the case of argmin/argmax of an iterable, it is now signaled to the user
that only the axis=None case is supported, instead of giving a wrong
result.
2020-04-06 08:33:18 -05:00
22605c6fe9 Fix -Wshadow diagnostics
A declaration of a local variable can "shadow" a parameter or another
local variable declared in an outer scope.

Since this can create confusion about which variable is referred to, it
is better to fix these diagnostics.

A variety of changes were made:
 - Add curly braces to reduce the scope of a variable (ndarray_unary_op)
   so that its scope has ended before the next scope where it is used
 - be consistent about whether a variable is declared with for-loop scope
   or not (ndarray_print_row)
 - remove a declaration so that the outer variable is used, after verifying
   this will function properly (insert_slice_list)
 - rename a variable introduced by a macro (RUN_SUM, RUN_STD) so it does
   not shadow another variable
2020-04-06 08:12:47 -05:00
11ed69dacf Fix -Wmissing-prototypes diagnostics
This diagnostic flag, enabled by default in CircuitPython, requires that
nonstatic functions have a previous prototype.  Since placing prototypes
in header files is the only way that mismatched arguments between function
definition and use sites can be detected, this is a valuable warning.

In the case of ulab, the majority of the  changes required were to mark
functions as "static" that were used only in a single C source file.
2020-04-06 08:05:20 -05:00
Zoltán Vörös
c69f2d9256 implemented the ==, and != binary operators 2020-04-04 22:14:36 +02:00
Zoltán Vörös
b4f83997e7
Merge branch 'master' into power 2020-04-02 19:08:00 +02:00
Zoltán Vörös
2e27a356f5 added unistd.h to ndarray.c to fix issue #73 2020-04-02 11:04:23 +02:00
Zoltán Vörös
1648325d69 added fast ndarray initialisation option 2020-04-02 09:41:13 +02:00
Zoltán Vörös
3153c86f09 fixed empty array error 2020-03-31 23:02:14 +02:00
Zoltán Vörös
ae0dfbc126 fixed binary error with empty arrays 2020-03-31 22:52:06 +02:00
Zoltán Vörös
a2d52b6454 implemented the ** operator, and the reversed binary operators 2020-03-31 21:38:47 +02:00
53c158bde3 ndarray.c: circuitpython needs translate() for mp_raise 2020-03-30 15:34:01 -05:00
Zoltán Vörös
b3562ae78c Boolean indexing raises TypeError, if index is not of Boolean type 2020-03-30 12:58:04 +02:00
Zoltán Vörös
ea4a7422ef fixing Boolean indexing issue 2020-03-30 12:45:54 +02:00
3dc52575f0 slice_length: avoid implementation-defined division by negative number
In CircuitPython (only), a the slice assignment to [-1👎-3] of an
ndarray of length 1 caused a crash.  This appears to be because in
CircuitPython, the internal pointer of an empty array was NULL rather than
pointing at some memory which happened to be valid and assignable.

This appears to be a corner case of how integer promotion rules work in C.
The expression `slice.stop - slice.start + (slice.step + correction)`
is type `unsigned long` and on a LP64 platform its value is
18446744073709551614.  This led to the function returning that this slice
had length 1 instead, during the automated tests.

By casting to signed types capable of holding indices and sizes, the
problem is corrected on both platforms.
2020-03-16 22:09:39 -05:00
Zoltán Vörös
3e53136a93 ndarrays can now be initialised from ndarrays 2020-03-12 07:17:54 +01:00
Jeff Epler
f9fabc5079 Fix handling of negative indices
I don't know why, but mp_seq_get_fast_slice_indexes adjusts "stop" in a
surprising way, and that led to the (remaining) differences in slicing
between ulab and built-in lists.

    // If the index is negative then stop points to the last item, not after it
    if (indexes->step < 0) {
        indexes->stop++;
    }

Call the underlying routine, mp_obj_slice_indices, instead.
2020-02-29 17:00:42 -06:00
Jeff Epler
585513ce76 Return empty slices as empty ndarrays, not exceptions
This matches the behavior of built-in lists as well as numpy
2020-02-29 16:57:59 -06:00
Zoltán Vörös
6fe015f134 properties are now defined in ndarray_properties.h 2020-02-16 19:49:01 +01:00
Zoltán Vörös
d8bfe46bd8 added __name__ to all submodules 2020-02-14 19:51:28 +01:00
Jeff Epler
fc80a25685 Increase CircuitPython compatibility
- Adapt to signature of mp_make_new_fun_t for mpy and cpy by ifdef
 - Use MP_OBJ_IS_TYPE instead of mp_obj_is_type
 - Ditto MP_OBJ_IS_INT
 - Use mp_const_none instead of MP_ROM_NONE
 - Ditto mp_const_true, mp_const_false
2020-02-12 10:15:47 -06:00
Zoltán Vörös
2c71467ced implemented ndarray properties 2020-02-11 20:08:37 +01:00
Zoltán Vörös
89170a13a6 fixed error in filter.c, removed asbytearray, and added buffer protocol to ndarray.c 2020-02-10 19:50:49 +01:00
Zoltán Vörös
936bb3bae5 corrected slicing error in issue #32 2020-02-09 19:56:32 +01:00
Zoltán Vörös
76ccd1a118 the master branch is configurable now 2020-02-07 21:23:24 +01:00
Zoltán Vörös
b2c4749962 replaced MP_ROM_PTR macro, wherever it made sense 2020-01-20 19:55:38 +01:00
Zoltán Vörös
68e38bc6b8 backup commit 2020-01-06 07:43:27 +01:00
Nicko van Someren
e33720e9c0 Fixed several issues preventing compilation on macOS 2019-11-11 13:39:28 -08:00
Zoltán Vörös
08b8fd0ae2 fixed float_t->mp_float_t mistake in ndarray.c 2019-11-04 19:28:06 +01:00
Zoltán Vörös
6e4911d96f replaced float with mp_float_t everywhere, so that the source can be compiled for all platforms 2019-11-01 14:28:29 +01:00
Zoltán Vörös
761ad69d71 fully implemented subscription methods 2019-10-29 21:12:12 +01:00
Zoltán Vörös
5599dd2f31 fixed small bug in rawsize 2019-10-19 19:45:26 +02:00
Zoltán Vörös
d4acce7b1f extended documentation, and moved size function to linalg 2019-10-16 20:08:16 +02:00
Zoltán Vörös
5caa711422 extended manual, inserted links to numpy functions 2019-10-12 22:33:13 +02:00
Zoltán Vörös
e30b8d6f4e added first version of manual, fixed small bug in roll 2019-10-11 21:45:14 +02:00
Zoltán Vörös
be6ab7ba18 extended universal functions for arbitrary typecode 2019-10-11 18:59:45 +02:00
Zoltán Vörös
0c161e2ba3 fixed error in iterator and make_new 2019-10-11 15:58:17 +02:00
Zoltán Vörös
68dd3a7423 this is mainly a safety backup; subscr is not fully implemented yet 2019-10-10 22:01:26 +02:00
Zoltán Vörös
1c233de552 extended unary operators in ndarray.c 2019-10-08 17:37:53 +02:00
Zoltán Vörös
4a8ecc28f2 added keyword arguments to linspace, made binary_op tighter 2019-10-07 20:49:29 +02:00
Zoltán Vörös
ba975c100d added comparison operators to ndarray 2019-10-05 15:59:03 +02:00
Zoltán Vörös
7feaf8c57e removed printf statement in ndarray.c 2019-10-04 20:11:28 +02:00
Zoltán Vörös
cadae1dbf7 extended linalg, added .flatten to ndarray 2019-10-04 20:06:04 +02:00
Zoltán Vörös
52694959d3 bit of clean-up in binary_op/removed upcasting() 2019-10-04 12:32:49 +02:00
Zoltán Vörös
6a65d33445 fixed half of the binary operator code (implemented macros) 2019-09-27 20:23:25 +02:00