sparse icon indicating copy to clipboard operation
sparse copied to clipboard

Convert two assignments to augmented source code

Open elfring opened this issue 2 years ago • 0 comments

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of augmented assignment statements accordingly.

diff --git a/sparse/_compressed/indexing.py b/sparse/_compressed/indexing.py
index df35a6c..abe270a 100644
--- a/sparse/_compressed/indexing.py
+++ b/sparse/_compressed/indexing.py
@@ -151,7 +151,7 @@ def getitem(x, key):
             indptr = np.empty(shape[0] + 1, dtype=x.indptr.dtype)
             indptr[0] = 0
             np.cumsum(np.bincount(uncompressed, minlength=shape[0]), out=indptr[1:])
-            indices = indices % size
+            indices %= size
 
     arg = (data, indices, indptr)
 
diff --git a/sparse/_slicing.py b/sparse/_slicing.py
index 4e46244..7169ead 100644
--- a/sparse/_slicing.py
+++ b/sparse/_slicing.py
@@ -40,7 +40,7 @@ def normalize_index(idx, shape):
             continue
         else:
             n_sliced_dims += 1
-    idx = idx + (slice(None),) * (len(shape) - n_sliced_dims)
+    idx += (slice(None),) * (len(shape) - n_sliced_dims)
     if len([i for i in idx if i is not None]) > len(shape):
         raise IndexError("Too many indices for array")
 

elfring avatar Nov 21 '21 17:11 elfring