本文整理汇总了Python中matplotlib.testing.compare.compare_images方法的典型用法代码示例。如果您正苦于以下问题:Python compare.compare_images方法的具体用法?Python compare.compare_images怎么用?Python compare.compare_images使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.testing.compare
的用法示例。
在下文中一共展示了compare.compare_images方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: image_comparison_expect_rms
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def image_comparison_expect_rms(im1, im2, tol, expect_rms):
"""Compare two images, expecting a particular RMS error.
im1 and im2 are filenames relative to the baseline_dir directory.
tol is the tolerance to pass to compare_images.
expect_rms is the expected RMS value, or None. If None, the test will
succeed if compare_images succeeds. Otherwise, the test will succeed if
compare_images fails and returns an RMS error almost equal to this value.
"""
im1 = os.path.join(baseline_dir, im1)
im2_src = os.path.join(baseline_dir, im2)
im2 = os.path.join(result_dir, im2)
# Move im2 from baseline_dir to result_dir. This will ensure that
# compare_images writes the diff file to result_dir, instead of trying to
# write to the (possibly read-only) baseline_dir.
shutil.copyfile(im2_src, im2)
results = compare_images(im1, im2, tol=tol, in_decorator=True)
if expect_rms is None:
assert_equal(None, results)
else:
assert_not_equal(None, results)
assert_almost_equal(expect_rms, results['rms'], places=4)
示例2: test_plot_tracks_with_hic
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_plot_tracks_with_hic():
outfile = NamedTemporaryFile(suffix='.png', prefix='pyGenomeTracks_test_',
delete=False)
args = "--tracks {0} --region X:2500000-3500000 "\
"--trackLabelFraction 0.23 --width 38 " \
"--dpi 130 --outFileName {1}" \
"".format(os.path.join(ROOT, 'browser_tracks_hic.ini'),
outfile.name).split()
pygenometracks.plotTracks.main(args)
res = compare_images(os.path.join(ROOT, 'master_plot_hic.png'),
outfile.name, tolerance)
print("saving test to {}".format(outfile.name))
assert res is None, res
os.remove(outfile.name)
示例3: test_plot_tracks_with_hic_dec
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_plot_tracks_with_hic_dec():
outfile = NamedTemporaryFile(suffix='.png', prefix='pyGenomeTracks_test_',
delete=False)
args = "--tracks {0} --region X:2500000-3500000 "\
"--trackLabelFraction 0.23 --width 38 " \
"--dpi 130 --outFileName {1} --decreasingXAxis" \
"".format(os.path.join(ROOT, 'browser_tracks_hic.ini'),
outfile.name).split()
pygenometracks.plotTracks.main(args)
res = compare_images(os.path.join(ROOT, 'master_plot_hic_dec.png'),
outfile.name, tolerance)
print("saving test to {}".format(outfile.name))
assert res is None, res
os.remove(outfile.name)
示例4: test_plot_tracks_with_hic_rasterize_height
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_plot_tracks_with_hic_rasterize_height():
outfile = NamedTemporaryFile(suffix='.pdf', prefix='pyGenomeTracks_test_',
delete=False)
args = "--tracks {0} --region X:2500000-2600000 "\
"--trackLabelFraction 0.23 --width 38 " \
"--dpi 10 --outFileName {1}" \
"".format(os.path.join(ROOT,
'browser_tracks_hic_rasterize_height.ini'),
outfile.name).split()
pygenometracks.plotTracks.main(args)
res = compare_images(os.path.join(ROOT,
'master_plot_hic_rasterize_height.pdf'),
outfile.name, tolerance)
assert res is None, res
os.remove(outfile.name)
示例5: test_hicAggregateContacts
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_hicAggregateContacts():
outfile_aggregate_plots = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_test_', delete=False)
args = "--matrix {root}/Li_et_al_2015.h5 --BED {root}/hicAggregateContacts/test_regions.bed " \
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --disable_bbox_tight --dpi 100".\
format(root=ROOT, out_agg=outfile_aggregate_plots.name)
test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate.png'
hicexplorer.hicAggregateContacts.main(args.split())
res = compare_images(test_image_agg, outfile_aggregate_plots.name, tolerance)
assert res is None, res
os.remove(outfile_aggregate_plots.name)
示例6: test_hicAggregateContacts_cooler
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_hicAggregateContacts_cooler():
outfile_aggregate_plots = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_test_', delete=False)
args = "--matrix {root}/Li_et_al_2015.cool --BED {root}/hicAggregateContacts/test_regions.bed " \
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --disable_bbox_tight --dpi 100".\
format(root=ROOT, out_agg=outfile_aggregate_plots.name)
test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate.png' # noqa: F841
hicexplorer.hicAggregateContacts.main(args.split())
res = compare_images(test_image_agg, outfile_aggregate_plots.name, tolerance)
assert res is None, res
os.remove(outfile_aggregate_plots.name)
示例7: test_hicAggregateContacts_clustering
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_hicAggregateContacts_clustering():
outfile_aggregate_plots = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_test_', delete=False)
outfile_heatmaps = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_heatmap_', delete=False)
args = "--matrix {root}/Li_et_al_2015.h5 --BED {root}/hicAggregateContacts/test_regions.bed " \
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --hclust 4 " \
"--diagnosticHeatmapFile {out_heat} --howToCluster diagonal --disable_bbox_tight --dpi 100 " \
"--BED2 {root}/hicAggregateContacts/test_regions.bed".format(root=ROOT, out_agg=outfile_aggregate_plots.name,
out_heat=outfile_heatmaps.name)
test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate_hclust4.png'
test_image_heatmap = ROOT + 'hicAggregateContacts/master_heatmap.png'
hicexplorer.hicAggregateContacts.main(args.split())
res = compare_images(test_image_agg, outfile_aggregate_plots.name, tolerance)
assert res is None, res
res = compare_images(test_image_heatmap, outfile_heatmaps.name, tolerance)
assert res is None, res
os.remove(outfile_aggregate_plots.name)
os.remove(outfile_heatmaps.name)
示例8: test_hicAggregateContacts_clustering_cool
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_hicAggregateContacts_clustering_cool():
outfile_aggregate_plots = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_test_', delete=False)
outfile_heatmaps = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_heatmap_', delete=False)
args = "--matrix {root}/Li_et_al_2015.cool --BED {root}/hicAggregateContacts/test_regions.bed " \
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --hclust 4 " \
"--diagnosticHeatmapFile {out_heat} --howToCluster diagonal --disable_bbox_tight --dpi 100 " \
"--BED2 {root}/hicAggregateContacts/test_regions.bed".format(root=ROOT, out_agg=outfile_aggregate_plots.name,
out_heat=outfile_heatmaps.name)
test_image_agg = ROOT + 'hicAggregateContacts/master_aggregate_hclust4.png'
test_image_heatmap = ROOT + 'hicAggregateContacts/master_heatmap.png'
hicexplorer.hicAggregateContacts.main(args.split())
res = compare_images(test_image_agg, outfile_aggregate_plots.name, tolerance)
assert res is None, res
res = compare_images(test_image_heatmap, outfile_heatmaps.name, tolerance)
assert res is None, res
os.remove(outfile_aggregate_plots.name)
os.remove(outfile_heatmaps.name)
示例9: test_hicAggregateContacts_3d_cooler
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_hicAggregateContacts_3d_cooler():
outfile_aggregate_3d = NamedTemporaryFile(suffix='.png', prefix='hicaggregate_test_3d', delete=False)
args = "--matrix {root}/Li_et_al_2015.cool --BED {root}/hicAggregateContacts/test_regions.bed " \
"--outFileName {out_agg} --numberOfBins 30 --range 50000:900000 --hclust 2 --dpi 100 " \
"--plotType 3d --disable_bbox_tight " \
"--BED2 {root}/hicAggregateContacts/test_regions.bed".format(root=ROOT, out_agg=outfile_aggregate_3d.name)
test_image_agg_3d = ROOT + 'hicAggregateContacts/master_aggregate_3d.png'
hicexplorer.hicAggregateContacts.main(args.split())
res = compare_images(test_image_agg_3d, outfile_aggregate_3d.name, tolerance)
assert res is None, res
os.remove(outfile_aggregate_3d.name)
示例10: test_correlate
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_correlate():
outfile_heatmap = NamedTemporaryFile(suffix='heatmap.png', prefix='hicexplorer_test', delete=False)
outfile_scatter = NamedTemporaryFile(suffix='scatter.png', prefix='hicexplorer_test', delete=False)
args = "--matrices {} {} --labels 'first' 'second' " \
" --method spearman --log1p --colorMap jet "\
"--outFileNameHeatmap {} --outFileNameScatter {}".format(ROOT + "hicCorrectMatrix/small_test_matrix_ICEcorrected_chrUextra_chr3LHet.h5",
ROOT + "hicCorrectMatrix/small_test_matrix_ICEcorrected_chrUextra_chr3LHet.h5",
outfile_heatmap.name, outfile_scatter.name).split()
hicCorrelate.main(args)
res = compare_images(ROOT + "hicCorrelate" + '/heatmap.png', outfile_heatmap.name, tol=40)
assert res is None, res
res = compare_images(ROOT + "hicCorrelate" + '/scatter.png', outfile_scatter.name, tol=40)
assert res is None, res
os.remove(outfile_heatmap.name)
os.remove(outfile_scatter.name)
示例11: test_correlate_chromosomes
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_correlate_chromosomes():
outfile_heatmap = NamedTemporaryFile(suffix='heatmap.png', prefix='hicexplorer_test', delete=False)
outfile_scatter = NamedTemporaryFile(suffix='scatter.png', prefix='hicexplorer_test', delete=False)
args = "--matrices {} {} --labels 'first' 'second' " \
" --method spearman --log1p --colorMap jet "\
"--outFileNameHeatmap {} --outFileNameScatter {} " \
"--chromosomes chrUextra chr3LHet".format(ROOT + "hicCorrectMatrix/small_test_matrix_ICEcorrected_chrUextra_chr3LHet.h5",
ROOT + "hicCorrectMatrix/small_test_matrix_ICEcorrected_chrUextra_chr3LHet.h5",
outfile_heatmap.name, outfile_scatter.name).split()
hicCorrelate.main(args)
res = compare_images(ROOT + "hicCorrelate" + '/heatmap_chrom.png', outfile_heatmap.name, tol=40)
assert res is None, res
res = compare_images(ROOT + "hicCorrelate" + '/scatter_chrom.png', outfile_scatter.name, tol=40)
assert res is None, res
os.remove(outfile_heatmap.name)
os.remove(outfile_scatter.name)
示例12: test_one_viewpoint_per_file_batch_mode
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_one_viewpoint_per_file_batch_mode():
output_folder = mkdtemp(prefix="output_")
args = "-if {} -iff {} --range {} {} --outputFolder {} -psn {} -bm -t {}".format(ROOT + 'chicViewpoint/fileNames_one_matrix.txt',
ROOT + 'chicViewpoint/output_4',
200000, 200000,
output_folder, 1, 1).split()
chicPlotViewpoint.main(args)
res = compare_images(ROOT + 'chicPlotViewpoint/batchMode/one/Eya1_FL-E13-5_chr1_chr1_14300280.png',
output_folder + '/Eya1_FL-E13-5_chr1_chr1_14300280.png', tolerance)
assert res is None, res
res = compare_images(ROOT + 'chicPlotViewpoint/batchMode/one/Sox17_FL-E13-5_chr1_chr1_4487435.png',
output_folder + '/Sox17_FL-E13-5_chr1_chr1_4487435.png', tolerance)
assert res is None, res
res = compare_images(ROOT + 'chicPlotViewpoint/batchMode/one/Tfap2d_FL-E13-5_chr1_chr1_19093103.png',
output_folder + '/Tfap2d_FL-E13-5_chr1_chr1_19093103.png', tolerance)
assert res is None, res
assert set(os.listdir(ROOT + "chicPlotViewpoint/batchMode/one")
) == set(os.listdir(output_folder))
示例13: draw_and_compare
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def draw_and_compare(file, folder=IMG_FOLDER, tol=TOL,
draw=Diagram.draw, **params):
def decorator(func):
def wrapper():
true_path = os.path.join(folder, file)
test_path = os.path.join(folder, '.' + file)
draw(func(), path=test_path, **params)
test = compare_images(true_path, test_path, tol)
assert test is None
os.remove(test_path)
return wrapper
return decorator
示例14: make_comparer
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def make_comparer(path_expected: Path, path_actual: Path, *, tol: int):
def save_and_compare(basename, tolerance=None):
path_actual.mkdir(parents=True, exist_ok=True)
out_path = path_actual / f'{basename}.png'
pyplot.savefig(out_path, dpi=40)
pyplot.close()
if tolerance is None:
tolerance = tol
res = compare_images(
str(path_expected / f'{basename}.png'), str(out_path), tolerance
)
assert res is None, res
return save_and_compare
示例15: test_scatter_raw
# 需要导入模块: from matplotlib.testing import compare [as 别名]
# 或者: from matplotlib.testing.compare import compare_images [as 别名]
def test_scatter_raw(tmp_path):
pbmc = sc.datasets.pbmc68k_reduced()[:100].copy()
raw_pth = tmp_path / "raw.png"
x_pth = tmp_path / "X.png"
sc.pl.scatter(pbmc, color="HES4", basis="umap", use_raw=True)
plt.savefig(raw_pth, dpi=60)
plt.close()
sc.pl.scatter(pbmc, color="HES4", basis="umap", use_raw=False)
plt.savefig(x_pth, dpi=60)
plt.close()
comp = compare_images(str(raw_pth), str(x_pth), tol=5)
assert "Error" in comp, "Plots should change depending on use_raw."