Skip to content

Commit

Permalink
fix minor bug in indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
cortespea committed Dec 15, 2023
1 parent e5b2226 commit 574919d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,13 @@ def test_sparse_array_indexing():
sa[[0, 1]] = [[[0, 1]]] # Broadcast 3-d array to 2-d

sa[[0, 1], 0] = [[0, 1]] # Reduce dimensions

# Check closed and open slices
sa = SparseArray.from_shape([5, 5])
sa[0:3, :] = 1
arr = np.zeros([5, 5])
arr[0:3, :] = 1
assert (sa == arr).all()

def test_sparse_array_boolean_indexing():
for dtype in (float, bool):
Expand Down
2 changes: 1 addition & 1 deletion thermosteam/base/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ def __setitem__(self, index, value):
rows = [rows[i] for i in default_range(m, len(rows))]
if n.__class__ is slice:
if n == open_slice:
self[:] = value
for i in rows: i[:] = value
return
else:
n = default_range(n, self.vector_size)
Expand Down

0 comments on commit 574919d

Please sign in to comment.