Skip to content

Increase the usage of augmented assignment statements #864

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

Open
elfring opened this issue Nov 4, 2021 · 3 comments
Open

Increase the usage of augmented assignment statements #864

elfring opened this issue Nov 4, 2021 · 3 comments

Comments

@elfring
Copy link

elfring commented Nov 4, 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/zarr/convenience.py b/zarr/convenience.py
index 18b59a7..bbd87f9 100644
--- a/zarr/convenience.py
+++ b/zarr/convenience.py
@@ -576,9 +576,9 @@ def copy_store(source, dest, source_path='', dest_path='', excludes=None,
     source_path = normalize_storage_path(source_path)
     dest_path = normalize_storage_path(dest_path)
     if source_path:
-        source_path = source_path + '/'
+        source_path += '/'
     if dest_path:
-        dest_path = dest_path + '/'
+        dest_path += '/'
 
     # normalize excludes and includes
     if excludes is None:
@@ -631,7 +631,7 @@ def copy_store(source, dest, source_path='', dest_path='', excludes=None,
                 # create a descriptive label for this operation
                 descr = source_key
                 if dest_key != source_key:
-                    descr = descr + ' -> ' + dest_key
+                    descr += ' -> ' + dest_key
 
                 # decide what to do
                 do_copy = True
diff --git a/zarr/indexing.py b/zarr/indexing.py
index 2e9f7c8..c036dc0 100644
--- a/zarr/indexing.py
+++ b/zarr/indexing.py
@@ -443,7 +443,7 @@ class Order:
 def wraparound_indices(x, dim_len):
     loc_neg = x < 0
     if np.any(loc_neg):
-        x[loc_neg] = x[loc_neg] + dim_len
+        x[loc_neg] += dim_len
 
 
 def boundscheck_indices(x, dim_len):
@joshmoore
Copy link
Member

Thanks for the suggestion, @elfring. Are you up for opening the PR?

@elfring
Copy link
Author

elfring commented Nov 5, 2021

💭 Can the presented changes be integrated also directly?

@joshmoore
Copy link
Member

A PR with these changes would be fine, yes.

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

No branches or pull requests

2 participants