Ensure that scipy/numpy output is JSON-serializable

This commit is contained in:
Peter Dekkers 2024-05-25 09:48:29 +12:00 committed by Behdad Esfahbod
parent 524275ae14
commit a531041f3e

View File

@ -143,6 +143,9 @@ def min_cost_perfect_bipartite_matching_scipy(G):
n = len(G)
rows, cols = linear_sum_assignment(G)
assert (rows == list(range(n))).all()
# Convert numpy array and integer to Python types,
# to ensure that this is JSON-serializable.
cols = list(int(e) for e in cols)
return list(cols), matching_cost(G, cols)