@@ -122,17 +122,11 @@ def mse(
122122
123123 # Shape validation
124124 if y_true .ndim != 3 :
125- raise ValueError (
126- f"y_true must be 3-dimensional (batch_size, horizon, features), got shape { y_true .shape } "
127- )
125+ raise ValueError (f"y_true must be 3-dimensional (batch_size, horizon, features), got shape { y_true .shape } " )
128126 if y_pred .ndim != 3 :
129- raise ValueError (
130- f"y_pred must be 3-dimensional (batch_size, horizon, features), got shape { y_pred .shape } "
131- )
127+ raise ValueError (f"y_pred must be 3-dimensional (batch_size, horizon, features), got shape { y_pred .shape } " )
132128 if y_true .shape != y_pred .shape :
133- raise ValueError (
134- f"y_true and y_pred must have the same shape, got { y_true .shape } and { y_pred .shape } "
135- )
129+ raise ValueError (f"y_true and y_pred must have the same shape, got { y_true .shape } and { y_pred .shape } " )
136130
137131 # Empty validation
138132 if y_true .size == 0 :
@@ -215,17 +209,11 @@ def mae(
215209
216210 # Shape validation
217211 if y_true .ndim != 3 :
218- raise ValueError (
219- f"y_true must be 3-dimensional (batch_size, horizon, features), got shape { y_true .shape } "
220- )
212+ raise ValueError (f"y_true must be 3-dimensional (batch_size, horizon, features), got shape { y_true .shape } " )
221213 if y_pred .ndim != 3 :
222- raise ValueError (
223- f"y_pred must be 3-dimensional (batch_size, horizon, features), got shape { y_pred .shape } "
224- )
214+ raise ValueError (f"y_pred must be 3-dimensional (batch_size, horizon, features), got shape { y_pred .shape } " )
225215 if y_true .shape != y_pred .shape :
226- raise ValueError (
227- f"y_true and y_pred must have the same shape, got { y_true .shape } and { y_pred .shape } "
228- )
216+ raise ValueError (f"y_true and y_pred must have the same shape, got { y_true .shape } and { y_pred .shape } " )
229217
230218 # Empty validation
231219 if y_true .size == 0 :
@@ -341,43 +329,33 @@ def mase(
341329
342330 # Shape validation
343331 if y_true .ndim != 3 :
344- raise ValueError (
345- f"y_true must be 3-dimensional (batch_size, horizon, features), got shape { y_true .shape } "
346- )
332+ raise ValueError (f"y_true must be 3-dimensional (batch_size, horizon, features), got shape { y_true .shape } " )
347333 if y_pred .ndim != 3 :
348- raise ValueError (
349- f"y_pred must be 3-dimensional (batch_size, horizon, features), got shape { y_pred .shape } "
350- )
334+ raise ValueError (f"y_pred must be 3-dimensional (batch_size, horizon, features), got shape { y_pred .shape } " )
351335 if y_train .ndim != 3 :
352336 raise ValueError (
353337 f"y_train must be 3-dimensional (batch_size, train_length, features), got shape { y_train .shape } "
354338 )
355339
356340 if y_true .shape != y_pred .shape :
357- raise ValueError (
358- f"y_true and y_pred must have the same shape, got { y_true .shape } and { y_pred .shape } "
359- )
341+ raise ValueError (f"y_true and y_pred must have the same shape, got { y_true .shape } and { y_pred .shape } " )
360342
361343 batch_size_true , _ , features_true = y_true .shape
362344 batch_size_train , train_length , features_train = y_train .shape
363345
364346 if batch_size_true != batch_size_train :
365347 raise ValueError (
366- f"Batch size mismatch: y_true has { batch_size_true } samples, "
367- f"y_train has { batch_size_train } samples"
348+ f"Batch size mismatch: y_true has { batch_size_true } samples, y_train has { batch_size_train } samples"
368349 )
369350
370351 if features_true != features_train :
371352 raise ValueError (
372- f"Feature count mismatch: y_true has { features_true } features, "
373- f"y_train has { features_train } features"
353+ f"Feature count mismatch: y_true has { features_true } features, y_train has { features_train } features"
374354 )
375355
376356 # Training data length validation
377357 if train_length < 2 :
378- raise ValueError (
379- f"y_train must have at least 2 time steps for naive baseline, got { train_length } "
380- )
358+ raise ValueError (f"y_train must have at least 2 time steps for naive baseline, got { train_length } " )
381359
382360 # Empty validation
383361 if y_true .size == 0 :
@@ -551,9 +529,7 @@ def crps_from_quantiles(
551529
552530 # Shape validation
553531 if y_true .ndim != 3 :
554- raise ValueError (
555- f"y_true must be 3-dimensional (batch_size, horizon, features), got shape { y_true .shape } "
556- )
532+ raise ValueError (f"y_true must be 3-dimensional (batch_size, horizon, features), got shape { y_true .shape } " )
557533 if quantile_preds .ndim != 3 :
558534 raise ValueError (
559535 f"quantile_preds must be 3-dimensional (batch_size, horizon, num_quantiles), "
@@ -565,29 +541,22 @@ def crps_from_quantiles(
565541
566542 if batch_size_true != batch_size_pred :
567543 raise ValueError (
568- f"Batch size mismatch: y_true has { batch_size_true } samples, "
569- f"quantile_preds has { batch_size_pred } samples"
544+ f"Batch size mismatch: y_true has { batch_size_true } samples, quantile_preds has { batch_size_pred } samples"
570545 )
571546 if horizon_true != horizon_pred :
572- raise ValueError (
573- f"Horizon mismatch: y_true has { horizon_true } steps, "
574- f"quantile_preds has { horizon_pred } steps"
575- )
547+ raise ValueError (f"Horizon mismatch: y_true has { horizon_true } steps, quantile_preds has { horizon_pred } steps" )
576548
577549 # Quantile levels validation
578550 if len (quantile_levels ) != num_quantiles :
579551 raise ValueError (
580- f"quantile_levels length ({ len (quantile_levels )} ) must match "
581- f"num_quantiles dimension ({ num_quantiles } )"
552+ f"quantile_levels length ({ len (quantile_levels )} ) must match num_quantiles dimension ({ num_quantiles } )"
582553 )
583554
584555 if not all (0.0 <= q <= 1.0 for q in quantile_levels ):
585556 raise ValueError (f"quantile_levels must be in [0.0, 1.0], got { quantile_levels } " )
586557
587558 if quantile_levels != sorted (quantile_levels ):
588- raise ValueError (
589- f"quantile_levels must be sorted in ascending order, got { quantile_levels } "
590- )
559+ raise ValueError (f"quantile_levels must be sorted in ascending order, got { quantile_levels } " )
591560
592561 # Empty validation
593562 if y_true .size == 0 :
@@ -656,4 +625,4 @@ def crps_from_quantiles(
656625 # Average over horizon, keep batch dimension
657626 return np .mean (crps_values , axis = 1 )
658627 else :
659- raise ValueError (f"reduction must be 'mean' or 'none', got '{ reduction } '" )
628+ raise ValueError (f"reduction must be 'mean' or 'none', got '{ reduction } '" )
0 commit comments