Skip to content

Commit 022bb3c

Browse files
Apply ruff/Pylint rule PLR6104
PLR6104 Use `+=`, `*=`, `/=` to perform an augmented assignment directly
1 parent 57db7a9 commit 022bb3c

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/zarr/api/asynchronous.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ async def consolidate_metadata(
173173
store_path = await make_store_path(store)
174174

175175
if path is not None:
176-
store_path = store_path / path
176+
store_path /= path
177177

178178
group = await AsyncGroup.open(store_path, zarr_format=zarr_format, use_consolidated=False)
179179
group.store_path.store._check_writable()
@@ -294,7 +294,7 @@ async def open(
294294
store_path = await make_store_path(store, mode=mode, storage_options=storage_options)
295295

296296
if path is not None:
297-
store_path = store_path / path
297+
store_path /= path
298298

299299
if "shape" not in kwargs and mode in {"a", "w", "w-"}:
300300
try:
@@ -403,7 +403,7 @@ async def save_array(
403403
mode = kwargs.pop("mode", None)
404404
store_path = await make_store_path(store, mode=mode, storage_options=storage_options)
405405
if path is not None:
406-
store_path = store_path / path
406+
store_path /= path
407407
new = await AsyncArray.create(
408408
store_path,
409409
zarr_format=zarr_format,
@@ -584,7 +584,7 @@ async def group(
584584

585585
store_path = await make_store_path(store, mode=mode, storage_options=storage_options)
586586
if path is not None:
587-
store_path = store_path / path
587+
store_path /= path
588588

589589
if chunk_store is not None:
590590
warnings.warn("chunk_store is not yet implemented", RuntimeWarning, stacklevel=2)
@@ -699,7 +699,7 @@ async def open_group(
699699

700700
store_path = await make_store_path(store, mode=mode, storage_options=storage_options)
701701
if path is not None:
702-
store_path = store_path / path
702+
store_path /= path
703703

704704
if attributes is None:
705705
attributes = {}
@@ -885,7 +885,7 @@ async def create(
885885

886886
store_path = await make_store_path(store, mode=mode, storage_options=storage_options)
887887
if path is not None:
888-
store_path = store_path / path
888+
store_path /= path
889889

890890
return await AsyncArray.create(
891891
store_path,
@@ -1073,7 +1073,7 @@ async def open_array(
10731073
mode = kwargs.pop("mode", None)
10741074
store_path = await make_store_path(store, mode=mode)
10751075
if path is not None:
1076-
store_path = store_path / path
1076+
store_path /= path
10771077

10781078
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
10791079

src/zarr/codecs/sharding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def create_empty(
252252
def __setitem__(self, chunk_coords: ChunkCoords, value: Buffer) -> None:
253253
chunk_start = len(self.buf)
254254
chunk_length = len(value)
255-
self.buf = self.buf + value
255+
self.buf += value
256256
self.index.set_chunk_slice(chunk_coords, slice(chunk_start, chunk_start + chunk_length))
257257

258258
def __delitem__(self, chunk_coords: ChunkCoords) -> None:

src/zarr/core/indexing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ def check(a: npt.NDArray[Any]) -> Order:
673673
def wraparound_indices(x: npt.NDArray[Any], dim_len: int) -> None:
674674
loc_neg = x < 0
675675
if np.any(loc_neg):
676-
x[loc_neg] = x[loc_neg] + dim_len
676+
x[loc_neg] += dim_len
677677

678678

679679
def boundscheck_indices(x: npt.NDArray[Any], dim_len: int) -> None:
@@ -998,8 +998,8 @@ def __init__(
998998
if stop < 0:
999999
stop = dim_numchunks + stop
10001000

1001-
start = start * dim_chunk_size
1002-
stop = stop * dim_chunk_size
1001+
start *= dim_chunk_size
1002+
stop *= dim_chunk_size
10031003
slice_ = slice(start, stop)
10041004

10051005
else:

tests/v3/test_codecs/test_sharding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_sharding_partial_overwrite(
193193
read_data = a[0:10, 0:10, 0:10]
194194
assert np.array_equal(data, read_data)
195195

196-
data = data + 10
196+
data += 10
197197
a[:10, :10, :10] = data
198198
read_data = a[0:10, 0:10, 0:10]
199199
assert np.array_equal(data, read_data)

0 commit comments

Comments
 (0)