@numpyonly
def test_clustering():
    with util_numpy.test_uses_numpy() as np:
        s = np.array([[0.0, 0, 1, 2, 1, 0, 1, 0, 0], [0.0, 1, 2, 0, 0, 0, 0, 0, 0], [1.0, 2, 0, 0, 0, 0, 0, 1, 1], [0.0, 0, 1, 2, 1, 0, 1, 0, 0], [0.0, 1, 2, 0, 0, 0, 0, 0, 0], [1.0, 2, 0, 0, 0, 0, 0, 1, 1]])

        def test_hook(from_idx, to_idx, distance):
            assert ((from_idx, to_idx) in [(3, 0), (4, 1), (5, 2), (1, 0)])
        model = clustering.Hierarchical(dtw.distance_matrix_fast, {}, 2, merge_hook=test_hook, show_progress=False)
        cluster_idx = model.fit(s)
        assert (cluster_idx[0] == {0, 1, 3, 4})
        assert (cluster_idx[2] == {2, 5})
@numpyonly
def test_clustering():
    with util_numpy.test_uses_numpy() as np:
        s = np.array([[0.0, 0, 1, 2, 1, 0, 1, 0, 0], [0.0, 1, 2, 0, 0, 0, 0, 0, 0], [1.0, 2, 0, 0, 0, 0, 0, 1, 1], [0.0, 0, 1, 2, 1, 0, 1, 0, 0], [0.0, 1, 2, 0, 0, 0, 0, 0, 0], [1.0, 2, 0, 0, 0, 0, 0, 1, 1]])

        def test_hook(from_idx, to_idx, distance):
            assert ((from_idx, to_idx) in [(3, 0), (4, 1), (5, 2), (1, 0)])
        model = clustering.Hierarchical(dtw.distance_matrix_fast, {}, 2, merge_hook=test_hook, show_progress=False)
        cluster_idx = model.fit(s)
        assert (cluster_idx[0] == {0, 1, 3, 4})
        assert (cluster_idx[2] == {2, 5})