Skip to content

Commit 6b82e5c

Browse files
committed
Conditionalize the ulab.numpy code on CIRCUITPY_ULAB
This allows _eve to build without ulab.
1 parent 61154d8 commit 6b82e5c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

shared-bindings/_eve/__init__.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
#include "py/runtime.h"
1212
#include "py/binary.h"
1313

14+
#if CIRCUITPY_ULAB
1415
#include "extmod/ulab/code/ulab.h"
1516
#include "extmod/ulab/code/ndarray.h"
17+
#endif
1618

1719
#include "shared-module/_eve/__init__.h"
1820
#include "shared-bindings/_eve/__init__.h"
@@ -847,6 +849,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii);
847849

848850
// }
849851

852+
#if CIRCUITPY_ULAB
850853
static bool is_vector(mp_obj_t a) {
851854
if (!mp_obj_is_type(a, &ulab_ndarray_type)) {
852855
return false;
@@ -857,6 +860,7 @@ static bool is_vector(mp_obj_t a) {
857860
}
858861
return true;
859862
}
863+
#endif
860864

861865
// Hand-written functions {
862866

@@ -867,6 +871,7 @@ static bool is_vector(mp_obj_t a) {
867871
//| :param float y: pixel y-coordinate"""
868872
//| ...
869873
static mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
874+
#if CIRCUITPY_ULAB
870875
if (is_vector(a0) && is_vector(a1)) {
871876
ndarray_obj_t *v0 = MP_OBJ_TO_PTR(a0);
872877
ndarray_obj_t *v1 = MP_OBJ_TO_PTR(a1);
@@ -875,11 +880,12 @@ static mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
875880
for (size_t i = 0; i < v0->len; i++, p0++, p1++) {
876881
common_hal__eve_Vertex2f(EVEHAL(self), *p0, *p1);
877882
}
878-
} else {
879-
mp_float_t x = mp_obj_get_float(a0);
880-
mp_float_t y = mp_obj_get_float(a1);
881-
common_hal__eve_Vertex2f(EVEHAL(self), x, y);
883+
return mp_const_none;
882884
}
885+
#endif
886+
mp_float_t x = mp_obj_get_float(a0);
887+
mp_float_t y = mp_obj_get_float(a1);
888+
common_hal__eve_Vertex2f(EVEHAL(self), x, y);
883889
return mp_const_none;
884890
}
885891
static MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f);

0 commit comments

Comments
 (0)