* Properly register submodules of ulab This is related to * https://github.com/adafruit/circuitpython/issues/6066 in which, after the merge of 1.18 into CircuitPython, we lost the ability to import submodules of built-in modules. While reconstructing the changes we had made locally to enable this, I discovered that there was an easier way: simply register the dotted module names via MP_REGISTER_MODULE. * Fix finding processor count when no `python` executable is installed debian likes to install only `python3`, and not `python` (which was, for many decades, python2). This was previously done for `build.sh` but not for `build-cp.sh`. * Only use this submodule feature in CircuitPython .. as it does not work properly in MicroPython. Also, modules to be const. This saves a small amount of RAM * Fix -Werror=undef diagnostic Most CircuitPython ports build with -Werror=undef, so that use of an undefined preprocessor flag is an error. Also, CircuitPython's micropython version is old enough that MICROPY_VERSION is not (ever) defined. Defensively check for this macro being defined, and use the older style of MP_REGISTER_MODULE when it is not. * Fix -Werror=discarded-qualifiers diagnostics Most CircuitPython ports build with -Werror=discarded-qualifiers. This detected a problem where string constants were passed to functions with non-constant parameter types. * bump version number * Use MicroPython-compatible registration of submodules * straggler * Remove spurious casts these were build errors for micropython * Run tests for both nanbox and regular variant during CI
41 lines
1.2 KiB
C
41 lines
1.2 KiB
C
|
|
/*
|
|
* This file is part of the micropython-ulab project,
|
|
*
|
|
* https://github.com/v923z/micropython-ulab
|
|
*
|
|
* The MIT License (MIT)
|
|
*
|
|
* Copyright (c) 2020-2021 Zoltán Vörös
|
|
*
|
|
*/
|
|
|
|
#ifndef _SCIPY_OPTIMIZE_
|
|
#define _SCIPY_OPTIMIZE_
|
|
|
|
#include "../../ulab_tools.h"
|
|
|
|
#ifndef OPTIMIZE_EPSILON
|
|
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
|
|
#define OPTIMIZE_EPSILON MICROPY_FLOAT_CONST(1.2e-7)
|
|
#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
|
|
#define OPTIMIZE_EPSILON MICROPY_FLOAT_CONST(2.3e-16)
|
|
#endif
|
|
#endif
|
|
|
|
#define OPTIMIZE_EPS MICROPY_FLOAT_CONST(1.0e-4)
|
|
#define OPTIMIZE_NONZDELTA MICROPY_FLOAT_CONST(0.05)
|
|
#define OPTIMIZE_ZDELTA MICROPY_FLOAT_CONST(0.00025)
|
|
#define OPTIMIZE_ALPHA MICROPY_FLOAT_CONST(1.0)
|
|
#define OPTIMIZE_BETA MICROPY_FLOAT_CONST(2.0)
|
|
#define OPTIMIZE_GAMMA MICROPY_FLOAT_CONST(0.5)
|
|
#define OPTIMIZE_DELTA MICROPY_FLOAT_CONST(0.5)
|
|
|
|
extern const mp_obj_module_t ulab_scipy_optimize_module;
|
|
|
|
MP_DECLARE_CONST_FUN_OBJ_KW(optimize_bisect_obj);
|
|
MP_DECLARE_CONST_FUN_OBJ_KW(optimize_curve_fit_obj);
|
|
MP_DECLARE_CONST_FUN_OBJ_KW(optimize_fmin_obj);
|
|
MP_DECLARE_CONST_FUN_OBJ_KW(optimize_newton_obj);
|
|
|
|
#endif /* _SCIPY_OPTIMIZE_ */
|