本文整理汇总了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
示例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")