fix(timesfm2_5): correct method name in window_size moving average call
Summary
Fixes #46821
When calling TimesFm2_5ModelForPrediction with a window_size parameter, an AttributeError is raised because the forward method calls self._timesfm_moving_average() but the actual @staticmethod is named _timesfm2_5_moving_average().
Root Cause
The method was likely renamed during the TimesFM 2.5 integration (from the original timesfm naming to timesfm2_5 for namespace consistency), but the call site in forward() was not updated to match.
Fix
Changed self._timesfm_moving_average(ts, window_size) to self._timesfm2_5_moving_average(ts, window_size) in both:
modeling_timesfm2_5.py(line 780)modular_timesfm2_5.py(line 567)
Testing
The fix resolves the AttributeError reported in the issue. The moving average logic itself is unchanged — only the method name reference was corrected.
CI Dashboard: View test results in Grafana
cc @kashif I think!
on it!
Great catch on the call-site fix! One thing to flag: the modular file change (modular_timesfm2_5.py line 567) now calls self._timesfm2_5_moving_average, but TimesFm2_5ModelForPrediction in the modular file inherits from TimesFmModelForPrediction, which only defines _timesfm_moving_average (not _timesfm2_5_moving_average). This means:
make fix-repo(which regeneratesmodeling_timesfm2_5.pyfrom the modular file) may regenerate the generated file without the method, or fail the modular-conversion consistency check.- Python itself would raise
AttributeError: 'TimesFm2_5ModelForPrediction' object has no attribute '_timesfm2_5_moving_average'if someone runs the modular file path directly.
The complete fix also needs a _timesfm2_5_moving_average static method defined in the TimesFm2_5ModelForPrediction class in modular_timesfm2_5.py (same implementation as the parent's _timesfm_moving_average), so the code generator has a definition to copy. Running python utils/check_modular_conversion.py --fix after adding the static method confirms the generated file stays consistent.
Drafted-by: Claude Code (Sonnet 4.6) (no human review before posting)
@Sriniketh24 @Rocketknight1 Thanks for the review! I have added the _timesfm2_5_moving_average staticmethod to modular_timesfm2_5.py as well, so make fix-repo will work correctly going forward. The method is identical to what is in the generated file.
[For maintainers] Suggested jobs to run (before merge)
run-slow: timesfm2_5