# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [conda env:phathom]
#     language: python
#     name: conda-env-phathom-py
# ---

import numpy as np
from lapsolver import solve_dense
from scipy.optimize import linear_sum_assignment

N = 100
costs = np.random.randint(0, 100, (N, N))

# %%timeit -n 100
rows_lapsolver, cols_lapsolver = solve_dense(costs)
rows_lapsolver

# %%timeit -n 100
rows_scipy, cols_scipy = linear_sum_assignment(costs)

rows_lapsolver, cols_lapsolver = solve_dense(costs)
rows_scipy, cols_scipy = solve_dense(costs)
assert np.all(rows_lapsolver == rows_scipy)
assert np.all(cols_lapsolver == cols_scipy)



StarcoderdataJupyterScriptsDedupFiltered