Skip to content

Commit

Permalink
refactor "test" to a test
Browse files Browse the repository at this point in the history
  • Loading branch information
frrad committed Aug 31, 2024
1 parent 2aa580c commit 0bdbbd5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 0 additions & 10 deletions pulp/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,3 @@ def col_based_arrays(self):
lenBase.append(len(elemBase) - startsBase[-1])
startsBase.append(len(elemBase))
return numEls, startsBase, lenBase, indBase, elemBase


if __name__ == "__main__":
"""unit test"""
rows = list(range(10))
cols = list(range(50, 60))
mat = Matrix(rows, cols)
mat.add(1, 52, "item")
mat.add(2, 54, "stuff")
print(mat.col_based_arrays())
16 changes: 16 additions & 0 deletions pulp/tests/test_sparse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pulp.sparse import Matrix


def test_sparse():
rows = list(range(10))
cols = list(range(50, 60))
mat = Matrix(rows, cols)
mat.add(1, 52, "item")
mat.add(2, 54, "stuff")
assert mat.col_based_arrays() == (
2,
[0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2],
[0, 0, 1, 0, 1, 0, 0, 0, 0, 0],
[1, 2],
["item", "stuff"],
)

0 comments on commit 0bdbbd5

Please sign in to comment.