MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / score_weight

Method score_weight

lib/matplotlib/font_manager.py:1420–1436  ·  view source on GitHub ↗

Return 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

(self, weight1, weight2)

Source from the content-addressed store, hash-verified

1418 return abs(stretchval1 - stretchval2) / 1000.0
1419
1420 def score_weight(self, weight1, weight2):
1421 """
1422 Return a match score between *weight1* and *weight2*.
1423
1424 The result is 0.0 if both weight1 and weight 2 are given as strings
1425 and have the same value.
1426
1427 Otherwise, the result is the absolute value of the difference between
1428 the CSS numeric values of *weight1* and *weight2*, normalized between
1429 0.05 and 1.0.
1430 """
1431 # exact match of the weight names, e.g. weight1 == weight2 == "regular"
1432 if cbook._str_equal(weight1, weight2):
1433 return 0.0
1434 w1 = _normalize_weight(weight1)
1435 w2 = _normalize_weight(weight2)
1436 return 0.95 * (abs(w1 - w2) / 1000) + 0.05
1437
1438 def score_size(self, size1, size2):
1439 """

Callers 2

_findfont_cachedMethod · 0.95
test_score_weightFunction · 0.80

Calls 1

_normalize_weightFunction · 0.85

Tested by 1

test_score_weightFunction · 0.64