Repository navigation
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #563
Problem
SklearnBaseLSS._configure_distribution(..., allow_change=False)checked that a continuation fit keeps the family options withoptions != self.distributional_kwargs_. With a NumPy array value, e.g.distributional_kwargs={"quantiles": np.linspace(...)}, the dict comparison compares the arrays element-wise and raisesValueError: The truth value of an array ... is ambiguous. As a result, everyfit(rebuild=False)failed afterbuild_model(), after a previous fit, and afterload().Fix
deeptab/models/lss_base.pyadds a small_same_family_options(options, stored)helper. It compares keys, usesnp.array_equalwhen 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, thenfit(rebuild=False), once with the stored options and once with the same values passed as a list.test_reused_build_rejects_different_numpy_array_optionsAll three fail on
mainand 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)