Skip to content

Unweighted fitter.fit(x, y) always crashes — weights are de facto mandatory #264

Open

Description

@rozyczko

Finding F-H8 in DEEP_ANALYSIS.md (parent #261).

Fitter.fit declares weights: Optional[np.ndarray] = None (fitter.py:276-278) and _precompute_reshaping passes None straight through. All three minimizers then do:

x, y, weights = np.asarray(x), np.asarray(y), np.asarray(weights)
if weights.shape != x.shape:
    raise ValueError('Weights must have the same shape as x and y.')

np.asarray(None) is a 0-d object array, so the documented default call fitter.fit(x, y) always dies with a misleading shape error. Identical block in minimizer_lmfit.py:144-150, minimizer_bumps.py:148-160, minimizer_dfo.py:133-145.

Fix: default to np.ones_like(y) (or stop advertising Optional in three signatures + docstrings). Hoisting the triplicated validation into MinimizerBase is tracked separately.

Activity

  1. added
    [scope] bug
    [area] fitting
    [priority] highest
    on Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [area] fitting[priority] highest[scope] bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions