[BUG] Align TimeXer v2 endogenous/exogenous usage with tslib metadata (fixes #2003) #2009
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
This PR makes the TimeXer v2 implementation consistent with the v2 /
tslibdesign by removing the duplicated configuration of endogenous and exogenous variables insideTimeXer._forecast.Instead of re-selecting series using
self.endogenous_vars/self.exogenous_varson top of thetslibmetadata, the model now relies solely on the tensors provided by the data pipeline (history_targetandhistory_cont).This implements option 1 discussed in #2003 ("not overriding or passing twice").
Motivation / Context
In v2, feature configuration is intended to be described by the
metadataproduced byTslibDataModuleand consumed byTslibBaseModel. TimeXer v2 currently has:metadataendogenous_vars/exogenous_varskwargs that are used in_forecastto re-select columns fromhistory_contThis leads to two different places where the endogenous / exogenous split can be defined, which is exactly the concern raised in #2003.
The maintainers confirmed that option 1 is preferred: relying on the metadata / data pipeline only, i.e. not overriding or passing the configuration twice.
What this PR changes
In
pytorch_forecasting/models/timexer/_timexer_v2.py:TimeXer._forecastno longer usesself.endogenous_varsorself.exogenous_varsto re-select columns fromhistory_cont.Instead, the method now follows the v2 convention:
history_targethistory_contConcretely, the previous block:
is replaced by:
The rest of
_forecast(embedding, encoder, head) remains unchanged.API / behaviour notes
endogenous_varsandexogenous_varsarguments are still present inTimeXer.__init__and are stored onself, but they are no longer used in_forecast.TslibDataModule.Tests
On Windows with Python 3.13, I ran:
The failures reported earlier were due to a local Windows permission issue with the default pytest temp directory; pointing
--basetempat a project-local directory resolved that, and the TimeXer tests now run cleanly with the change in place.Notes
_forecastonly.endogenous_vars/exogenous_varskwargs fromTimeXer.__init__, and