Skip to content

Commit

Permalink
Switch to using MP_ERROR_TEXT in CircuitPython, change ulab accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
jepler committed Oct 30, 2023
1 parent 2df210f commit 9c9e953
Show file tree
Hide file tree
Showing 23 changed files with 181 additions and 185 deletions.
52 changes: 26 additions & 26 deletions code/ndarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ mp_obj_t ndarray_dtype_make_new(const mp_obj_type_t *type, size_t n_args, size_t
if((_dtype != NDARRAY_BOOL) && (_dtype != NDARRAY_UINT8)
&& (_dtype != NDARRAY_INT8) && (_dtype != NDARRAY_UINT16)
&& (_dtype != NDARRAY_INT16) && (_dtype != NDARRAY_FLOAT)) {
mp_raise_TypeError(translate("data type not understood"));
mp_raise_TypeError(MP_ERROR_TEXT("data type not understood"));
}
} else {
GET_STR_DATA_LEN(_args[0].u_obj, _dtype_, len);
Expand All @@ -220,7 +220,7 @@ mp_obj_t ndarray_dtype_make_new(const mp_obj_type_t *type, size_t n_args, size_t
}
#endif
else {
mp_raise_TypeError(translate("data type not understood"));
mp_raise_TypeError(MP_ERROR_TEXT("data type not understood"));
}
}
dtype->dtype = _dtype;
Expand Down Expand Up @@ -252,7 +252,7 @@ mp_obj_t ndarray_dtype(mp_obj_t self_in) {
&& (*_dtype != NDARRAY_COMPLEX)
#endif
)) {
mp_raise_TypeError(translate("data type not understood"));
mp_raise_TypeError(MP_ERROR_TEXT("data type not understood"));
}
dtype = *_dtype;
}
Expand Down Expand Up @@ -504,7 +504,7 @@ bool ndarray_is_dense(ndarray_obj_t *ndarray) {
static size_t multiply_size(size_t a, size_t b) {
size_t result;
if (__builtin_mul_overflow(a, b, &result)) {
mp_raise_ValueError(translate("array is too big"));
mp_raise_ValueError(MP_ERROR_TEXT("array is too big"));
}
return result;
}
Expand All @@ -531,7 +531,7 @@ ndarray_obj_t *ndarray_new_ndarray(uint8_t ndim, size_t *shape, int32_t *strides
}

if (SIZE_MAX / ndarray->itemsize <= ndarray->len) {
mp_raise_ValueError(translate("ndarray length overflows"));
mp_raise_ValueError(MP_ERROR_TEXT("ndarray length overflows"));
}

// if the length is 0, still allocate a single item, so that contractions can be handled
Expand Down Expand Up @@ -690,7 +690,7 @@ ndarray_obj_t *ndarray_copy_view_convert_type(ndarray_obj_t *source, uint8_t dty
#if ULAB_SUPPORTS_COMPLEX
if(source->dtype == NDARRAY_COMPLEX) {
if(dtype != NDARRAY_COMPLEX) {
mp_raise_TypeError(translate("cannot convert complex type"));
mp_raise_TypeError(MP_ERROR_TEXT("cannot convert complex type"));
} else {
memcpy(array, sarray, complex_size);
}
Expand Down Expand Up @@ -856,7 +856,7 @@ ndarray_obj_t *ndarray_from_iterable(mp_obj_t obj, uint8_t dtype) {
break;
}
if(ndim == ULAB_MAX_DIMS) {
mp_raise_ValueError(translate("too many dimensions"));
mp_raise_ValueError(MP_ERROR_TEXT("too many dimensions"));
}
shape[ndim] = MP_OBJ_SMALL_INT_VALUE(mp_obj_len_maybe(item));
if(shape[ndim] == 0) {
Expand Down Expand Up @@ -1046,13 +1046,13 @@ static mp_bound_slice_t generate_slice(mp_int_t n, mp_obj_t index) {
_index += n;
}
if((_index >= n) || (_index < 0)) {
mp_raise_msg(&mp_type_IndexError, translate("index is out of bounds"));
mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("index is out of bounds"));
}
slice.start = _index;
slice.stop = _index + 1;
slice.step = 1;
} else {
mp_raise_msg(&mp_type_IndexError, translate("indices must be integers, slices, or Boolean lists"));
mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("indices must be integers, slices, or Boolean lists"));
}
return slice;
}
Expand All @@ -1078,7 +1078,7 @@ static ndarray_obj_t *ndarray_view_from_slices(ndarray_obj_t *ndarray, mp_obj_tu
k += ndarray->shape[ULAB_MAX_DIMS - ndarray->ndim + i];
}
if((k >= (int32_t)ndarray->shape[ULAB_MAX_DIMS - ndarray->ndim + i]) || (k < 0)) {
mp_raise_msg(&mp_type_IndexError, translate("index is out of bounds"));
mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("index is out of bounds"));
}
offset += ndarray->strides[ULAB_MAX_DIMS - ndarray->ndim + i] * k;
// ... and then we have to shift the shapes to the right
Expand All @@ -1105,7 +1105,7 @@ void ndarray_assign_view(ndarray_obj_t *view, ndarray_obj_t *values) {
int32_t *lstrides = m_new0(int32_t, ULAB_MAX_DIMS);
int32_t *rstrides = m_new0(int32_t, ULAB_MAX_DIMS);
if(!ndarray_can_broadcast(view, values, &ndim, shape, lstrides, rstrides)) {
mp_raise_ValueError(translate("operands could not be broadcast together"));
mp_raise_ValueError(MP_ERROR_TEXT("operands could not be broadcast together"));
} else {

ndarray_obj_t *ndarray = ndarray_copy_view_convert_type(values, view->dtype);
Expand Down Expand Up @@ -1171,7 +1171,7 @@ void ndarray_assign_view(ndarray_obj_t *view, ndarray_obj_t *values) {
static mp_obj_t ndarray_from_boolean_index(ndarray_obj_t *ndarray, ndarray_obj_t *index) {
// returns a 1D array, indexed by a Boolean array
if(ndarray->len != index->len) {
mp_raise_ValueError(translate("array and index length must be equal"));
mp_raise_ValueError(MP_ERROR_TEXT("array and index length must be equal"));
}
uint8_t *iarray = (uint8_t *)index->array;
// first we have to find out how many trues there are
Expand Down Expand Up @@ -1223,7 +1223,7 @@ static mp_obj_t ndarray_assign_from_boolean_index(ndarray_obj_t *ndarray, ndarra
#if ULAB_SUPPORTS_COMPLEX
if(values->dtype == NDARRAY_COMPLEX) {
if(ndarray->dtype != NDARRAY_COMPLEX) {
mp_raise_TypeError(translate("cannot convert complex to dtype"));
mp_raise_TypeError(MP_ERROR_TEXT("cannot convert complex to dtype"));
} else {
uint8_t *array = (uint8_t *)ndarray->array;
for(size_t i = 0; i < ndarray->len; i++) {
Expand Down Expand Up @@ -1314,7 +1314,7 @@ static mp_obj_t ndarray_get_slice(ndarray_obj_t *ndarray, mp_obj_t index, ndarra
if(mp_obj_is_type(index, &ulab_ndarray_type)) {
ndarray_obj_t *nindex = MP_OBJ_TO_PTR(index);
if((nindex->ndim > 1) || (nindex->boolean == false)) {
mp_raise_NotImplementedError(translate("operation is implemented for 1D Boolean arrays only"));
mp_raise_NotImplementedError(MP_ERROR_TEXT("operation is implemented for 1D Boolean arrays only"));
}
if(values == NULL) { // return value(s)
return ndarray_from_boolean_index(ndarray, nindex);
Expand All @@ -1327,7 +1327,7 @@ static mp_obj_t ndarray_get_slice(ndarray_obj_t *ndarray, mp_obj_t index, ndarra
if(mp_obj_is_type(index, &mp_type_tuple)) {
tuple = MP_OBJ_TO_PTR(index);
if(tuple->len > ndarray->ndim) {
mp_raise_msg(&mp_type_IndexError, translate("too many indices"));
mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("too many indices"));
}
} else {
mp_obj_t *items = m_new(mp_obj_t, 1);
Expand All @@ -1351,7 +1351,7 @@ static mp_obj_t ndarray_get_slice(ndarray_obj_t *ndarray, mp_obj_t index, ndarra

mp_obj_t ndarray_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
if(value == MP_OBJ_NULL) {
mp_raise_ValueError(translate("cannot delete array elements"));
mp_raise_ValueError(MP_ERROR_TEXT("cannot delete array elements"));
}
ndarray_obj_t *self = MP_OBJ_TO_PTR(self_in);

Expand Down Expand Up @@ -1429,7 +1429,7 @@ mp_obj_t ndarray_flatten(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a
ndarray_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
GET_STR_DATA_LEN(args[0].u_obj, order, len);
if((len != 1) || ((memcmp(order, "C", 1) != 0) && (memcmp(order, "F", 1) != 0))) {
mp_raise_ValueError(translate("flattening order must be either 'C', or 'F'"));
mp_raise_ValueError(MP_ERROR_TEXT("flattening order must be either 'C', or 'F'"));
}

uint8_t *sarray = (uint8_t *)self->array;
Expand Down Expand Up @@ -1567,7 +1567,7 @@ mp_obj_t ndarray_tobytes(mp_obj_t self_in) {
// Piping into a bytearray makes sense for dense arrays only,
// so bail out, if that is not the case
if(!ndarray_is_dense(self)) {
mp_raise_ValueError(translate("tobytes can be invoked for dense arrays only"));
mp_raise_ValueError(MP_ERROR_TEXT("tobytes can be invoked for dense arrays only"));
}
return mp_obj_new_bytearray_by_ref(self->itemsize * self->len, self->array);
}
Expand Down Expand Up @@ -1707,7 +1707,7 @@ mp_obj_t ndarray_binary_op(mp_binary_op_t _op, mp_obj_t lobj, mp_obj_t robj) {
broadcastable = ndarray_can_broadcast(lhs, rhs, &ndim, shape, lstrides, rstrides);
}
if(!broadcastable) {
mp_raise_ValueError(translate("operands could not be broadcast together"));
mp_raise_ValueError(MP_ERROR_TEXT("operands could not be broadcast together"));
m_del(size_t, shape, ULAB_MAX_DIMS);
m_del(int32_t, lstrides, ULAB_MAX_DIMS);
m_del(int32_t, rstrides, ULAB_MAX_DIMS);
Expand Down Expand Up @@ -1917,7 +1917,7 @@ mp_obj_t ndarray_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
#else
if(self->dtype == NDARRAY_FLOAT) {
#endif
mp_raise_ValueError(translate("operation is not supported for given type"));
mp_raise_ValueError(MP_ERROR_TEXT("operation is not supported for given type"));
}
// we can invert the content byte by byte, no need to distinguish between different dtypes
ndarray = ndarray_copy_view(self); // from this point, this is a dense copy
Expand Down Expand Up @@ -2006,7 +2006,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(ndarray_transpose_obj, ndarray_transpose);
mp_obj_t ndarray_reshape_core(mp_obj_t oin, mp_obj_t _shape, bool inplace) {
ndarray_obj_t *source = MP_OBJ_TO_PTR(oin);
if(!mp_obj_is_type(_shape, &mp_type_tuple) && !mp_obj_is_int(_shape)) {
mp_raise_TypeError(translate("shape must be integer or tuple of integers"));
mp_raise_TypeError(MP_ERROR_TEXT("shape must be integer or tuple of integers"));
}

mp_obj_tuple_t *shape;
Expand All @@ -2020,7 +2020,7 @@ mp_obj_t ndarray_reshape_core(mp_obj_t oin, mp_obj_t _shape, bool inplace) {
}

if(shape->len > ULAB_MAX_DIMS) {
mp_raise_ValueError(translate("maximum number of dimensions is " MP_STRINGIFY(ULAB_MAX_DIMS)));
mp_raise_ValueError(MP_ERROR_TEXT("maximum number of dimensions is " MP_STRINGIFY(ULAB_MAX_DIMS)));
}

size_t new_length = 1;
Expand All @@ -2040,14 +2040,14 @@ mp_obj_t ndarray_reshape_core(mp_obj_t oin, mp_obj_t _shape, bool inplace) {
}

if(unknown_dim > 1) {
mp_raise_ValueError(translate("can only specify one unknown dimension"));
mp_raise_ValueError(MP_ERROR_TEXT("can only specify one unknown dimension"));
} else if(unknown_dim == 1) {
new_shape[unknown_index] = source->len / new_length;
new_length = source->len;
}

if(source->len != new_length) {
mp_raise_ValueError(translate("cannot reshape array"));
mp_raise_ValueError(MP_ERROR_TEXT("cannot reshape array"));
}

ndarray_obj_t *ndarray;
Expand All @@ -2064,7 +2064,7 @@ mp_obj_t ndarray_reshape_core(mp_obj_t oin, mp_obj_t _shape, bool inplace) {
}
} else {
if(inplace) {
mp_raise_ValueError(translate("cannot assign new shape"));
mp_raise_ValueError(MP_ERROR_TEXT("cannot assign new shape"));
}
if(mp_obj_is_type(_shape, &mp_type_tuple)) {
ndarray = ndarray_new_ndarray_from_tuple(shape, source->dtype);
Expand All @@ -2087,7 +2087,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(ndarray_reshape_obj, ndarray_reshape);
#if ULAB_NUMPY_HAS_NDINFO
mp_obj_t ndarray_info(mp_obj_t obj_in) {
if(!mp_obj_is_type(obj_in, &ulab_ndarray_type)) {
mp_raise_TypeError(translate("function is defined for ndarrays only"));
mp_raise_TypeError(MP_ERROR_TEXT("function is defined for ndarrays only"));
}
ndarray_obj_t *ndarray = MP_OBJ_TO_PTR(obj_in);
mp_printf(MP_PYTHON_PRINTER, "class: ndarray\n");
Expand Down
4 changes: 0 additions & 4 deletions code/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ typedef struct _mp_obj_slice_t {
#endif
#endif

#if !CIRCUITPY
#define translate(x) MP_ERROR_TEXT(x)
#endif

#define ndarray_set_value(a, b, c, d) mp_binary_set_val_array(a, b, c, d)
void ndarray_set_complex_value(void *, size_t , mp_obj_t );

Expand Down
6 changes: 3 additions & 3 deletions code/ndarray_operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ mp_obj_t ndarray_binary_power(ndarray_obj_t *lhs, ndarray_obj_t *rhs,
mp_obj_t ndarray_inplace_ams(ndarray_obj_t *lhs, ndarray_obj_t *rhs, int32_t *rstrides, uint8_t optype) {

if((lhs->dtype != NDARRAY_FLOAT) && (rhs->dtype == NDARRAY_FLOAT)) {
mp_raise_TypeError(translate("cannot cast output with casting rule"));
mp_raise_TypeError(MP_ERROR_TEXT("cannot cast output with casting rule"));
}
uint8_t *larray = (uint8_t *)lhs->array;
uint8_t *rarray = (uint8_t *)rhs->array;
Expand Down Expand Up @@ -890,7 +890,7 @@ mp_obj_t ndarray_inplace_ams(ndarray_obj_t *lhs, ndarray_obj_t *rhs, int32_t *rs
mp_obj_t ndarray_inplace_divide(ndarray_obj_t *lhs, ndarray_obj_t *rhs, int32_t *rstrides) {

if((lhs->dtype != NDARRAY_FLOAT)) {
mp_raise_TypeError(translate("results cannot be cast to specified type"));
mp_raise_TypeError(MP_ERROR_TEXT("results cannot be cast to specified type"));
}
uint8_t *larray = (uint8_t *)lhs->array;
uint8_t *rarray = (uint8_t *)rhs->array;
Expand All @@ -914,7 +914,7 @@ mp_obj_t ndarray_inplace_divide(ndarray_obj_t *lhs, ndarray_obj_t *rhs, int32_t
mp_obj_t ndarray_inplace_power(ndarray_obj_t *lhs, ndarray_obj_t *rhs, int32_t *rstrides) {

if((lhs->dtype != NDARRAY_FLOAT)) {
mp_raise_TypeError(translate("results cannot be cast to specified type"));
mp_raise_TypeError(MP_ERROR_TEXT("results cannot be cast to specified type"));
}
uint8_t *larray = (uint8_t *)lhs->array;
uint8_t *rarray = (uint8_t *)rhs->array;
Expand Down
6 changes: 3 additions & 3 deletions code/numpy/approx.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ STATIC mp_obj_t approx_interp(size_t n_args, const mp_obj_t *pos_args, mp_map_t
COMPLEX_DTYPE_NOT_IMPLEMENTED(xp->dtype)
COMPLEX_DTYPE_NOT_IMPLEMENTED(fp->dtype)
if((xp->ndim != 1) || (fp->ndim != 1) || (xp->len < 2) || (fp->len < 2) || (xp->len != fp->len)) {
mp_raise_ValueError(translate("interp is defined for 1D iterables of equal length"));
mp_raise_ValueError(MP_ERROR_TEXT("interp is defined for 1D iterables of equal length"));
}

ndarray_obj_t *y = ndarray_new_linear_array(x->len, NDARRAY_FLOAT);
Expand Down Expand Up @@ -168,7 +168,7 @@ STATIC mp_obj_t approx_trapz(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
return mp_obj_new_float(mean);
}
if((y->ndim != 1)) {
mp_raise_ValueError(translate("trapz is defined for 1D iterables"));
mp_raise_ValueError(MP_ERROR_TEXT("trapz is defined for 1D iterables"));
}

mp_float_t (*funcy)(void *) = ndarray_get_float_function(y->dtype);
Expand All @@ -181,7 +181,7 @@ STATIC mp_obj_t approx_trapz(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
x = ndarray_from_mp_obj(args[1].u_obj, 0); // x must hold an increasing sequence of independent values
COMPLEX_DTYPE_NOT_IMPLEMENTED(x->dtype)
if((x->ndim != 1) || (y->len != x->len)) {
mp_raise_ValueError(translate("trapz is defined for 1D arrays of equal length"));
mp_raise_ValueError(MP_ERROR_TEXT("trapz is defined for 1D arrays of equal length"));
}

mp_float_t (*funcx)(void *) = ndarray_get_float_function(x->dtype);
Expand Down
6 changes: 3 additions & 3 deletions code/numpy/bitwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ mp_obj_t *bitwise_binary_operators(mp_obj_t x1, mp_obj_t x2, uint8_t optype) {

#if ULAB_SUPPORTS_COMPLEX
if((lhs->dtype == NDARRAY_FLOAT) || (rhs->dtype == NDARRAY_FLOAT) || (lhs->dtype == NDARRAY_COMPLEX) || (rhs->dtype == NDARRAY_COMPLEX)) {
mp_raise_ValueError(translate("not supported for input types"));
mp_raise_ValueError(MP_ERROR_TEXT("not supported for input types"));
}
#else
if((lhs->dtype == NDARRAY_FLOAT) || (rhs->dtype == NDARRAY_FLOAT)) {
mp_raise_ValueError(translate("not supported for input types"));
mp_raise_ValueError(MP_ERROR_TEXT("not supported for input types"));
}
#endif

Expand All @@ -348,7 +348,7 @@ mp_obj_t *bitwise_binary_operators(mp_obj_t x1, mp_obj_t x2, uint8_t optype) {
m_del(size_t, shape, ULAB_MAX_DIMS);
m_del(int32_t, lstrides, ULAB_MAX_DIMS);
m_del(int32_t, rstrides, ULAB_MAX_DIMS);
mp_raise_ValueError(translate("operands could not be broadcast together"));
mp_raise_ValueError(MP_ERROR_TEXT("operands could not be broadcast together"));
}

ndarray_obj_t *results = NULL;
Expand Down
10 changes: 5 additions & 5 deletions code/numpy/carray/carray.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mp_obj_t carray_real(mp_obj_t _source) {
return MP_OBJ_FROM_PTR(target);
}
} else {
mp_raise_NotImplementedError(translate("function is implemented for ndarrays only"));
mp_raise_NotImplementedError(MP_ERROR_TEXT("function is implemented for ndarrays only"));
}
return mp_const_none;
}
Expand All @@ -73,7 +73,7 @@ mp_obj_t carray_imag(mp_obj_t _source) {
return MP_OBJ_FROM_PTR(target);
}
} else {
mp_raise_NotImplementedError(translate("function is implemented for ndarrays only"));
mp_raise_NotImplementedError(MP_ERROR_TEXT("function is implemented for ndarrays only"));
}
return mp_const_none;
}
Expand Down Expand Up @@ -111,7 +111,7 @@ mp_obj_t carray_conjugate(mp_obj_t _source) {
} else if(mp_obj_is_int(_source) || mp_obj_is_float(_source)) {
return _source;
} else {
mp_raise_TypeError(translate("input must be an ndarray, or a scalar"));
mp_raise_TypeError(MP_ERROR_TEXT("input must be an ndarray, or a scalar"));
}
}
// this should never happen
Expand Down Expand Up @@ -183,11 +183,11 @@ static void carray_sort_complex_(mp_float_t *array, size_t len) {

mp_obj_t carray_sort_complex(mp_obj_t _source) {
if(!mp_obj_is_type(_source, &ulab_ndarray_type)) {
mp_raise_TypeError(translate("input must be a 1D ndarray"));
mp_raise_TypeError(MP_ERROR_TEXT("input must be a 1D ndarray"));
}
ndarray_obj_t *source = MP_OBJ_TO_PTR(_source);
if(source->ndim != 1) {
mp_raise_TypeError(translate("input must be a 1D ndarray"));
mp_raise_TypeError(MP_ERROR_TEXT("input must be a 1D ndarray"));
}

ndarray_obj_t *ndarray = ndarray_copy_view_convert_type(source, NDARRAY_COMPLEX);
Expand Down
2 changes: 1 addition & 1 deletion code/numpy/carray/carray_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#if ULAB_SUPPORTS_COMPLEX

void raise_complex_NotImplementedError(void) {
mp_raise_NotImplementedError(translate("not implemented for complex dtype"));
mp_raise_NotImplementedError(MP_ERROR_TEXT("not implemented for complex dtype"));
}

#endif
6 changes: 3 additions & 3 deletions code/numpy/compare.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static mp_obj_t compare_function(mp_obj_t x1, mp_obj_t x2, uint8_t op) {
int32_t *lstrides = m_new(int32_t, ULAB_MAX_DIMS);
int32_t *rstrides = m_new(int32_t, ULAB_MAX_DIMS);
if(!ndarray_can_broadcast(lhs, rhs, &ndim, shape, lstrides, rstrides)) {
mp_raise_ValueError(translate("operands could not be broadcast together"));
mp_raise_ValueError(MP_ERROR_TEXT("operands could not be broadcast together"));
m_del(size_t, shape, ULAB_MAX_DIMS);
m_del(int32_t, lstrides, ULAB_MAX_DIMS);
m_del(int32_t, rstrides, ULAB_MAX_DIMS);
Expand Down Expand Up @@ -263,7 +263,7 @@ static mp_obj_t compare_isinf_isfinite(mp_obj_t _x, uint8_t mask) {

return MP_OBJ_FROM_PTR(results);
} else {
mp_raise_TypeError(translate("wrong input type"));
mp_raise_TypeError(MP_ERROR_TEXT("wrong input type"));
}
return mp_const_none;
}
Expand Down Expand Up @@ -470,7 +470,7 @@ mp_obj_t compare_where(mp_obj_t _condition, mp_obj_t _x, mp_obj_t _y) {
if(!ndarray_can_broadcast(c, x, &ndim, oshape, cstrides, ystrides) ||
!ndarray_can_broadcast(c, y, &ndim, oshape, cstrides, ystrides) ||
!ndarray_can_broadcast(x, y, &ndim, oshape, xstrides, ystrides)) {
mp_raise_ValueError(translate("operands could not be broadcast together"));
mp_raise_ValueError(MP_ERROR_TEXT("operands could not be broadcast together"));
}

ndim = MAX(MAX(c->ndim, x->ndim), y->ndim);
Expand Down
Loading

0 comments on commit 9c9e953

Please sign in to comment.