Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sp.issparse instead of type check in tests #126

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tests/test_bipartite_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_empty(self):

matching = maximum_bipartite_matching(adjacency, nodes1, nodes2)

self.assertIsInstance(matching, sp.spmatrix)
self.assertTrue(sp.issparse(matching))
self.assertIsNot(matching, adjacency)
self.assertEqual(matching.nnz, 0)
self.assertEqual(matching.shape, (degree, degree))
Expand All @@ -65,7 +65,7 @@ def test_complete_bipartite(self):

matching = maximum_bipartite_matching(adjacency, nodes1, nodes2)

self.assertIsInstance(matching, sp.spmatrix)
self.assertTrue(sp.issparse(matching))
self.assertIsNot(matching, adjacency)
self.assertEqual(matching.shape, (degree, degree))
self.assert_is_unweighted_matching(matching)
Expand All @@ -85,7 +85,7 @@ def test_simple(self):

matching = maximum_bipartite_matching(adjacency, nodes1, nodes2)

self.assertIsInstance(matching, sp.spmatrix)
self.assertTrue(sp.issparse(matching))
self.assertIsNot(matching, adjacency)
self.assertEqual(matching.shape, (degree, degree))
self.assert_is_unweighted_matching(matching)
Expand All @@ -103,7 +103,7 @@ def test_simple_2(self):

matching = maximum_bipartite_matching(adjacency, nodes1, nodes2)

self.assertIsInstance(matching, sp.spmatrix)
self.assertTrue(sp.issparse(matching))
self.assertIsNot(matching, adjacency)
self.assertEqual(matching.shape, (6, 6))
self.assert_is_unweighted_matching(matching)
Expand All @@ -121,7 +121,7 @@ def test_random(self):

matching = maximum_bipartite_matching(adjacency, nodes1, nodes2)

self.assertIsInstance(matching, sp.spmatrix)
self.assertTrue(sp.issparse(matching))
self.assertIsNot(matching, adjacency)
self.assertEqual(matching.shape, adjacency.shape)
self.assert_is_unweighted_matching(matching)
Expand All @@ -132,7 +132,7 @@ def test_random_csr_matrix(self):

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

self.assertIsInstance(matching, sp.spmatrix)
self.assertTrue(sp.issparse(matching))
self.assertIsNot(matching, adjacency)
self.assertEqual(matching.shape, adjacency.shape)
self.assert_is_unweighted_matching(matching)
Expand All @@ -143,7 +143,7 @@ def test_random_csr_array(self):

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

self.assertIsInstance(matching, sp.spmatrix)
self.assertTrue(sp.issparse(matching))
self.assertIsNot(matching, adjacency)
self.assertEqual(matching.shape, adjacency.shape)
self.assert_is_unweighted_matching(matching)
Expand All @@ -154,7 +154,7 @@ def test_random_csc_array(self):

matching = maximum_bipartite_matching(sp.csc_array(adjacency), nodes1, nodes2)

self.assertIsInstance(matching, sp.spmatrix)
self.assertTrue(sp.issparse(matching))
self.assertIsNot(matching, adjacency)
self.assertEqual(matching.shape, adjacency.shape)
self.assert_is_unweighted_matching(matching)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_min_cost_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_scipy(self):
[0.0, 0.0, 0.0, 0.0, 0.0, 2.0],
]
)
self.assertIsInstance(sol, sp.spmatrix)
self.assertTrue(sp.issparse(sol))
self.assertTrue(check_solution_scipy(sol, [candidate]))

@unittest.skipIf(nx is None, "networkx is not installed")
Expand Down
Loading