• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python compare.comparable_formats函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.testing.compare.comparable_formats函数的典型用法代码示例。如果您正苦于以下问题:Python comparable_formats函数的具体用法?Python comparable_formats怎么用?Python comparable_formats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了comparable_formats函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _mark_xfail_if_format_is_uncomparable

def _mark_xfail_if_format_is_uncomparable(extension):
    if isinstance(extension, str):
        will_fail = extension not in comparable_formats()
    else:
        # Extension might be a pytest marker instead of a plain string.
        will_fail = extension.args[0] not in comparable_formats()
    if will_fail:
        fail_msg = 'Cannot compare %s files on this system' % extension
        import pytest
        return pytest.mark.xfail(extension, reason=fail_msg, strict=False,
                                 raises=ImageComparisonFailure)
    else:
        return extension
开发者ID:mspacek,项目名称:matplotlib,代码行数:13,代码来源:decorators.py


示例2: test

    def test(self):
        baseline_dir, result_dir = _image_directories(self._func)

        for fignum, baseline in zip(plt.get_fignums(), self._baseline_images):
            for extension in self._extensions:
                will_fail = not extension in comparable_formats()
                if will_fail:
                    fail_msg = 'Cannot compare %s files on this system' % extension
                else:
                    fail_msg = 'No failure expected'

                orig_expected_fname = os.path.join(baseline_dir, baseline) + '.' + extension
                if extension == 'eps' and not os.path.exists(orig_expected_fname):
                    orig_expected_fname = os.path.join(baseline_dir, baseline) + '.pdf'
                expected_fname = make_test_filename(os.path.join(
                    result_dir, os.path.basename(orig_expected_fname)), 'expected')
                actual_fname = os.path.join(result_dir, baseline) + '.' + extension
                if os.path.exists(orig_expected_fname):
                    shutil.copyfile(orig_expected_fname, expected_fname)
                else:
                    will_fail = True
                    fail_msg = (
                        "Do not have baseline image {0} because this "
                        "file does not exist: {1}".format(
                            expected_fname,
                            orig_expected_fname
                        )
                    )

                @knownfailureif(
                    will_fail, fail_msg,
                    known_exception_class=ImageComparisonFailure)
                def do_test():
                    figure = plt.figure(fignum)

                    if self._remove_text:
                        self.remove_text(figure)

                    figure.savefig(actual_fname, **self._savefig_kwarg)

                    err = compare_images(expected_fname, actual_fname,
                                         self._tol, in_decorator=True)

                    try:
                        if not os.path.exists(expected_fname):
                            raise ImageComparisonFailure(
                                'image does not exist: %s' % expected_fname)

                        if err:
                            raise ImageComparisonFailure(
                                'images not close: %(actual)s vs. %(expected)s '
                                '(RMS %(rms).3f)'%err)
                    except ImageComparisonFailure:
                        if not check_freetype_version(self._freetype_version):
                            raise KnownFailureTest(
                                "Mismatched version of freetype.  Test requires '%s', you have '%s'" %
                                (self._freetype_version, ft2font.__freetype_version__))
                        raise

                yield (do_test,)
开发者ID:717524640,项目名称:matplotlib,代码行数:60,代码来源:decorators.py


示例3: mark_extension

    def mark_extension(extension):
        ''' Mark whether extension is supported. '''
        __tracebackhide__ = True  # pylint: disable=unused-variable

        if extension not in mplcmp.comparable_formats():
            raise unittest.SkipTest('Cannot compare {} files in this '
                                    'system'.format(extension))
开发者ID:gaomy3832,项目名称:easypyplot,代码行数:7,代码来源:__init__.py


示例4: _xfail_if_format_is_uncomparable

def _xfail_if_format_is_uncomparable(extension):
    will_fail = extension not in comparable_formats()
    if will_fail:
        fail_msg = 'Cannot compare %s files on this system' % extension
    else:
        fail_msg = 'No failure expected'

    return _knownfailureif(will_fail, fail_msg,
                           known_exception_class=ImageComparisonFailure)
开发者ID:mspacek,项目名称:matplotlib,代码行数:9,代码来源:decorators.py


示例5: test

    def test(self):
        baseline_dir, result_dir = _image_directories(self._func)

        for fignum, baseline in zip(plt.get_fignums(), self._baseline_images):
            figure = plt.figure(fignum)

            for extension in self._extensions:
                will_fail = not extension in comparable_formats()
                if will_fail:
                    fail_msg = 'Cannot compare %s files on this system' % extension
                else:
                    fail_msg = 'No failure expected'

                orig_expected_fname = os.path.join(baseline_dir, baseline) + '.' + extension
                if extension == 'eps' and not os.path.exists(orig_expected_fname):
                    orig_expected_fname = os.path.join(baseline_dir, baseline) + '.pdf'
                expected_fname = os.path.join(result_dir, 'expected-' + os.path.basename(orig_expected_fname))
                actual_fname = os.path.join(result_dir, baseline) + '.' + extension
                if os.path.exists(orig_expected_fname):
                    shutil.copyfile(orig_expected_fname, expected_fname)
                else:
                    will_fail = True
                    fail_msg = 'Do not have baseline image %s' % expected_fname

                @knownfailureif(
                    will_fail, fail_msg,
                    known_exception_class=ImageComparisonFailure)
                def do_test():
                    figure.savefig(actual_fname)

                    err = compare_images(expected_fname, actual_fname, self._tol, in_decorator=True)

                    if not os.path.exists(expected_fname):
                        raise ImageComparisonFailure(
                            'image does not exist: %s' % expected_fname)

                    if err:
                        raise ImageComparisonFailure(
                            'images not close: %(actual)s vs. %(expected)s '
                            '(RMS %(rms).3f)'%err)

                yield (do_test,)
开发者ID:AlexSzatmary,项目名称:matplotlib,代码行数:42,代码来源:decorators.py


示例6: _xfail_if_format_is_uncomparable

def _xfail_if_format_is_uncomparable(extension):
    import pytest
    return pytest.mark.xfail(
        extension not in comparable_formats(),
        reason='Cannot compare {} files on this system'.format(extension),
        raises=ImageComparisonFailure, strict=True)
开发者ID:DanHickstein,项目名称:matplotlib,代码行数:6,代码来源:decorators.py



注:本文中的matplotlib.testing.compare.comparable_formats函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python compare.compare_images函数代码示例发布时间:2022-05-27
下一篇:
Python style.use函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap