Skip to content

Commit

Permalink
Change csc/csc_matrix to array
Browse files Browse the repository at this point in the history
  • Loading branch information
torressa committed Sep 28, 2023
1 parent 6de867a commit b399145
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/gurobi_optimods/bipartite_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _maximum_bipartite_matching_scipy(adjacency, nodes1, nodes2, create_env):
indptr = np.arange(0, 2 * from_arc.shape[0] + 2, 2)
ones = np.ones(from_arc.shape)
data = np.column_stack((ones * -1.0, ones)).reshape(-1, order="C")
A = sp.csc_matrix((data, indices, indptr))
A = sp.csc_array((data, indices, indptr))

# Solve model with gurobi, return cost and flows
x = model.addMVar(A.shape[1], lb=0, ub=capacity)
Expand Down
2 changes: 1 addition & 1 deletion src/gurobi_optimods/min_cost_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def min_cost_flow_scipy(
ones = np.ones(edge_source.shape)
data = np.column_stack((ones * -1.0, ones)).reshape(-1, order="C")

A = sp.csc_matrix((data, indices, indptr))
A = sp.csc_array((data, indices, indptr))

logger.info("Solving min-cost flow with {0} nodes and {1} edges".format(*A.shape))

Expand Down
4 changes: 2 additions & 2 deletions tests/test_bipartite_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ def test_random(self):
self.assertEqual(matching.shape, adjacency.shape)
self.assert_is_unweighted_matching(matching)

def test_random_csr_matrix(self):
def test_random_csr_array(self):
# Property test for matchings on random graphs
adjacency, nodes1, nodes2 = random_bipartite(n1=8, n2=7, p=0.5, seed=98634)

matching = maximum_bipartite_matching(sp.csr_matrix(adjacency), nodes1, nodes2)
matching = maximum_bipartite_matching(sp.csr_array(adjacency), nodes1, nodes2)

self.assertIsInstance(matching, sp.spmatrix)
self.assertIsNot(matching, adjacency)
Expand Down

0 comments on commit b399145

Please sign in to comment.