def test_barplot(): "Test plot.Barplot" ds = datasets.get_uv() # average plot.Barplot('fltvar', ds=ds) plot.Barplot('fltvar', match='rm', ds=ds) # one category p = plot.Barplot('fltvar + 2', 'A', ds=ds) assert p.get_ylim()[0] == 0 p = plot.Barplot('fltvar - 2', 'A', 'rm', ds=ds) assert p.get_ylim()[1] == 0 # multiple categories plot.Barplot('fltvar', 'A%B', match='rm', ds=ds) plot.Barplot('fltvar', 'A%B', match='rm', ds=ds, pool_error=False) # test against 0 plot.Barplot('fltvar', 'A%B', match='rm', test=0, ds=ds) # cells plot.Barplot('fltvar', 'A%B', cells=(('a2', 'b2'), ('a1', 'b1')), ds=ds) plot.Barplot('fltvar', 'A%B', match='rm', cells=(('a2', 'b2'), ('a1', 'b1')), ds=ds) # Fixed top p = plot.Barplot('fltvar', 'A%B', ds=ds, top=2, test_markers=False) ax = p._axes[0] assert ax.get_ylim()[1] == 2
def test_report(): "Test fmtxt.Report class" tempdir = tempfile.mkdtemp() report = fmtxt.Report("Test Report") section = report.add_section(u'unicode: \xe2 abc') ds = datasets.get_uv() p = plot.Barplot('fltvar', 'A', sub="B=='b1'", ds=ds, show=False) image = p.image() section.add_figure("test", image) report.sign() # report output print(report) dst = os.path.join(tempdir, 'report.html') report.save_html(dst) # test meta attribute reading eq_(read_meta(dst), {}) report.save_html(dst, meta={'samples': 100, 'text': 'blah'}) eq_(read_meta(dst), {'samples': '100', 'text': 'blah'}) # clean up shutil.rmtree(tempdir)
def test_boxplot(): "Test plot.Boxplot" ds = datasets.get_uv() plot.Boxplot('fltvar', 'A%B', match='rm', ds=ds, show=False) # one category plot.Boxplot('fltvar', ds=ds, test=False, show=False) plot.Boxplot('fltvar', ds=ds, show=False) plot.Boxplot('fltvar', match='rm', ds=ds, show=False) # many pairwise significances ds['fltvar'][ds.eval("A%B==('a1','b1')")] += 1 ds['fltvar'][ds.eval("A%B==('a2','b2')")] -= 1 ds['C'] = Factor('qw', repeat=10, tile=4) plot.Boxplot('fltvar', 'A%B%C', ds=ds, show=False) # long labels ds['A'].relabel({ 'a1': 'a very long label', 'a2': 'another very long label' }) p = plot.Barplot('fltvar', 'A%B', ds=ds, show=False) labels = p._ax.get_xticklabels() bbs = [l.get_window_extent() for l in labels] for i in xrange(len(bbs) - 1): ok_(bbs[i].x1 < bbs[i + 1].x0)
def test_barplot(): "Test plot.Barplot" ds = datasets.get_uv() # one category plot.Barplot('fltvar', ds=ds, test=False, show=False) plot.Barplot('fltvar', ds=ds, show=False) plot.Barplot('fltvar', match='rm', ds=ds, show=False) # multiple categories plot.Barplot('fltvar', 'A%B', match='rm', ds=ds, show=False) plot.Barplot('fltvar', 'A%B', match='rm', ds=ds, pool_error=False, show=False) plot.Barplot('fltvar', 'A%B', match='rm', test=0, ds=ds, show=False) # Fixed top p = plot.Barplot('fltvar', 'A%B', ds=ds, top=2, test_markers=False, show=False) ax = p._axes[0] eq_(ax.get_ylim()[1], 2)
def test_report(): "Test fmtxt.Report class" tempdir = tempfile.mkdtemp() report = fmtxt.Report("Test Report") section = report.add_section(u'unicode: \xe2 abc') ds = datasets.get_uv() p = plot.Barplot('fltvar', 'A', sub="B=='b1'", ds=ds, show=False) image = p.image() section.add_figure("test", image) report.sign() # report output print report dst = os.path.join(tempdir, 'report.html') report.save_html(dst) # clean up shutil.rmtree(tempdir)