Skip to content

feat: ✨ spectrafit new-config should emit v2 TOML (not v1 JSON) #2095

@Anselmoo

Description

@Anselmoo

Problem

spectrafit new-config -m voigt -n 3 was emitting banned v1 JSON format:

{"fitting": {"peaks": {"1": {...}}}}

The v1 format is hard-rejected by UnifiedFittingConfig since Phase 10.

Solution (implemented in commit 2d6fa967 + be12c14a)

  • _PARAM_DEFAULTS: dict[str, dict]dict[str, FitParameter]
  • _build_component() returns Component (Pydantic model, not raw dict)
  • _build_config() emits v2 format: {"components": [...], "minimizer": {...}}
  • Default output format changed from JSON to TOML
  • Removed dead try/except ImportError for tomli_w (it is a hard dep)
  • spectrafit init now writes spectrafit.toml project meta file

Verification

uv run spectrafit new-config -m voigt -n 3
# → produces valid [[components]] TOML accepted by UnifiedFittingConfig

Tests: 36 golden-table assertions in tests/unit/test_new_config.py, v2 format check in tests/unit/test_init_command.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestv2.0.0wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions