@@ -31,9 +31,9 @@ static mp_obj_t elasticnet_model_new(size_t n_args, const mp_obj_t *args) {
3131 }
3232
3333 mp_int_t n_features = mp_obj_get_int (args [0 ]);
34- float alpha = mp_obj_get_float (args [1 ]);
35- float l1_ratio = mp_obj_get_float (args [2 ]);
36- float learning_rate = mp_obj_get_float (args [3 ]);
34+ float alpha = mp_obj_get_float_to_f (args [1 ]);
35+ float l1_ratio = mp_obj_get_float_to_f (args [2 ]);
36+ float learning_rate = mp_obj_get_float_to_f (args [3 ]);
3737
3838 // Allocate space
3939 mp_obj_elasticnet_model_t * o = \
@@ -142,7 +142,7 @@ static mp_obj_t elasticnet_model_predict(mp_obj_fun_bc_t *self_obj,
142142 // Make prediction
143143 float prediction = predict_sample (self , features );
144144
145- return ( mp_obj_t ) mp_obj_new_float (prediction );
145+ return mp_obj_new_float_from_f (prediction );
146146}
147147
148148// Get model weights
@@ -185,7 +185,7 @@ static mp_obj_t elasticnet_model_get_bias(mp_obj_t self_obj) {
185185 mp_obj_elasticnet_model_t * o = MP_OBJ_TO_PTR (self_obj );
186186 elastic_net_model_t * self = & o -> model ;
187187
188- return ( mp_obj_t ) mp_obj_new_float (self -> bias );
188+ return mp_obj_new_float_from_f (self -> bias );
189189}
190190// Define a Python reference to the function above
191191static MP_DEFINE_CONST_FUN_OBJ_1 (elasticnet_model_get_bias_obj , elasticnet_model_get_bias ) ;
@@ -226,7 +226,7 @@ static mp_obj_t elasticnet_model_score_mse(size_t n_args, const mp_obj_t *args)
226226 const uint16_t n_samples = y_len ;
227227 float mse = elastic_net_mse (self , X , y , n_samples );
228228
229- return mp_obj_new_float (mse );
229+ return mp_obj_new_float_from_f (mse );
230230}
231231static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (elasticnet_model_score_mse_obj , 3 , 3 , elasticnet_model_score_mse ) ;
232232
0 commit comments