Skip to content

Commit 844f6e5

Browse files
authored
fix type inference
* fix type inference * make checks inclusive for negative values of integers * move to newer version of ubuntu * fix iterator macros * fix iterator macros
1 parent 1398a86 commit 844f6e5

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
os:
23-
- ubuntu-20.04
23+
- ubuntu-24.04
2424
- macOS-latest
2525
dims: [1, 2, 3, 4]
2626
runs-on: ${{ matrix.os }}
@@ -61,7 +61,7 @@ jobs:
6161
strategy:
6262
matrix:
6363
os:
64-
- ubuntu-20.04
64+
- ubuntu-24.04
6565
- macOS-latest
6666
dims: [1, 2, 3, 4]
6767
runs-on: ${{ matrix.os }}

code/ndarray.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,15 +1482,15 @@ ndarray_obj_t *ndarray_from_mp_obj(mp_obj_t obj, uint8_t other_type) {
14821482

14831483
if(mp_obj_is_int(obj)) {
14841484
int32_t ivalue = mp_obj_get_int(obj);
1485-
if((ivalue < -32767) || (ivalue > 32767)) {
1485+
if((ivalue < -32768) || (ivalue > 65535)) {
14861486
// the integer value clearly does not fit the ulab integer types, so move on to float
14871487
ndarray = ndarray_new_linear_array(1, NDARRAY_FLOAT);
14881488
mp_float_t *array = (mp_float_t *)ndarray->array;
14891489
array[0] = (mp_float_t)ivalue;
14901490
} else {
14911491
uint8_t dtype;
14921492
if(ivalue < 0) {
1493-
if(ivalue > -128) {
1493+
if(ivalue >= -128) {
14941494
dtype = NDARRAY_INT8;
14951495
} else {
14961496
dtype = NDARRAY_INT16;

code/ndarray.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,8 @@ ndarray_obj_t *ndarray_from_mp_obj(mp_obj_t , uint8_t );
731731
do {
732732

733733
#define ITERATOR_TAIL(_source_, _source_array_)\
734-
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 1];\
735-
_l_++;\
734+
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 1];\
735+
_l_++;\
736736
} while(_l_ < (_source_)->shape[ULAB_MAX_DIMS - 1]);\
737737
(_source_array_) -= (_source_)->strides[ULAB_MAX_DIMS - 1] * (_source_)->shape[ULAB_MAX_DIMS - 1];\
738738
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 2];\
@@ -750,17 +750,17 @@ ndarray_obj_t *ndarray_from_mp_obj(mp_obj_t , uint8_t );
750750
do {
751751

752752
#define ITERATOR_TAIL(_source_, _source_array_)\
753-
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 1];\
754-
_l_++;\
753+
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 1];\
754+
_l_++;\
755755
} while(_l_ < (_source_)->shape[ULAB_MAX_DIMS - 1]);\
756756
(_source_array_) -= (_source_)->strides[ULAB_MAX_DIMS - 1] * (_source_)->shape[ULAB_MAX_DIMS - 1];\
757757
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 2];\
758758
_k_++;\
759759
} while(_k_ < (_source_)->shape[ULAB_MAX_DIMS - 2]);\
760-
(_source_array_) -= (_source_)->strides[ULAB_MAX_DIMS - 2] * (_source_)->shape[ULAB_MAX_DIMS - 2];\
761-
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 3];\
762-
j++;\
763-
} while(j < (_source_)->shape[ULAB_MAX_DIMS - 3]);
760+
(_source_array_) -= (_source_)->strides[ULAB_MAX_DIMS - 2] * (_source_)->shape[ULAB_MAX_DIMS - 2];\
761+
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 3];\
762+
_j_++;\
763+
} while(_j_ < (_source_)->shape[ULAB_MAX_DIMS - 3]);
764764

765765
#endif /* ULAB_MAX_DIMS == 3 */
766766

@@ -776,16 +776,16 @@ ndarray_obj_t *ndarray_from_mp_obj(mp_obj_t , uint8_t );
776776
do {
777777

778778
#define ITERATOR_TAIL(_source_, _source_array_)\
779-
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 1];\
780-
_l_++;\
779+
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 1];\
780+
_l_++;\
781781
} while(_l_ < (_source_)->shape[ULAB_MAX_DIMS - 1]);\
782782
(_source_array_) -= (_source_)->strides[ULAB_MAX_DIMS - 1] * (_source_)->shape[ULAB_MAX_DIMS - 1];\
783783
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 2];\
784784
_k_++;\
785785
} while(_k_ < (_source_)->shape[ULAB_MAX_DIMS - 2]);\
786-
(_source_array_) -= (_source_)->strides[ULAB_MAX_DIMS - 2] * (_source_)->shape[ULAB_MAX_DIMS - 2];\
787-
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 3];\
788-
_j_++;\
786+
(_source_array_) -= (_source_)->strides[ULAB_MAX_DIMS - 2] * (_source_)->shape[ULAB_MAX_DIMS - 2];\
787+
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 3];\
788+
_j_++;\
789789
} while(_j_ < (_source_)->shape[ULAB_MAX_DIMS - 3]);\
790790
(_source_array_) -= (_source_)->strides[ULAB_MAX_DIMS - 3] * (_source_)->shape[ULAB_MAX_DIMS - 3];\
791791
(_source_array_) += (_source_)->strides[ULAB_MAX_DIMS - 4];\

code/ulab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "user/user.h"
3434
#include "utils/utils.h"
3535

36-
#define ULAB_VERSION 6.7.6
36+
#define ULAB_VERSION 6.7.7
3737
#define xstr(s) str(s)
3838
#define str(s) #s
3939

docs/ulab-change-log.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Fri, 06 Jun 2025
2+
3+
version 6.7.7
4+
5+
fix ndarray type inference for micropython objects
6+
17
Thu, 29 May 2025
28

39
version 6.7.6

0 commit comments

Comments
 (0)