from autoperiod.helpers import load_google_trends_csv, load_gpfs_csv from autoperiod.plotting import Plotter if __name__ == '__main__': # values = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3] * 100, np.float) # values = values / np.max(values) # values = 1 - values # times = np.arange(1, values.size + 1, dtype=np.float) times, values = load_google_trends_csv(os.path.join(os.getcwd(), "tests/data/trends_easter.csv")) p = Autoperiod(times, values, plotter=Plotter()) times, values = load_google_trends_csv(os.path.join(os.getcwd(), "tests/data/trends_python.csv")) p = Autoperiod(times, values, plotter=Plotter()) times, values = load_gpfs_csv(os.path.join(os.getcwd(), "tests/data/ub-hpc-6665127-gpfs-writes.csv")) p = Autoperiod(times, values, plotter=Plotter()) times, values = load_google_trends_csv(os.path.join(os.getcwd(), "tests/data/trends_newyears.csv")) p = Autoperiod(times, values, plotter=Plotter()) times, values = load_google_trends_csv(os.path.join(os.getcwd(), "tests/data/trends_summer.csv")) p = Autoperiod(times, values, plotter=Plotter()) times, values = load_gpfs_csv(os.path.join(os.getcwd(), "tests/data/industry-2895978-gpfs-reads.csv")) p = Autoperiod(times, values, plotter=Plotter()) times, values = load_gpfs_csv(os.path.join(os.getcwd(), "tests/data/industry-2901023-gpfs-writes.csv")) p = Autoperiod(times, values, plotter=Plotter()) times, values = load_gpfs_csv(os.path.join(os.getcwd(), "tests/data/industry-2896041-gpfs-writes.csv"))
def bench_gpfs_read_stat(benchmark): times, values = load_gpfs_csv(data("ub-hpc-6665127-gpfs-reads.csv")) period = benchmark(_autoperiod, times, values, 'stat') assert period == approx(9469, rel=0.01)
def test_pcp_spiky_acf(mthd): times, values = load_gpfs_csv(data("chemistry-1455991-gpfs-writes.csv")) period = Autoperiod(times, values, threshold_method=mthd).period assert period == approx(3660, rel=0.01)
def test_pcp_smallperiod(threshold_method, filename, expect_period): # test for regression to false alarm large period times, values = load_gpfs_csv(data(filename)) period = Autoperiod(times, values, threshold_method=threshold_method).period assert period == approx(expect_period, rel=0.01)
def test_gpfs_writes(threshold_method): times, values = load_gpfs_csv(data("ub-hpc-6665127-gpfs-writes.csv")) period = Autoperiod(times, values, threshold_method=threshold_method).period assert period == approx(9560, rel=0.01)
def test_pcp_noperiod(threshold_method, filename): times, values = load_gpfs_csv(data(filename)) period = Autoperiod(times, values, threshold_method=threshold_method).period assert period is None