Skip to content

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

@rozyczko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [area] fittingUmbrella for fitting related work[priority] highestUrgent. Needs attention ASAP[scope] bugBug report or fix (major.minor.PATCH)
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions