Skip to content

Commit a5d18dd

Browse files
committed
Rename 'grow' to 'extend'.
1 parent 4c23297 commit a5d18dd

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

tiled/adapters/zarr.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,28 @@ async def patch(
183183
self,
184184
data: NDArray[Any],
185185
slice: Tuple[slice | int, ...],
186-
grow: bool = False,
186+
extend: bool = False,
187187
) -> Tuple[Tuple[int, ...], Tuple[Tuple[int, ...], ...]]:
188188
"""
189-
Write data into a slice of the array, maybe growing it.
189+
Write data into a slice of the array, maybe extending it.
190190
191-
If the specified slice does not fit into the array, and grow=True, the
192-
array will be resize (grown, never shrunk) to fit it. The new shape is
193-
returned.
191+
If the specified slice does not fit into the array, and extend=True, the
192+
array will be resized (expanded, never shrunk) to fit it.
193+
194+
Parameters
195+
----------
196+
data : array-like
197+
slice :
198+
Where to place the new data
199+
extend : bool
200+
If slice does not fit wholly within the shape of the existing array,
201+
reshape (expand) it to fit if this is True.
202+
203+
Raises
204+
------
205+
ValueError :
206+
If slice does not fit wholly with the shape of the existing array
207+
and expand is False
194208
"""
195209
current_shape = self._array.shape
196210
new_shape = list(current_shape)
@@ -201,7 +215,7 @@ async def patch(
201215
new_shape[i] = max(new_shape[i], s.stop)
202216
new_shape_tuple = tuple(new_shape)
203217
if new_shape_tuple != current_shape:
204-
if grow:
218+
if extend:
205219
# Resize the Zarr array to accommodate new data
206220
self._array.resize(new_shape_tuple)
207221
else:

tiled/client/array.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def write_block(self, array, block, slice=...):
179179
)
180180
)
181181

182-
def patch(self, array: NDArray, slice: NDSlice, grow=False):
182+
def patch(self, array: NDArray, slice: NDSlice, extend=False):
183183
"""
184184
Write data
185185
@@ -189,13 +189,13 @@ def patch(self, array: NDArray, slice: NDSlice, grow=False):
189189
The data to write
190190
slice : NDSlice
191191
Where to place this data in the array
192-
grow : bool
193-
Grow the array shape to fit the new slice, if necessary
192+
extend : bool
193+
Extend the array shape to fit the new slice, if necessary
194194
"""
195195
array_ = numpy.ascontiguousarray(array)
196196
params = params_from_slice(slice)
197197
params["shape"] = ",".join(map(str, array_.shape))
198-
params["grow"] = bool(grow)
198+
params["extend"] = bool(extend)
199199
handle_error(
200200
self.context.http_client.patch(
201201
self.item["links"]["full"],

tiled/server/router.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ async def patch_array_full(
12961296
request: Request,
12971297
slice=Depends(slice_),
12981298
shape=Depends(shape_param),
1299-
grow: bool = False,
1299+
extend: bool = False,
13001300
entry=SecureEntry(
13011301
scopes=["write:data"],
13021302
structure_families={StructureFamily.array},
@@ -1316,7 +1316,7 @@ async def patch_array_full(
13161316
media_type = request.headers["content-type"]
13171317
deserializer = deserialization_registry.dispatch("array", media_type)
13181318
data = await ensure_awaitable(deserializer, body, dtype, shape)
1319-
await ensure_awaitable(entry.patch, data, slice, grow)
1319+
await ensure_awaitable(entry.patch, data, slice, extend)
13201320
return json_or_msgpack(request, None)
13211321

13221322

0 commit comments

Comments
 (0)