def test_progressbar(max_val, sleep_time=2):
    bar = Scoring.Bar(max_val)
    bar.start()
    for i in range(max_val):
        bar.update(i + 1)
        sleep(sleep_time)
    bar.finish()
    print("all is good")
def GridSearchPCA(estimator,
                  params,
                  Data,
                  config,
                  n_comp,
                  name,
                  location,
                  states=3):
    df = CreateDataFrame(Data=Data, config=config)
    KFold = FE.KFold(Data.shape[2])

    start = time()
    GRID = ParameterGrid(params)
    combinations = len(list(GRID))
    print("Number of combinations {}".format(combinations))
    bar = Scoring.Bar(combinations * 10)
    combo = 0
    bar.start()
    for i, g in enumerate(GRID):
        score_tab = Scoring.ScoringTable(location=location,
                                         name=name + str(g) + str(i),
                                         n_states=states)
        for cross in range(Data.shape[0]):
            clf = copy(estimator)
            X_train, y_train, X_test, y_test = KFold.fit_transform(
                x=df, kFoldIndex=cross)

            scale = StandardScaler()
            X_train = scale.fit_transform(X=X_train, y=y_train)
            X_test = scale.transform(X=X_test)

            pca = PCA(n_components=n_comp)
            X_train = pca.fit_transform(X=X_train)
            X_test = pca.transform(X=X_test)

            clf.set_params(**g)
            pred = train_and_predict(model=clf,
                                     train=X_train,
                                     test=X_test,
                                     labels=y_train,
                                     unsupervised=False)
            score = Scoring.score(states=pred,
                                  results=np.array(y_test),
                                  unsupervised=False,
                                  pocet_stavu=states)
            score_tab.add(scores=score)
            combo += 1
            bar.update(combo)

        score_tab.save_table()
        del score_tab
        info = copy(config)
        info["params"] = g
        with open(location + name + str(g) + str(i) + '_config.pickle',
                  'wb') as f:
            pickle.dump(info, f)

    bar.finish()
    print('Celý proces trval: {} vteřin'.format(
        np.around(time() - start, decimals=0)))
    print('Hotovo!!')
    return