Skip to content

fix(models): compare array-valued LSS family options by value - #564

Open
ChrisW09 wants to merge 2 commits into
mainfrom
fix/lss-array-options
Open

ChrisW09 wants to merge 2 commits into
mainfrom
fix/lss-array-options

Conversation

@ChrisW09

@ChrisW09 ChrisW09 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #563

Problem

SklearnBaseLSS._configure_distribution(..., allow_change=False) checked that a continuation fit keeps the family options with options != self.distributional_kwargs_. With a NumPy array value, e.g. distributional_kwargs={"quantiles": np.linspace(...)}, the dict comparison compares the arrays element-wise and raises ValueError: The truth value of an array ... is ambiguous. As a result, every fit(rebuild=False) failed after build_model(), after a previous fit, and after load().

Fix

deeptab/models/lss_base.py adds a small _same_family_options(options, stored) helper. It compares keys, uses np.array_equal when either value is a NumPy array or a torch tensor (tensors are moved to the CPU and converted first), and == otherwise. The continuation check uses it, so unchanged array options are accepted and different ones still raise "Changing the distribution family or options requires rebuild=True".

Tests

In tests/integration/test_lss_base.py:

  • test_reused_build_accepts_array_options[numpy|torch]: build_model() with NumPy or tensor quantiles, then fit(rebuild=False), once with the stored options and once with the same values passed as a list.
  • test_reused_build_rejects_different_numpy_array_options

All three fail on main and pass with this change.

Docs

No change needed.

Checks

  • just test: 3239 passed, 46 skipped, 28 xfailed; coverage 91.28%
  • just docs: build succeeded (warnings treated as errors)
  • just check: all hooks passed (ruff, prettier, pyright)

The continuation check compared family options with options != stored,
which raises for NumPy array values such as quantile levels, so every
fit(rebuild=False) failed once distributional_kwargs held an array.
Compare arrays with np.array_equal; changed options are still rejected.

Fixes #563
distributional_kwargs={"quantiles": torch.tensor([...])} failed the same
way NumPy arrays did when fit(rebuild=False) compared the options.

Refs #563

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] LSS continuation fits crash when family options contain a NumPy array or tensor (e.g. quantiles=np.linspace(...))

1 participant