当前位置: 首页>>代码示例>>Python>>正文


Python cbook._str_equal方法代码示例

本文整理汇总了Python中matplotlib.cbook._str_equal方法的典型用法代码示例。如果您正苦于以下问题:Python cbook._str_equal方法的具体用法?Python cbook._str_equal怎么用?Python cbook._str_equal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.cbook的用法示例。


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

示例1: score_weight

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import _str_equal [as 别名]
def score_weight(self, weight1, weight2):
        """
        Returns a match score between *weight1* and *weight2*.

        The result is 0.0 if both weight1 and weight 2 are given as strings
        and have the same value.

        Otherwise, the result is the absolute value of the difference between
        the CSS numeric values of *weight1* and *weight2*, normalized between
        0.05 and 1.0.
        """
        # exact match of the weight names, e.g. weight1 == weight2 == "regular"
        if cbook._str_equal(weight1, weight2):
            return 0.0
        w1 = weight1 if isinstance(weight1, Number) else weight_dict[weight1]
        w2 = weight2 if isinstance(weight2, Number) else weight_dict[weight2]
        return 0.95 * (abs(w1 - w2) / 1000) + 0.05 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:19,代码来源:font_manager.py

示例2: validate_hist_bins

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import _str_equal [as 别名]
def validate_hist_bins(s):
    if cbook._str_equal(s, "auto"):
        return s
    try:
        return int(s)
    except (TypeError, ValueError):
        pass

    try:
        return validate_floatlist(s)
    except ValueError:
        pass

    raise ValueError("'hist.bins' must be 'auto', an int or " +
                     "a sequence of floats") 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:17,代码来源:rcsetup.py


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