Uniform LUT fitting and C code generation for analytic functions and table data, with GUI and CLI workflows.
The project now includes:
- a Tkinter GUI with fit controls, plotting, history, batch runs, and multilingual labels/tooltips
- a CLI for scripted use
- a split pipeline (
fit compute+render/codegen) so code output can be regenerated without re-running the fit - startup dependency preflight from
requirements.txt - portable runtime storage/config for source and compiled builds
- codegen formatting features (wrapped arrays, array placement options)
- future-ready algorithm scaffolding (current shipped method: uniform LUT)
core/: fitting/evaluation math and shared typesios/: source loading/parsing (tables + analytic expressions)codegen/: C generators, formatting, memory estimatesapp/: GUI, CLI, pipeline, reporting, runtime config/bootstrapbuild/: PyInstaller specs (GUI + CLI)tests/: tests and sample datafitter.py: source-mode dispatcher entry point
Install dependencies:
python -m pip install -r requirements.txtThe app performs a startup preflight check for runtime dependencies and exits early with a clear message if something is missing.
python fitter.py
python -m appExamples using the dispatcher in CLI mode:
python fitter.py tests/test.csv --float --test-count 0
python -m app --func "sin(x) + 0.1*x*x" --xmin -2 --xmax 5python -m app.guipython -m app.cli <path> [flags]
python -m app.cli --func <expr|name> --xmin <x0> --xmax <x1> [flags]python -m app.cli tests/test.csv --linear --float --test-count 0
python -m app.cli tests/test.csv --spline --double --with-slopespython -m app.cli --func sin --xmin -2 --xmax 5
python -m app.cli --func linear --a 0.7 --b 0.1 --xmin -2 --xmax 5
python -m app.cli --func "sin(x) + 0.1*x*x" --xmin -2 --xmax 5
python -m app.cli --func-file expr.txt --xmin -2 --xmax 5Built-in analytic names:
sin,cos,exp,log,linear
python -m app.cli tests/test.csv --out out/fit_report
python -m app.cli tests/test.csv --out out/fit_report.txt- If
--outhas no extension,.txtis appended. - When
--outis set, the report is written to file instead of stdout.
--linear/--spline<path>for table data--func <expr|name>--func-file <path>--xmin <float> --xmax <float>--a <float> --b <float>(forlinear)
--abs-err <float>--sym-err <float>--n-max <int>--xmin-shift
--float(default)--double--int16--int32--with-slopes--test-count <int>--func-name <str>--array-name <str>--q-frac <int>/--x-shift <int>/--y-scale <int>(int modes)
--plot(requiresmatplotlib)--out <path>
- Table and analytic sources
- Interpolation mode near table-source controls
- Parameter section for error limits, auto-relax, and
Optimize xmin - Fitting tabs (
Basic,Advanced,Algorithms) with current uniform LUT controls inBasic - Codegen section with numeric mode, slopes, test count, names, array placement, fixed-point settings
Update Codebehavior:- code/summary are regenerated from cached fit data
- changing codegen parameters auto-updates output without re-running fitting
- Run progress info shown near the progress bar (estimated
N, currentN, best-so-far) - Plot tab with separate X scales for fit/error subplots
- History restore:
- restores config and rendered outputs immediately
- restores fit/plot too for newer history entries with cached fit payloads
The app uses a bundled default config (app/default_config.json) plus an optional user override file.
- storage root:
.fitter_data/in the repo
- storage root:
fitter_data/next to the executable
config.json(user overrides)history.jsonoutputs/(default export directory)
- timing logging on/off (
logging.enabled) - codegen max line length for wrapped arrays
- default array placement
- code preview syntax highlighting toggle
- Variable:
x - Operators:
+ - * / ^(^means power) - Parentheses:
() - Constants:
pi,e - Functions include:
sin,cos,tan,exp,log,sqrt,abs,pow,min,maxasin,acos,atan,floor,ceil,sinh,cosh,tanh
Preferred specs (current):
build/pyinstaller_gui.spec->FitterGUIbuild/pyinstaller_cli.spec->FitterCLI
Example:
pyinstaller build/pyinstaller_gui.spec
pyinstaller build/pyinstaller_cli.specThere is also a legacy build/pyinstaller.spec in the repo.
Useful test commands:
python -m unittest tests.test_pipeline tests.test_ls_fit tests.test_segment_estimator
python -m unittest tests.test_codegen_formatting tests.test_runtime_bootstrap- Current fitting method shipped in the GUI/CLI is uniform LUT.
- The codebase already includes planning documents for future expansion (
Plan.md,BenchmarkSpec.md).