Streamlit Web Application
The streamlit_app module contains the Streamlit-based web interface.
Main Application
Streamlit Application for RegressionLab Web-based interface for curve fitting operations.
Theme Configuration
Streamlit UI theme from config (same rules as tkinter app).
Uses config.theme.UI_STYLE when available (env + theme.py). Converts color names to hex for CSS via matplotlib. Fallback to config.env only if theme cannot be imported (e.g. headless without tkinter).
Application Sections
The streamlit_app.sections subpackage contains UI sections organized by functionality.
Main Sections Package
Streamlit app sections: sidebar, data, fitting, results, help, modes.
Data Section
Data loading and display for the Streamlit app.
- streamlit_app.sections.data.load_uploaded_file(uploaded_file)[source]
Load data from an uploaded file (CSV, XLSX, or TXT).
- Parameters:
uploaded_file – Streamlit UploadedFile object (e.g. from st.file_uploader).
- Returns:
DataFrame with loaded data, or None if loading fails.
- streamlit_app.sections.data.show_data_with_pair_plots(data, *, key_prefix=None, file_id=None)[source]
Show data in an expander with optional pair plots and data analysis (transform/clean/save).
- Parameters:
data – DataFrame or data to display.
key_prefix – If set (e.g. ‘view_data’), enables transform/clean/save and uses session state for the current data. Required for analysis features.
file_id – When key_prefix is set, used to detect file changes. When file_id changes, the displayed data is reset to the new loaded data.
Fitting Section
Fitting logic and equation selection UI for the Streamlit app.
- streamlit_app.sections.fitting.perform_fit(data, x_name, y_name, equation_name, plot_name, custom_formula=None, parameter_names=None, show_title=None)[source]
Perform curve fitting for the given dataset and equation selection.
This helper wraps the core fitting logic used by the Streamlit UI: it resolves either a predefined fitting function or a custom
CustomFunctionEvaluator, computes the fit and generates the corresponding plot.- Parameters:
data – Dataset with columns
x_name,y_nameand optionally their uncertaintiesu{x_name},u{y_name}.x_name – Name of the independent variable column.
y_name – Name of the dependent variable column.
equation_name – Internal equation identifier or
'custom_formula'.plot_name – Base name used for the generated plot.
custom_formula – Custom formula string when
equation_nameis'custom_formula'.parameter_names – List of parameter names used in
custom_formula.show_title – If set, override plot title visibility (from env) for this fit.
Noneuses the value fromPLOT_SHOW_TITLE.
- Returns:
Dictionary with keys
equation_name,parameters,equation,plot_pathandplot_namewhen the fit succeeds, orNoneif the operation fails or is not supported.
- streamlit_app.sections.fitting.select_variables(data, key_prefix='')[source]
Show variable selection widgets and return the chosen variables and plot name.
- Parameters:
data – Dataset from which variables are extracted.
key_prefix – Optional prefix for Streamlit widget keys to avoid clashes.
- Returns:
Tuple
(x_name, y_name, plot_name)selected by the user.
- streamlit_app.sections.fitting.show_equation_selector(equation_types)[source]
Show equation type selector in the sidebar/content area.
- Parameters:
equation_types – List of available equation identifiers.
- Returns:
Tuple
(equation_key, custom_formula, parameter_names)wherecustom_formulaandparameter_namesare only populated when the custom‑formula option is selected.
Results Section
Results display for the Streamlit app.
Help Section
Help and information section for the Streamlit app.
Modes Section
Operation modes: normal, multiple datasets, checker, total fitting, view data.
- streamlit_app.sections.modes.mode_view_data(_equation_types)[source]
Handle view-data mode: load file and show data without fitting (like Tkinter ‘Mirar datos’).
- streamlit_app.sections.modes.mode_normal_fitting(equation_types)[source]
Handle normal fitting mode (single file, single equation), with optional loop mode.
- streamlit_app.sections.modes.mode_multiple_datasets(equation_types)[source]
Handle multiple datasets mode (multiple files, single equation), with loop hint.