55"""
66
77from dataclasses import dataclass , field
8- from typing import Any , Literal , Optional
8+ from typing import Any , Literal
99
1010import numpy as np
1111
@@ -31,7 +31,7 @@ class ForecastRequest:
3131 model_version : str = "1"
3232 """Model version to use for inference. Default: '1'"""
3333
34- compression : Optional [ str ] = "zstd"
34+ compression : str | None = "zstd"
3535 """Arrow compression algorithm. Options: 'zstd', 'lz4', None. Default: 'zstd'"""
3636
3737 def __post_init__ (self ) -> None :
@@ -74,19 +74,19 @@ class ToToForecastRequest(ForecastRequest):
7474 output_type : OutputType = "point"
7575 """Output type to return. Options: 'point', 'quantiles', 'samples'. Default: 'point'."""
7676
77- padding_mask : Optional [ np .ndarray ] = None
77+ padding_mask : np .ndarray | None = None
7878 """Padding mask for variable-length sequences. Shape: same as x.
7979 1 for valid timesteps, 0 for padding."""
8080
81- id_mask : Optional [ np .ndarray ] = None
81+ id_mask : np .ndarray | None = None
8282 """Identifier mask for multi-series forecasting. Shape: (batch_size,).
8383 Each unique ID represents a different time series."""
8484
85- num_samples : Optional [ int ] = None
85+ num_samples : int | None = None
8686 """Number of forecast samples for probabilistic predictions.
8787 If set, returns sample-based distribution."""
8888
89- quantiles : Optional [ list [float ]] = None
89+ quantiles : list [float ] | None = None
9090 """Quantile levels for probabilistic forecasting.
9191 Example: [0.1, 0.5, 0.9] for 10th, 50th (median), 90th percentiles."""
9292
@@ -142,11 +142,11 @@ class FlowStateForecastRequest(ForecastRequest):
142142 output_type : OutputType = "point"
143143 """Output type to return. Options: 'point', 'quantiles', 'samples'. Default: 'point'."""
144144
145- scale_factor : Optional [ float ] = None
145+ scale_factor : float | None = None
146146 """Scaling factor for normalization/denormalization.
147147 Applied to inputs before inference and outputs after inference."""
148148
149- prediction_type : Optional [ Literal ["mean" , "median" , "quantile" ]] = None
149+ prediction_type : Literal ["mean" , "median" , "quantile" ] | None = None
150150 """Prediction type for FlowState model.
151151 Options: 'mean', 'median' (requires output_type='point'),
152152 'quantile' (requires output_type='quantiles')."""
@@ -179,7 +179,7 @@ def __post_init__(self) -> None:
179179 )
180180 if self .output_type == "point" and self .prediction_type == "quantile" :
181181 raise ValueError (
182- f "output_type='point' conflicts with prediction_type='quantile'"
182+ "output_type='point' conflicts with prediction_type='quantile'"
183183 )
184184
185185 def to_arrays_and_metadata (self ) -> tuple [dict [str , np .ndarray ], dict [str , Any ]]:
@@ -208,13 +208,13 @@ class ForecastResponse:
208208 """Response metadata from backend (e.g., model_name, model_version)"""
209209
210210 # Backend outputs
211- point : Optional [ np .ndarray ] = None
211+ point : np .ndarray | None = None
212212 """Point predictions from FlowState. Shape: (batch_size, horizon, features)"""
213213
214- quantiles : Optional [ np .ndarray ] = None
214+ quantiles : np .ndarray | None = None
215215 """Quantile predictions from ToTo. Shape: (batch_size, horizon, num_quantiles)"""
216216
217- samples : Optional [ np .ndarray ] = None
217+ samples : np .ndarray | None = None
218218 """Sample predictions from ToTo. Shape: (batch_size, horizon, num_samples)"""
219219
220220 @classmethod
0 commit comments