Skip to content

v0.4.2

Choose a tag to compare

@imewei imewei released this 30 Dec 09:10
· 554 commits to main since this release

Highlights

Interactive Streamlit GUI

  • nlsq gui CLI command: Launch interactive curve fitting interface
    • Data import from CSV, Excel, JSON, and HDF5 files
    • Built-in model library with 15+ common functions
    • Custom model definition with JAX/NumPy syntax
    • Real-time parameter adjustment with sliders
    • Interactive visualization with residual plots
    • Export fitted parameters and covariance matrix

Package Restructure (v0.4.2 Architecture)

  • Subpackage organization: Logical grouping of modules

    nlsq/
    ├── core/           # Core optimization (minpack, least_squares, trf)
    ├── interfaces/     # Protocol definitions for dependency injection
    ├── streaming/      # Large dataset handling
    ├── caching/        # Performance optimization (memory pool, smart cache)
    ├── stability/      # Numerical stability (guard, SVD fallback)
    ├── precision/      # Precision controls (mixed precision, normalizer)
    └── utils/          # Utilities (validators, diagnostics, logging)
    
  • Protocol interfaces package (nlsq/interfaces/): Dependency injection support

    • CacheProtocol, BoundedCacheProtocol: Cache implementations
    • OptimizerProtocol, LeastSquaresOptimizerProtocol: Optimizer interfaces
    • DataSourceProtocol: Data source abstraction
    • JacobianProtocol: Jacobian computation interface
    • ResultProtocol: Optimization result containers

Performance Optimizations

  • Lazy imports (43% faster import): Specialty modules loaded on first access
    • Import time reduced from ~1084ms to ~620ms
  • Vectorized sparse Jacobian (37-50x speedup): O(nnz) NumPy operations
    • Handles 100k×50 matrices in <150ms

Code Modernization

  • Python 3.12+ type hints: Updated Union → |, Optional[X] → X | None
  • Dataclass __slots__: Added slots=True to dataclasses for memory efficiency

Test Results

  • Tests: 2,904+ passing (100% success rate)
  • Coverage: ~82% (exceeds 80% target)
  • Platforms: Ubuntu ✅ | macOS ✅ | Windows ✅

Backward Compatibility

  • 100% API backward compatible
  • All public imports preserved via __init__.py re-exports
  • Old import paths work via module aliases

Installation

pip install nlsq==0.4.2

# With GUI support
pip install nlsq[gui]==0.4.2

# With all optional dependencies
pip install nlsq[all]==0.4.2

See CHANGELOG.md for full details.