From 06d378bf25370a318036e502bb8e9394891f88c2 Mon Sep 17 00:00:00 2001 From: Kushagra Srivastav <76401345+Kushagra7777@users.noreply.github.com> Date: Wed, 18 Feb 2026 04:31:41 +0900 Subject: [PATCH 1/5] fix flowstate h=1 crash removed extra squeeze in _predict_batch so flowstate returns 2D arrays for h=1 with single unique_id. --- timecopilot/models/foundation/flowstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/timecopilot/models/foundation/flowstate.py b/timecopilot/models/foundation/flowstate.py index de9d95b..02039c0 100644 --- a/timecopilot/models/foundation/flowstate.py +++ b/timecopilot/models/foundation/flowstate.py @@ -167,7 +167,7 @@ def _predict_batch( batch_first=False, ).prediction_outputs fcst = fcst.squeeze(-1).transpose(-1, -2) # now shape is (batch, h, quantiles) - fcst_mean = fcst[..., supported_quantiles.index(0.5)].squeeze() + fcst_mean = fcst[..., supported_quantiles.index(0.5)] fcst_mean_np = fcst_mean.detach().numpy() fcst_quantiles_np = fcst.detach().numpy() if quantiles is not None else None return fcst_mean_np, fcst_quantiles_np From 80536e433cbae4cdb6657cd35e08936320f47422 Mon Sep 17 00:00:00 2001 From: Kushagra Srivastav <76401345+Kushagra7777@users.noreply.github.com> Date: Wed, 18 Feb 2026 15:05:10 +0900 Subject: [PATCH 2/5] flowstate h=1 test added --- tests/models/foundation/test_flowstate.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/models/foundation/test_flowstate.py diff --git a/tests/models/foundation/test_flowstate.py b/tests/models/foundation/test_flowstate.py new file mode 100644 index 0000000..bff2e47 --- /dev/null +++ b/tests/models/foundation/test_flowstate.py @@ -0,0 +1,26 @@ +import pandas as pd +import numpy as np + +from timecopilot import TimeCopilotForecaster +from timecopilot.models.foundation.flowstate import FlowState + + +def test_flowstate_h1_single_uid(): + # create simple weekly data for one unique_id + ds = pd.date_range("2024-01-01", periods=20, freq="W") + df = pd.DataFrame({ + "unique_id": "u1", + "ds": ds, + "y": np.arange(20) + }) + + tcf = TimeCopilotForecaster(models=[FlowState()]) + + # this used to crash before the fix + fcst = tcf.forecast(df=df, h=1, freq="W") + + # basic checks + assert isinstance(fcst, pd.DataFrame) + assert len(fcst) == 1 + assert "unique_id" in fcst.columns + assert "ds" in fcst.columns From 7c3b1b1d7366dc85ec79e038f4afca3c80b43d82 Mon Sep 17 00:00:00 2001 From: Kushagra Srivastav <76401345+Kushagra7777@users.noreply.github.com> Date: Wed, 18 Feb 2026 15:07:29 +0900 Subject: [PATCH 3/5] lint and style fix --- tests/models/foundation/test_flowstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/models/foundation/test_flowstate.py b/tests/models/foundation/test_flowstate.py index bff2e47..145e06c 100644 --- a/tests/models/foundation/test_flowstate.py +++ b/tests/models/foundation/test_flowstate.py @@ -1,5 +1,5 @@ -import pandas as pd import numpy as np +import pandas as pd from timecopilot import TimeCopilotForecaster from timecopilot.models.foundation.flowstate import FlowState From f5f097be5dd09c5024cefc4f30ef758b282acf3b Mon Sep 17 00:00:00 2001 From: Kushagra Srivastav <76401345+Kushagra7777@users.noreply.github.com> Date: Wed, 18 Feb 2026 15:09:13 +0900 Subject: [PATCH 4/5] more lint and style fix ruff check . ruff format . --- tests/models/foundation/test_flowstate.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/models/foundation/test_flowstate.py b/tests/models/foundation/test_flowstate.py index 145e06c..6e0cfe4 100644 --- a/tests/models/foundation/test_flowstate.py +++ b/tests/models/foundation/test_flowstate.py @@ -8,11 +8,7 @@ def test_flowstate_h1_single_uid(): # create simple weekly data for one unique_id ds = pd.date_range("2024-01-01", periods=20, freq="W") - df = pd.DataFrame({ - "unique_id": "u1", - "ds": ds, - "y": np.arange(20) - }) + df = pd.DataFrame({"unique_id": "u1", "ds": ds, "y": np.arange(20)}) tcf = TimeCopilotForecaster(models=[FlowState()]) From 3bc1218988229a706a01f6adb9bed0365595d936 Mon Sep 17 00:00:00 2001 From: Kushagra Srivastav <76401345+Kushagra7777@users.noreply.github.com> Date: Thu, 19 Feb 2026 15:35:51 +0900 Subject: [PATCH 5/5] Fix numpy conversion for fcst_mean adjust conversion to handle device-related issues safely Co-Authored-By: spolisar Co-Authored-By: azul --- timecopilot/models/foundation/flowstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/timecopilot/models/foundation/flowstate.py b/timecopilot/models/foundation/flowstate.py index 02039c0..493232c 100644 --- a/timecopilot/models/foundation/flowstate.py +++ b/timecopilot/models/foundation/flowstate.py @@ -168,7 +168,7 @@ def _predict_batch( ).prediction_outputs fcst = fcst.squeeze(-1).transpose(-1, -2) # now shape is (batch, h, quantiles) fcst_mean = fcst[..., supported_quantiles.index(0.5)] - fcst_mean_np = fcst_mean.detach().numpy() + fcst_mean_np = fcst_mean.detach().numpy(force=True) fcst_quantiles_np = fcst.detach().numpy() if quantiles is not None else None return fcst_mean_np, fcst_quantiles_np