Updated beets lib ( + mutagen ) and added unidecode

This commit is contained in:
rembo10
2014-03-31 16:21:50 -07:00
parent f0b4f2f3c8
commit 2ba476c6ef
256 changed files with 63907 additions and 8702 deletions
Executable → Regular
+36 -41
View File
@@ -61,7 +61,7 @@ You could then use that index matrix to loop over the original cost matrix
and calculate the smallest cost of the combinations::
n = len(matrix)
minval = sys.maxint
minval = sys.maxsize
for row in range(n):
cost = 0
for col in range(n):
@@ -163,7 +163,7 @@ large value. For example::
for row in matrix:
cost_row = []
for col in row:
cost_row += [sys.maxint - col]
cost_row += [sys.maxsize - col]
cost_matrix += [cost_row]
m = Munkres()
@@ -197,7 +197,7 @@ creation of the cost matrix::
import munkres
cost_matrix = munkres.make_cost_matrix(matrix,
lambda cost: sys.maxint - cost)
lambda cost: sys.maxsize - cost)
So, the above profit-calculation program can be recast as::
@@ -206,7 +206,7 @@ So, the above profit-calculation program can be recast as::
matrix = [[5, 9, 1],
[10, 3, 2],
[8, 7, 4]]
cost_matrix = make_cost_matrix(matrix, lambda cost: sys.maxint - cost)
cost_matrix = make_cost_matrix(matrix, lambda cost: sys.maxsize - cost)
m = Munkres()
indexes = m.compute(cost_matrix)
print_matrix(matrix, msg='Lowest cost through this matrix:')
@@ -277,6 +277,7 @@ __docformat__ = 'restructuredtext'
# ---------------------------------------------------------------------------
import sys
import copy
# ---------------------------------------------------------------------------
# Exports
@@ -289,7 +290,7 @@ __all__ = ['Munkres', 'make_cost_matrix']
# ---------------------------------------------------------------------------
# Info about the module
__version__ = "1.0.5.4"
__version__ = "1.0.6"
__author__ = "Brian Clapper, bmc@clapper.org"
__url__ = "http://software.clapper.org/munkres/"
__copyright__ = "(c) 2008 Brian M. Clapper"
@@ -458,8 +459,8 @@ class Munkres:
for i in range(n):
for j in range(n):
if (self.C[i][j] == 0) and \
(not self.col_covered[j]) and \
(not self.row_covered[i]):
(not self.col_covered[j]) and \
(not self.row_covered[i]):
self.marked[i][j] = 1
self.col_covered[j] = True
self.row_covered[i] = True
@@ -575,7 +576,7 @@ class Munkres:
def __find_smallest(self):
"""Find the smallest uncovered value in the matrix."""
minval = sys.maxint
minval = sys.maxsize
for i in range(self.n):
for j in range(self.n):
if (not self.row_covered[i]) and (not self.col_covered[j]):
@@ -595,8 +596,8 @@ class Munkres:
j = 0
while True:
if (self.C[i][j] == 0) and \
(not self.row_covered[i]) and \
(not self.col_covered[j]):
(not self.row_covered[i]) and \
(not self.col_covered[j]):
row = i
col = j
done = True
@@ -690,7 +691,7 @@ def make_cost_matrix(profit_matrix, inversion_function):
.. python::
cost_matrix = Munkres.make_cost_matrix(matrix, lambda x : sys.maxint - x)
cost_matrix = Munkres.make_cost_matrix(matrix, lambda x : sys.maxsize - x)
:Parameters:
profit_matrix : list of lists
@@ -721,7 +722,7 @@ def print_matrix(matrix, msg=None):
import math
if msg is not None:
print msg
print(msg)
# Calculate the appropriate format width.
width = 0
@@ -746,36 +747,31 @@ def print_matrix(matrix, msg=None):
if __name__ == '__main__':
matrices = [
# Square
([[400, 150, 400],
[400, 450, 600],
[300, 225, 300]],
850 # expected cost
),
# Square
([[400, 150, 400],
[400, 450, 600],
[300, 225, 300]],
850), # expected cost
# Rectangular variant
([[400, 150, 400, 1],
[400, 450, 600, 2],
[300, 225, 300, 3]],
452 # expected cost
),
# Rectangular variant
([[400, 150, 400, 1],
[400, 450, 600, 2],
[300, 225, 300, 3]],
452), # expected cost
# Square
([[10, 10, 8],
[ 9, 8, 1],
[ 9, 7, 4]],
18
),
# Rectangular variant
([[10, 10, 8, 11],
[ 9, 8, 1, 1],
[ 9, 7, 4, 10]],
15
),
]
# Square
([[10, 10, 8],
[9, 8, 1],
[9, 7, 4]],
18),
# Rectangular variant
([[10, 10, 8, 11],
[9, 8, 1, 1],
[9, 7, 4, 10]],
15)]
m = Munkres()
for cost_matrix, expected_total in matrices:
@@ -785,7 +781,6 @@ if __name__ == '__main__':
for r, c in indexes:
x = cost_matrix[r][c]
total_cost += x
print '(%d, %d) -> %d' % (r, c, x)
print 'lowest cost=%d' % total_cost
print('(%d, %d) -> %d' % (r, c, x))
print('lowest cost=%d' % total_cost)
assert expected_total == total_cost