@scipyonly
@numpyonly
def test_controlchart():
    with util_numpy.test_uses_numpy() as np:
        series = np.zeros((600, 60))
        rsrc_fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'rsrc', 'synthetic_control.data')
        with open(rsrc_fn, 'r') as ifile:
            for (idx, line) in enumerate(ifile.readlines()):
                series[idx, :] = line.split()
        s = []
        for idx in range(0, 600, 20):
            s.append(series[idx, :])
        model = clustering.LinkageTree(dtw.distance_matrix_fast, {'parallel': True})
        cluster_idx = model.fit(s)
        if (not dtwvis.test_without_visualization()):
            import matplotlib.pyplot as plt
            if directory:
                hierarchy_fn = os.path.join(directory, 'hierarchy.png')
            else:
                file = tempfile.NamedTemporaryFile()
                hierarchy_fn = (file.name + '_hierarchy.png')
            (fig, ax) = plt.subplots(nrows=1, ncols=2, figsize=(10, 10))
            show_ts_label = (lambda idx: ('ts-' + str(idx)))

            def curcmap(idx):
                if ((idx % 2) == 0):
                    return 'r'
                return 'g'
            model.plot(hierarchy_fn, axes=ax, show_ts_label=show_ts_label, show_tr_label=True, ts_label_margin=(- 10), ts_left_margin=10, ts_sample_length=1, ts_color=curcmap)
            print('Figure saved to', hierarchy_fn)
@scipyonly
@numpyonly
def test_controlchart():
    with util_numpy.test_uses_numpy() as np:
        series = np.zeros((600, 60))
        rsrc_fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'rsrc', 'synthetic_control.data')
        with open(rsrc_fn, 'r') as ifile:
            for (idx, line) in enumerate(ifile.readlines()):
                series[idx, :] = line.split()
        s = []
        for idx in range(0, 600, 20):
            s.append(series[idx, :])
        model = clustering.LinkageTree(dtw.distance_matrix_fast, {'parallel': True})
        cluster_idx = model.fit(s)
        if (not dtwvis.test_without_visualization()):
            import matplotlib.pyplot as plt
            if directory:
                hierarchy_fn = os.path.join(directory, 'hierarchy.png')
            else:
                file = tempfile.NamedTemporaryFile()
                hierarchy_fn = (file.name + '_hierarchy.png')
            (fig, ax) = plt.subplots(nrows=1, ncols=2, figsize=(10, 10))
            show_ts_label = (lambda idx: ('ts-' + str(idx)))

            def curcmap(idx):
                if ((idx % 2) == 0):
                    return 'r'
                return 'g'
            model.plot(hierarchy_fn, axes=ax, show_ts_label=show_ts_label, show_tr_label=True, ts_label_margin=(- 10), ts_left_margin=10, ts_sample_length=1, ts_color=curcmap)
            print('Figure saved to', hierarchy_fn)