def test_samples(): m1 = Metric("x", "y") m1.add_ys(x=2, ys=[3]) m1.add_ys(x=3, ys=[3]) m2 = Metric("x", "y") m2.add_ys(x=2, ys=[15, 14]) m2.add_ys(x=3, ys=[10, 12]) assert m1.samples == 1 assert m2.samples == 2
def test_summ_valid(): m1 = Metric("x", "y") m1.add_ys(x=2, ys=[3]) m1.add_ys(x=3, ys=[3]) m2 = Metric("x", "y") m2.add_ys(x=2, ys=[15]) m2.add_ys(x=3, ys=[10]) m3 = m1 + m2 assert len(m3.data.keys()) == 2
def test_ezplot(tmpdir): m = Metric('x', 'y') m.add_ys(1, [1, 2, 3]) m.add_record(2, 4) m.add_record(2, 4) m.add_record(2, 4) m.add_ys(4, [5, 6, 12]) files_before = len(os.listdir(tmpdir)) plot(m, folder=tmpdir, name="bla3") files_after = len(os.listdir(tmpdir)) assert files_after > files_before
def test_cycle_save(tmpdir): m1 = Metric("x", "y") m1.add_ys(x=2, ys=[3]) m1.add_ys(x=3, ys=[3]) m1.save(tmpdir) ms = Metric.load_all(tmpdir) assert len(ms) == 1 assert m1.__dict__ == ms[0].__dict__
def test_original_metrics_intact(): m1 = Metric("x", "y") m1.add_ys(x=2, ys=[3]) m1.add_ys(x=3, ys=[3]) m2 = Metric("x", "y") m2.add_ys(x=2, ys=[15]) m2.add_ys(x=3, ys=[10]) m3 = m1 + m2 assert m1.samples == 1 assert m2.samples == 1 assert m3.samples == 2
def test_load_many(tmpdir): m1 = Metric("m1", "x", "y") m1.add_ys(x=2, ys=[3]) m1.add_ys(x=3, ys=[3]) m2 = Metric("m2", "x", "y") m2.add_ys(x=2, ys=[15]) m2.add_ys(x=3, ys=[10]) m1.save(tmpdir) m2.save(tmpdir) ms = Metric.load_all(tmpdir) assert len(ms) == 2
def test_summ_3(): m1 = Metric("x", "y") m1.add_ys(x=2, ys=[3, 4, 5]) m1.add_ys(x=3, ys=[20, 4, 5]) m2 = Metric("x", "y") m2.add_ys(x=2, ys=[15]) m2.add_ys(x=3, ys=[20]) m3 = Metric("x", "y") m3.add_ys(x=2, ys=[15]) m3.add_ys(x=3, ys=[20]) m4 = sum([m1, m2, m3]) assert 2 in m4.data.keys()
def test_plot_group(tmpdir): m = Metric('x', 'y') m.add_ys(1, [1, 2, 3]) m.add_record(2, 4) m.add_record(2, 4) m.add_record(2, 4) m.add_ys(4, [5, 6, 12]) m2 = Metric('x', 'y') m2.add_ys(1, [4, 3, 5]) m2.add_record(2, 5) m2.add_record(2, 9) m2.add_record(2, 9) m2.add_ys(4, [5, 6, -1]) files_before = len(os.listdir(tmpdir)) plot_group([m, m2], folder=tmpdir, name="bla3") files_after = len(os.listdir(tmpdir)) assert files_after > files_before