fix: allow OptimizationConfig.seed=0 - #359
Closed
HarshRajSinghania wants to merge 1 commit into
Closed
HarshRajSinghania wants to merge 1 commit into
HarshRajSinghania wants to merge 1 commit into
Conversation
Use NonNegativeInt so seed=0 is accepted, matching Pipeline(seed=0). Negative seeds remain invalid. Fixes deeppavlov#352
Collaborator
|
duplicate of #358 |
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.
Summary
OptimizationConfig.seedwas typed asPositiveInt, soseed=0raised a validation error.Pipeline(seed=0)andPipeline.from_search_space(..., seed=0)already accept 0 (int | None).Pipeline.from_presetandPipeline.from_optimization_configfailed because they construct anOptimizationConfig.Motivation
Fixes #352.
Zero is a valid RNG seed and is the first value of a typical seed grid. Rejecting it forced workarounds such as setting
pipeline._seed = 0after construction.Implementation
OptimizationConfig.seedfromPositiveInttoNonNegativeInt(still default42).Testing
Added in
tests/configs/test_full_config.py:test_optimization_config_accepts_seed_zerotest_optimization_config_rejects_negative_seedLocally verified Pydantic
NonNegativeIntaccepts0and rejects-1.The full AutoIntent test suite was not run here (heavy optional deps). The new tests follow the existing config-validation style and should pass with the project's usual
pytest tests/configs/test_full_config.py.