@@ -41,7 +41,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
41
41
MP_QSTR_generator ,
42
42
MP_TYPE_FLAG_NONE ,
43
43
print , random_generator_print ,
44
- make_new , random_generator_make_new ,
44
+ make_new , random_generator_make_new ,
45
45
locals_dict , & random_generator_locals_dict
46
46
);
47
47
#else
@@ -76,11 +76,12 @@ mp_obj_t random_generator_make_new(const mp_obj_type_t *type, size_t n_args, siz
76
76
if (args [0 ] == mp_const_none ) {
77
77
#ifndef MICROPY_PY_RANDOM_SEED_INIT_FUNC
78
78
mp_raise_ValueError (MP_ERROR_TEXT ("no default seed" ));
79
- #endif
79
+ #else
80
80
random_generator_obj_t * generator = m_new_obj (random_generator_obj_t );
81
81
generator -> base .type = & random_generator_type ;
82
82
generator -> state = MICROPY_PY_RANDOM_SEED_INIT_FUNC ;
83
83
return MP_OBJ_FROM_PTR (generator );
84
+ #endif
84
85
} else if (mp_obj_is_int (args [0 ])) {
85
86
random_generator_obj_t * generator = m_new_obj (random_generator_obj_t );
86
87
generator -> base .type = & random_generator_type ;
@@ -89,7 +90,7 @@ mp_obj_t random_generator_make_new(const mp_obj_type_t *type, size_t n_args, siz
89
90
} else if (mp_obj_is_type (args [0 ], & mp_type_tuple )){
90
91
mp_obj_tuple_t * seeds = MP_OBJ_TO_PTR (args [0 ]);
91
92
mp_obj_t * items = m_new (mp_obj_t , seeds -> len );
92
-
93
+
93
94
for (uint8_t i = 0 ; i < seeds -> len ; i ++ ) {
94
95
random_generator_obj_t * generator = m_new_obj (random_generator_obj_t );
95
96
generator -> base .type = & random_generator_type ;
@@ -175,7 +176,7 @@ static mp_obj_t random_normal(size_t n_args, const mp_obj_t *pos_args, mp_map_t
175
176
176
177
mp_float_t * array = (mp_float_t * )ndarray -> array ;
177
178
178
- // numpy's random supports only dense output arrays, so we can simply
179
+ // numpy's random supports only dense output arrays, so we can simply
179
180
// loop through the elements in a linear fashion
180
181
for (size_t i = 0 ; i < ndarray -> len ; i = i + 2 ) {
181
182
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
@@ -248,7 +249,7 @@ static mp_obj_t random_random(size_t n_args, const mp_obj_t *pos_args, mp_map_t
248
249
if (!mp_obj_is_type (out , & ulab_ndarray_type )) {
249
250
mp_raise_TypeError (MP_ERROR_TEXT ("out has wrong type" ));
250
251
}
251
-
252
+
252
253
ndarray = MP_OBJ_TO_PTR (out );
253
254
254
255
if (ndarray -> dtype != NDARRAY_FLOAT ) {
@@ -283,10 +284,10 @@ static mp_obj_t random_random(size_t n_args, const mp_obj_t *pos_args, mp_map_t
283
284
284
285
mp_float_t * array = (mp_float_t * )ndarray -> array ;
285
286
286
- // numpy's random supports only dense output arrays, so we can simply
287
+ // numpy's random supports only dense output arrays, so we can simply
287
288
// loop through the elements in a linear fashion
288
289
for (size_t i = 0 ; i < ndarray -> len ; i ++ ) {
289
-
290
+
290
291
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
291
292
uint32_t x = pcg32_next (& self -> state );
292
293
* array = (float )(int32_t )(x >> 8 ) * 0x1.0p-24f ;
@@ -375,4 +376,3 @@ const mp_obj_module_t ulab_numpy_random_module = {
375
376
.base = { & mp_type_module },
376
377
.globals = (mp_obj_dict_t * )& mp_module_ulab_numpy_random_globals ,
377
378
};
378
-
0 commit comments