<filename>tests/test_metrics.py
import numpy as np

from ts_eval.metrics import is_


# fmt: off
# M4 competition supplied values to verify IS correctness
# Input
S1_L = np.array([289, 266, 313, 238, 224, 209, 206, 175, 164, 150, 138, 120, 109, 96, 83, 70, 58, 46])
S1_U = np.array([938, 923, 992, 949, 1008, 1014, 1040, 1041, 1067, 1078, 1094, 1104, 1121, 1133, 1146, 1157, 1170, 1182])
S2_L = np.array([297, 304, 312, 319, 327, 334, 342, 349, 357, 364, 372, 379, 387, 395, 402, 410, 417, 425])
S2_U = np.array([865, 873, 880, 888, 895, 903, 910, 918, 926, 933, 941, 948, 956, 963, 971, 978, 986, 993])
Y = np.array([654, 492, 171, 342, 591, 672, 465, 255, 864, 768, 672, 519, 519, 591, 480, 564, 579, 423])

# Expected output
IS1 = np.array([649, 657, 6359, 711, 784, 805, 834, 866, 903, 928, 956, 984, 1012, 1037, 1063, 1087, 1112, 1136])
IS2 = np.array([568, 569, 6208, 569, 568, 569, 568, 4329, 569, 569, 569, 569, 569, 568, 569, 568, 569, 648])
# fmt: on


def test_m4_data_mis():
    assert np.allclose(is_(Y, S1_U, S1_L), IS1)
    assert np.allclose(is_(Y, S2_U, S2_L), IS2)
