當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。