fix keyword typo
This commit is contained in:
parent
261e606fc7
commit
b04905e959
1 changed files with 8 additions and 8 deletions
|
|
@ -1912,7 +1912,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(ndarray_transpose_obj, ndarray_transpose);
|
||||||
mp_obj_t ndarray_transpose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
mp_obj_t ndarray_transpose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||||
static const mp_arg_t allowed_args[] = {
|
static const mp_arg_t allowed_args[] = {
|
||||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE } },
|
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE } },
|
||||||
{ MP_QSTR_axis, MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE } },
|
{ MP_QSTR_axes, MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE } },
|
||||||
};
|
};
|
||||||
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
|
|
@ -1928,15 +1928,15 @@ mp_obj_t ndarray_transpose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw
|
||||||
int32_t *strides = m_new(int32_t, self->ndim);
|
int32_t *strides = m_new(int32_t, self->ndim);
|
||||||
uint8_t *order = m_new(uint8_t, self->ndim);
|
uint8_t *order = m_new(uint8_t, self->ndim);
|
||||||
|
|
||||||
mp_obj_t axis = args[1].u_obj;
|
mp_obj_t axes = args[1].u_obj;
|
||||||
|
|
||||||
if(axis == mp_const_none) {
|
if(axes == mp_const_none) {
|
||||||
// simply swap the order of the axes
|
// simply swap the order of the axes
|
||||||
for(uint8_t i = 0; i < self->ndim; i++) {
|
for(uint8_t i = 0; i < self->ndim; i++) {
|
||||||
order[i] = self->ndim - 1 - i;
|
order[i] = self->ndim - 1 - i;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!mp_obj_is_type(axis, &mp_type_tuple)) {
|
if(!mp_obj_is_type(axes, &mp_type_tuple)) {
|
||||||
mp_raise_TypeError(MP_ERROR_TEXT("keyword argument must be tuple of integers"));
|
mp_raise_TypeError(MP_ERROR_TEXT("keyword argument must be tuple of integers"));
|
||||||
}
|
}
|
||||||
// start with the straight array, and then swap only those specified in the argument
|
// start with the straight array, and then swap only those specified in the argument
|
||||||
|
|
@ -1944,14 +1944,14 @@ mp_obj_t ndarray_transpose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw
|
||||||
order[i] = i;
|
order[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_tuple_t *axes = MP_OBJ_TO_PTR(axis);
|
mp_obj_tuple_t *axes_tuple = MP_OBJ_TO_PTR(axes);
|
||||||
|
|
||||||
if(axes->len > self->ndim) {
|
if(axes_tuple->len > self->ndim) {
|
||||||
mp_raise_ValueError(MP_ERROR_TEXT("too many axes specified"));
|
mp_raise_ValueError(MP_ERROR_TEXT("too many axes specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint8_t i = 0; i < axes->len; i++) {
|
for(uint8_t i = 0; i < axes_tuple->len; i++) {
|
||||||
int32_t ax = mp_obj_get_int(axes->items[i]);
|
int32_t ax = mp_obj_get_int(axes_tuple->items[i]);
|
||||||
if((ax >= self->ndim) || (ax < 0)) {
|
if((ax >= self->ndim) || (ax < 0)) {
|
||||||
mp_raise_ValueError(MP_ERROR_TEXT("axis index out of bounds"));
|
mp_raise_ValueError(MP_ERROR_TEXT("axis index out of bounds"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue