from unittest.mock import MagicMock, PropertyMock
import numpy as np
from thyro.features import get_feature
from collections import namedtuple


ReturnsFS = namedtuple('ReturnsFS', 'len shape segments features iter')

np.random.seed(10)

TEST_SEGMENTS = [slice(2, 5), slice(6, 9), slice(12, 15)]

TEST_SIGNAL = np.random.randint(1, 10, 15)
MIN_FEATURE = get_feature(TEST_SIGNAL, 'min')
MAX_FEATURE = get_feature(TEST_SIGNAL, 'max')

FEATURE_SPACE_RETURN = [(MIN_FEATURE(seg), MAX_FEATURE(seg)) for seg in TEST_SEGMENTS]


def mock_feature_space():
    mocked_fs = MagicMock()

    mocked_len = 3
    mocked_fs.__len__.return_value = mocked_len

    mocked_shape = (3, 2)
    shape = PropertyMock(return_value=mocked_shape)
    type(mocked_fs).shape = shape

    segments = PropertyMock(return_value=TEST_SEGMENTS)
    type(mocked_fs).segments = segments

    _features = (MIN_FEATURE, MAX_FEATURE)
    features = PropertyMock(return_value=_features)
    type(mocked_fs).features = features


    mocked_fs.__iter__.return_value = FEATURE_SPACE_RETURN

    return_values = ReturnsFS(mocked_len, mocked_shape, TEST_SEGMENTS, _features, FEATURE_SPACE_RETURN)

    return mocked_fs, return_values

@@ -449,16 +449,25 @@
 ETURN = 
+np.array(
 %5B(MIN_FE
@@ -521,16 +521,161 @@
 EGMENTS%5D
+)%0A%0ATEST_FEATURE_NAMES = %5B'test_signal_min', 'test_signal_max'%5D%0ATEST_LABELS = %5B'test_label'%5D * len(TEST_SEGMENTS)%0ATEST_TARGETS = np.array(%5B0%5D * 3)
 %0A%0A%0Adef m

Add test utils