當前位置: 首頁>>代碼示例>>Python>>正文


Python compare.compare_images方法代碼示例

本文整理匯總了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) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:27,代碼來源:test_compare_images.py

示例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) 
開發者ID:deeptools,項目名稱:pyGenomeTracks,代碼行數:18,代碼來源:test_hiCMatrixTracks.py

示例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) 
開發者ID:deeptools,項目名稱:pyGenomeTracks,代碼行數:18,代碼來源:test_hiCMatrixTracks.py

示例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) 
開發者ID:deeptools,項目名稱:pyGenomeTracks,代碼行數:19,代碼來源:test_hiCMatrixTracks.py

示例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) 
開發者ID:deeptools,項目名稱:HiCExplorer,代碼行數:18,代碼來源:test_hicAggregateContacts.py

示例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) 
開發者ID:deeptools,項目名稱:HiCExplorer,代碼行數:18,代碼來源:test_hicAggregateContacts.py

示例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) 
開發者ID:deeptools,項目名稱:HiCExplorer,代碼行數:26,代碼來源:test_hicAggregateContacts.py

示例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) 
開發者ID:deeptools,項目名稱:HiCExplorer,代碼行數:26,代碼來源:test_hicAggregateContacts.py

示例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) 
開發者ID:deeptools,項目名稱:HiCExplorer,代碼行數:19,代碼來源:test_hicAggregateContacts.py

示例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) 
開發者ID:deeptools,項目名稱:HiCExplorer,代碼行數:20,代碼來源:test_hicCorrelate.py

示例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) 
開發者ID:deeptools,項目名稱:HiCExplorer,代碼行數:21,代碼來源:test_hicCorrelate.py

示例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)) 
開發者ID:deeptools,項目名稱:HiCExplorer,代碼行數:22,代碼來源:test_chicPlotViewpoint.py

示例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 
開發者ID:oxford-quantum-group,項目名稱:discopy,代碼行數:14,代碼來源:test_drawing.py

示例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 
開發者ID:theislab,項目名稱:scanpy,代碼行數:16,代碼來源:conftest.py

示例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." 
開發者ID:theislab,項目名稱:scanpy,代碼行數:17,代碼來源:test_plotting.py


注:本文中的matplotlib.testing.compare.compare_images方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。