Skip to content

Commit 9c9e953

Browse files
committed
Switch to using MP_ERROR_TEXT in CircuitPython, change ulab accordingly
1 parent 2df210f commit 9c9e953

File tree

23 files changed

+181
-185
lines changed

23 files changed

+181
-185
lines changed

code/ndarray.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ mp_obj_t ndarray_dtype_make_new(const mp_obj_type_t *type, size_t n_args, size_t
199199
if((_dtype != NDARRAY_BOOL) && (_dtype != NDARRAY_UINT8)
200200
&& (_dtype != NDARRAY_INT8) && (_dtype != NDARRAY_UINT16)
201201
&& (_dtype != NDARRAY_INT16) && (_dtype != NDARRAY_FLOAT)) {
202-
mp_raise_TypeError(translate("data type not understood"));
202+
mp_raise_TypeError(MP_ERROR_TEXT("data type not understood"));
203203
}
204204
} else {
205205
GET_STR_DATA_LEN(_args[0].u_obj, _dtype_, len);
@@ -220,7 +220,7 @@ mp_obj_t ndarray_dtype_make_new(const mp_obj_type_t *type, size_t n_args, size_t
220220
}
221221
#endif
222222
else {
223-
mp_raise_TypeError(translate("data type not understood"));
223+
mp_raise_TypeError(MP_ERROR_TEXT("data type not understood"));
224224
}
225225
}
226226
dtype->dtype = _dtype;
@@ -252,7 +252,7 @@ mp_obj_t ndarray_dtype(mp_obj_t self_in) {
252252
&& (*_dtype != NDARRAY_COMPLEX)
253253
#endif
254254
)) {
255-
mp_raise_TypeError(translate("data type not understood"));
255+
mp_raise_TypeError(MP_ERROR_TEXT("data type not understood"));
256256
}
257257
dtype = *_dtype;
258258
}
@@ -504,7 +504,7 @@ bool ndarray_is_dense(ndarray_obj_t *ndarray) {
504504
static size_t multiply_size(size_t a, size_t b) {
505505
size_t result;
506506
if (__builtin_mul_overflow(a, b, &result)) {
507-
mp_raise_ValueError(translate("array is too big"));
507+
mp_raise_ValueError(MP_ERROR_TEXT("array is too big"));
508508
}
509509
return result;
510510
}
@@ -531,7 +531,7 @@ ndarray_obj_t *ndarray_new_ndarray(uint8_t ndim, size_t *shape, int32_t *strides
531531
}
532532

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

537537
// if the length is 0, still allocate a single item, so that contractions can be handled
@@ -690,7 +690,7 @@ ndarray_obj_t *ndarray_copy_view_convert_type(ndarray_obj_t *source, uint8_t dty
690690
#if ULAB_SUPPORTS_COMPLEX
691691
if(source->dtype == NDARRAY_COMPLEX) {
692692
if(dtype != NDARRAY_COMPLEX) {
693-
mp_raise_TypeError(translate("cannot convert complex type"));
693+
mp_raise_TypeError(MP_ERROR_TEXT("cannot convert complex type"));
694694
} else {
695695
memcpy(array, sarray, complex_size);
696696
}
@@ -856,7 +856,7 @@ ndarray_obj_t *ndarray_from_iterable(mp_obj_t obj, uint8_t dtype) {
856856
break;
857857
}
858858
if(ndim == ULAB_MAX_DIMS) {
859-
mp_raise_ValueError(translate("too many dimensions"));
859+
mp_raise_ValueError(MP_ERROR_TEXT("too many dimensions"));
860860
}
861861
shape[ndim] = MP_OBJ_SMALL_INT_VALUE(mp_obj_len_maybe(item));
862862
if(shape[ndim] == 0) {
@@ -1046,13 +1046,13 @@ static mp_bound_slice_t generate_slice(mp_int_t n, mp_obj_t index) {
10461046
_index += n;
10471047
}
10481048
if((_index >= n) || (_index < 0)) {
1049-
mp_raise_msg(&mp_type_IndexError, translate("index is out of bounds"));
1049+
mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("index is out of bounds"));
10501050
}
10511051
slice.start = _index;
10521052
slice.stop = _index + 1;
10531053
slice.step = 1;
10541054
} else {
1055-
mp_raise_msg(&mp_type_IndexError, translate("indices must be integers, slices, or Boolean lists"));
1055+
mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("indices must be integers, slices, or Boolean lists"));
10561056
}
10571057
return slice;
10581058
}
@@ -1078,7 +1078,7 @@ static ndarray_obj_t *ndarray_view_from_slices(ndarray_obj_t *ndarray, mp_obj_tu
10781078
k += ndarray->shape[ULAB_MAX_DIMS - ndarray->ndim + i];
10791079
}
10801080
if((k >= (int32_t)ndarray->shape[ULAB_MAX_DIMS - ndarray->ndim + i]) || (k < 0)) {
1081-
mp_raise_msg(&mp_type_IndexError, translate("index is out of bounds"));
1081+
mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("index is out of bounds"));
10821082
}
10831083
offset += ndarray->strides[ULAB_MAX_DIMS - ndarray->ndim + i] * k;
10841084
// ... and then we have to shift the shapes to the right
@@ -1105,7 +1105,7 @@ void ndarray_assign_view(ndarray_obj_t *view, ndarray_obj_t *values) {
11051105
int32_t *lstrides = m_new0(int32_t, ULAB_MAX_DIMS);
11061106
int32_t *rstrides = m_new0(int32_t, ULAB_MAX_DIMS);
11071107
if(!ndarray_can_broadcast(view, values, &ndim, shape, lstrides, rstrides)) {
1108-
mp_raise_ValueError(translate("operands could not be broadcast together"));
1108+
mp_raise_ValueError(MP_ERROR_TEXT("operands could not be broadcast together"));
11091109
} else {
11101110

11111111
ndarray_obj_t *ndarray = ndarray_copy_view_convert_type(values, view->dtype);
@@ -1171,7 +1171,7 @@ void ndarray_assign_view(ndarray_obj_t *view, ndarray_obj_t *values) {
11711171
static mp_obj_t ndarray_from_boolean_index(ndarray_obj_t *ndarray, ndarray_obj_t *index) {
11721172
// returns a 1D array, indexed by a Boolean array
11731173
if(ndarray->len != index->len) {
1174-
mp_raise_ValueError(translate("array and index length must be equal"));
1174+
mp_raise_ValueError(MP_ERROR_TEXT("array and index length must be equal"));
11751175
}
11761176
uint8_t *iarray = (uint8_t *)index->array;
11771177
// first we have to find out how many trues there are
@@ -1223,7 +1223,7 @@ static mp_obj_t ndarray_assign_from_boolean_index(ndarray_obj_t *ndarray, ndarra
12231223
#if ULAB_SUPPORTS_COMPLEX
12241224
if(values->dtype == NDARRAY_COMPLEX) {
12251225
if(ndarray->dtype != NDARRAY_COMPLEX) {
1226-
mp_raise_TypeError(translate("cannot convert complex to dtype"));
1226+
mp_raise_TypeError(MP_ERROR_TEXT("cannot convert complex to dtype"));
12271227
} else {
12281228
uint8_t *array = (uint8_t *)ndarray->array;
12291229
for(size_t i = 0; i < ndarray->len; i++) {
@@ -1314,7 +1314,7 @@ static mp_obj_t ndarray_get_slice(ndarray_obj_t *ndarray, mp_obj_t index, ndarra
13141314
if(mp_obj_is_type(index, &ulab_ndarray_type)) {
13151315
ndarray_obj_t *nindex = MP_OBJ_TO_PTR(index);
13161316
if((nindex->ndim > 1) || (nindex->boolean == false)) {
1317-
mp_raise_NotImplementedError(translate("operation is implemented for 1D Boolean arrays only"));
1317+
mp_raise_NotImplementedError(MP_ERROR_TEXT("operation is implemented for 1D Boolean arrays only"));
13181318
}
13191319
if(values == NULL) { // return value(s)
13201320
return ndarray_from_boolean_index(ndarray, nindex);
@@ -1327,7 +1327,7 @@ static mp_obj_t ndarray_get_slice(ndarray_obj_t *ndarray, mp_obj_t index, ndarra
13271327
if(mp_obj_is_type(index, &mp_type_tuple)) {
13281328
tuple = MP_OBJ_TO_PTR(index);
13291329
if(tuple->len > ndarray->ndim) {
1330-
mp_raise_msg(&mp_type_IndexError, translate("too many indices"));
1330+
mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("too many indices"));
13311331
}
13321332
} else {
13331333
mp_obj_t *items = m_new(mp_obj_t, 1);
@@ -1351,7 +1351,7 @@ static mp_obj_t ndarray_get_slice(ndarray_obj_t *ndarray, mp_obj_t index, ndarra
13511351

13521352
mp_obj_t ndarray_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
13531353
if(value == MP_OBJ_NULL) {
1354-
mp_raise_ValueError(translate("cannot delete array elements"));
1354+
mp_raise_ValueError(MP_ERROR_TEXT("cannot delete array elements"));
13551355
}
13561356
ndarray_obj_t *self = MP_OBJ_TO_PTR(self_in);
13571357

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

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

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

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

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

20422042
if(unknown_dim > 1) {
2043-
mp_raise_ValueError(translate("can only specify one unknown dimension"));
2043+
mp_raise_ValueError(MP_ERROR_TEXT("can only specify one unknown dimension"));
20442044
} else if(unknown_dim == 1) {
20452045
new_shape[unknown_index] = source->len / new_length;
20462046
new_length = source->len;
20472047
}
20482048

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

20532053
ndarray_obj_t *ndarray;
@@ -2064,7 +2064,7 @@ mp_obj_t ndarray_reshape_core(mp_obj_t oin, mp_obj_t _shape, bool inplace) {
20642064
}
20652065
} else {
20662066
if(inplace) {
2067-
mp_raise_ValueError(translate("cannot assign new shape"));
2067+
mp_raise_ValueError(MP_ERROR_TEXT("cannot assign new shape"));
20682068
}
20692069
if(mp_obj_is_type(_shape, &mp_type_tuple)) {
20702070
ndarray = ndarray_new_ndarray_from_tuple(shape, source->dtype);
@@ -2087,7 +2087,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(ndarray_reshape_obj, ndarray_reshape);
20872087
#if ULAB_NUMPY_HAS_NDINFO
20882088
mp_obj_t ndarray_info(mp_obj_t obj_in) {
20892089
if(!mp_obj_is_type(obj_in, &ulab_ndarray_type)) {
2090-
mp_raise_TypeError(translate("function is defined for ndarrays only"));
2090+
mp_raise_TypeError(MP_ERROR_TEXT("function is defined for ndarrays only"));
20912091
}
20922092
ndarray_obj_t *ndarray = MP_OBJ_TO_PTR(obj_in);
20932093
mp_printf(MP_PYTHON_PRINTER, "class: ndarray\n");

code/ndarray.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ typedef struct _mp_obj_slice_t {
111111
#endif
112112
#endif
113113

114-
#if !CIRCUITPY
115-
#define translate(x) MP_ERROR_TEXT(x)
116-
#endif
117-
118114
#define ndarray_set_value(a, b, c, d) mp_binary_set_val_array(a, b, c, d)
119115
void ndarray_set_complex_value(void *, size_t , mp_obj_t );
120116

code/ndarray_operators.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ mp_obj_t ndarray_binary_power(ndarray_obj_t *lhs, ndarray_obj_t *rhs,
861861
mp_obj_t ndarray_inplace_ams(ndarray_obj_t *lhs, ndarray_obj_t *rhs, int32_t *rstrides, uint8_t optype) {
862862

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

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

916916
if((lhs->dtype != NDARRAY_FLOAT)) {
917-
mp_raise_TypeError(translate("results cannot be cast to specified type"));
917+
mp_raise_TypeError(MP_ERROR_TEXT("results cannot be cast to specified type"));
918918
}
919919
uint8_t *larray = (uint8_t *)lhs->array;
920920
uint8_t *rarray = (uint8_t *)rhs->array;

code/numpy/approx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ STATIC mp_obj_t approx_interp(size_t n_args, const mp_obj_t *pos_args, mp_map_t
6565
COMPLEX_DTYPE_NOT_IMPLEMENTED(xp->dtype)
6666
COMPLEX_DTYPE_NOT_IMPLEMENTED(fp->dtype)
6767
if((xp->ndim != 1) || (fp->ndim != 1) || (xp->len < 2) || (fp->len < 2) || (xp->len != fp->len)) {
68-
mp_raise_ValueError(translate("interp is defined for 1D iterables of equal length"));
68+
mp_raise_ValueError(MP_ERROR_TEXT("interp is defined for 1D iterables of equal length"));
6969
}
7070

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

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

187187
mp_float_t (*funcx)(void *) = ndarray_get_float_function(x->dtype);

code/numpy/bitwise.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ mp_obj_t *bitwise_binary_operators(mp_obj_t x1, mp_obj_t x2, uint8_t optype) {
331331

332332
#if ULAB_SUPPORTS_COMPLEX
333333
if((lhs->dtype == NDARRAY_FLOAT) || (rhs->dtype == NDARRAY_FLOAT) || (lhs->dtype == NDARRAY_COMPLEX) || (rhs->dtype == NDARRAY_COMPLEX)) {
334-
mp_raise_ValueError(translate("not supported for input types"));
334+
mp_raise_ValueError(MP_ERROR_TEXT("not supported for input types"));
335335
}
336336
#else
337337
if((lhs->dtype == NDARRAY_FLOAT) || (rhs->dtype == NDARRAY_FLOAT)) {
338-
mp_raise_ValueError(translate("not supported for input types"));
338+
mp_raise_ValueError(MP_ERROR_TEXT("not supported for input types"));
339339
}
340340
#endif
341341

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

354354
ndarray_obj_t *results = NULL;

code/numpy/carray/carray.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mp_obj_t carray_real(mp_obj_t _source) {
4747
return MP_OBJ_FROM_PTR(target);
4848
}
4949
} else {
50-
mp_raise_NotImplementedError(translate("function is implemented for ndarrays only"));
50+
mp_raise_NotImplementedError(MP_ERROR_TEXT("function is implemented for ndarrays only"));
5151
}
5252
return mp_const_none;
5353
}
@@ -73,7 +73,7 @@ mp_obj_t carray_imag(mp_obj_t _source) {
7373
return MP_OBJ_FROM_PTR(target);
7474
}
7575
} else {
76-
mp_raise_NotImplementedError(translate("function is implemented for ndarrays only"));
76+
mp_raise_NotImplementedError(MP_ERROR_TEXT("function is implemented for ndarrays only"));
7777
}
7878
return mp_const_none;
7979
}
@@ -111,7 +111,7 @@ mp_obj_t carray_conjugate(mp_obj_t _source) {
111111
} else if(mp_obj_is_int(_source) || mp_obj_is_float(_source)) {
112112
return _source;
113113
} else {
114-
mp_raise_TypeError(translate("input must be an ndarray, or a scalar"));
114+
mp_raise_TypeError(MP_ERROR_TEXT("input must be an ndarray, or a scalar"));
115115
}
116116
}
117117
// this should never happen
@@ -183,11 +183,11 @@ static void carray_sort_complex_(mp_float_t *array, size_t len) {
183183

184184
mp_obj_t carray_sort_complex(mp_obj_t _source) {
185185
if(!mp_obj_is_type(_source, &ulab_ndarray_type)) {
186-
mp_raise_TypeError(translate("input must be a 1D ndarray"));
186+
mp_raise_TypeError(MP_ERROR_TEXT("input must be a 1D ndarray"));
187187
}
188188
ndarray_obj_t *source = MP_OBJ_TO_PTR(_source);
189189
if(source->ndim != 1) {
190-
mp_raise_TypeError(translate("input must be a 1D ndarray"));
190+
mp_raise_TypeError(MP_ERROR_TEXT("input must be a 1D ndarray"));
191191
}
192192

193193
ndarray_obj_t *ndarray = ndarray_copy_view_convert_type(source, NDARRAY_COMPLEX);

code/numpy/carray/carray_tools.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#if ULAB_SUPPORTS_COMPLEX
2323

2424
void raise_complex_NotImplementedError(void) {
25-
mp_raise_NotImplementedError(translate("not implemented for complex dtype"));
25+
mp_raise_NotImplementedError(MP_ERROR_TEXT("not implemented for complex dtype"));
2626
}
2727

2828
#endif

code/numpy/compare.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static mp_obj_t compare_function(mp_obj_t x1, mp_obj_t x2, uint8_t op) {
3636
int32_t *lstrides = m_new(int32_t, ULAB_MAX_DIMS);
3737
int32_t *rstrides = m_new(int32_t, ULAB_MAX_DIMS);
3838
if(!ndarray_can_broadcast(lhs, rhs, &ndim, shape, lstrides, rstrides)) {
39-
mp_raise_ValueError(translate("operands could not be broadcast together"));
39+
mp_raise_ValueError(MP_ERROR_TEXT("operands could not be broadcast together"));
4040
m_del(size_t, shape, ULAB_MAX_DIMS);
4141
m_del(int32_t, lstrides, ULAB_MAX_DIMS);
4242
m_del(int32_t, rstrides, ULAB_MAX_DIMS);
@@ -263,7 +263,7 @@ static mp_obj_t compare_isinf_isfinite(mp_obj_t _x, uint8_t mask) {
263263

264264
return MP_OBJ_FROM_PTR(results);
265265
} else {
266-
mp_raise_TypeError(translate("wrong input type"));
266+
mp_raise_TypeError(MP_ERROR_TEXT("wrong input type"));
267267
}
268268
return mp_const_none;
269269
}
@@ -470,7 +470,7 @@ mp_obj_t compare_where(mp_obj_t _condition, mp_obj_t _x, mp_obj_t _y) {
470470
if(!ndarray_can_broadcast(c, x, &ndim, oshape, cstrides, ystrides) ||
471471
!ndarray_can_broadcast(c, y, &ndim, oshape, cstrides, ystrides) ||
472472
!ndarray_can_broadcast(x, y, &ndim, oshape, xstrides, ystrides)) {
473-
mp_raise_ValueError(translate("operands could not be broadcast together"));
473+
mp_raise_ValueError(MP_ERROR_TEXT("operands could not be broadcast together"));
474474
}
475475

476476
ndim = MAX(MAX(c->ndim, x->ndim), y->ndim);

0 commit comments

Comments
 (0)