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

Convert two assignments to augmented source code #531

Closed
elfring opened this issue Nov 21, 2021 · 2 comments
Closed

Convert two assignments to augmented source code #531

elfring opened this issue Nov 21, 2021 · 2 comments
Labels
enhancement Indicates new feature requests

Comments

@elfring
Copy link

elfring commented Nov 21, 2021

👀 Some source code analysis tools can help to find opportunities for improving software components.
💭 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 elfring added the enhancement Indicates new feature requests label Nov 21, 2021
@hameerabbasi
Copy link
Collaborator

Hey, would you be willing to make a PR?

@hameerabbasi
Copy link
Collaborator

This was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

2 participants