zarr-python icon indicating copy to clipboard operation
zarr-python copied to clipboard

Increase the usage of augmented assignment statements

Open elfring opened this issue 4 years ago • 3 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/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):

elfring avatar Nov 04 '21 17:11 elfring

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

joshmoore avatar Nov 05 '21 15:11 joshmoore

:thought_balloon: Can the presented changes be integrated also directly?

elfring avatar Nov 05 '21 15:11 elfring

A PR with these changes would be fine, yes.

joshmoore avatar Nov 08 '21 11:11 joshmoore