本文整理匯總了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")