fix: validate unique model names for models without alias#1079
Open
HummerQAQ wants to merge 3 commits intoNixtla:mainfrom
Open
fix: validate unique model names for models without alias#1079HummerQAQ wants to merge 3 commits intoNixtla:mainfrom
HummerQAQ wants to merge 3 commits intoNixtla:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a validation gap in model name uniqueness checking when using custom models without an explicit alias attribute. Previously, the validation logic had a bug where it used lambda: None as a default value instead of None, and only validated models with an alias attribute. This meant duplicate custom models without aliases would silently merge their outputs into a single column.
Changes:
- Fixed
_validate_model_names()to userepr(model)as fallback whenaliasis not defined, ensuring all models are validated - Corrected the bug in the old code that used
lambda: Noneinstead ofNoneas the default value - Added test coverage with
_NoAliasModelto verify duplicate detection for models without alias
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/statsforecast/core.py | Fixed model name validation to use repr(model) fallback and check uniqueness across all models, not just those with alias |
| tests/test_core.py | Added _NoAliasModel test helper and test case to verify duplicate models without alias are properly rejected |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Issue
This PR fixes a gap in model name validation when using custom models without an explicit
alias.While working on a research project, I defined two simple custom forecasting models (
modelAandmodelB) that do not expose analiasattribute. During experimentation, I accidentally passed duplicated models:However, StatsForecast did not raise an error and instead silently merged both outputs into a single column in the forecast DataFrame. This made it appear as if one model was missing, leading to unnecessary debugging time before identifying the root cause.
What changed
ValueErroris raised during initialization if duplicate model names are detectedWhy this matters
While most users rely on built-in models, StatsForecast’s API allows users to pass arbitrary custom models. In such advanced or experimental scenarios, silent configuration errors might be costly to debug.