Advanced User Guide

This guide is for developers and scientists who need to leverage the full power of NLSQ: custom optimization pipelines, protocol-based design, orchestration components, and library extension.

Advanced Tutorials

Design custom workflows using NLSQ’s API layer.

Advanced User Tutorials
Architecture

Package structure and optimization pipeline.

Architecture Overview

API Levels

NLSQ provides multiple API levels for different needs:

# High Level: fit() function
from nlsq import fit

popt, pcov = fit(model, x, y, p0=[...])

# Mid Level: CurveFit class
from nlsq import CurveFit

fitter = CurveFit()
popt, pcov = fitter.curve_fit(model, x, y, p0=[...])

# Low Level: LeastSquares class
from nlsq.core.least_squares import LeastSquares

optimizer = LeastSquares()
result = optimizer.least_squares(fun=residuals, x0=p0)

# Orchestration: Decomposed components (v0.6.4)
from nlsq.core.orchestration import DataPreprocessor, OptimizationSelector

preprocessor = DataPreprocessor()
preprocessed = preprocessor.preprocess(f=model, xdata=x, ydata=y)