Skip to content

Commit ba9ddae

Browse files
committed
better docstringss
1 parent eb21cbf commit ba9ddae

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

icechunk-python/docs/docs/moving-chunks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ arr[:] = np.arange(24).reshape(6, 4)
124124
print("Original 6x4 array:")
125125
print(arr[:])
126126

127-
session.shift_array("/arr2d", (1, 0)) # Shift down 1 chunk
127+
session.shift_array("/arr2d", (1, 0)) # Shift +1 chunk along dim 0
128128
print("\nAfter shift (1, 0):")
129129
print(arr[:])
130130
```

icechunk-python/python/icechunk/session.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ def move(self, from_path: str, to_path: str) -> None:
180180
The current path of the node (e.g., "/data/raw").
181181
to_path : str
182182
The new path for the node (e.g., "/data/v1").
183+
184+
Examples
185+
--------
186+
>>> session = repo.rearrange_session("main")
187+
>>> session.move("/data/raw", "/data/v1")
188+
>>> session.commit("Renamed raw to v1")
183189
"""
184190
return self._session.move_node(from_path, to_path)
185191

@@ -230,14 +236,16 @@ def shift_array(
230236
array_path : str
231237
The path to the array to shift.
232238
chunk_offset : Iterable[int]
233-
The number of chunks to shift by in each dimension. Positive values
234-
shift right/down, negative values shift left/up.
239+
Offset added to each chunk coordinate. A chunk at index ``x`` moves
240+
to ``x + chunk_offset``. For a 3D array, ``chunk_offset=(1, 0, -2)``
241+
moves the chunk at ``(i, j, k)`` to ``(i+1, j, k-2)``.
235242
236243
Returns
237244
-------
238245
tuple[int, ...]
239-
The index shift in element space (chunk_offset * chunk_size for each dimension).
240-
Useful for knowing where to write new data after a shift.
246+
The shift in element space (``chunk_offset * chunk_size`` per dimension).
247+
For example, with ``chunk_size=10`` and ``chunk_offset=(2,)``, returns
248+
``(20,)`` — useful for slicing the region that needs new data.
241249
242250
Notes
243251
-----
@@ -261,8 +269,8 @@ def roll_array(
261269
array_path : str
262270
The path to the array to roll.
263271
chunk_offset : Iterable[int]
264-
The number of chunks to roll by in each dimension. Positive values
265-
roll right/down, negative values roll left/up.
272+
Offset added to each chunk coordinate (with wraparound). A chunk at
273+
index ``x`` moves to ``(x + chunk_offset) % num_chunks``.
266274
267275
Returns
268276
-------

0 commit comments

Comments
 (0)