-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement offsets slicing in
list_offsets
(#88)
- Loading branch information
1 parent
bd71cf8
commit b6cbaa4
Showing
3 changed files
with
73 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pyarrow as pa | ||
from arro3.compute import list_offsets | ||
|
||
|
||
def test_list_flatten(): | ||
list_arr = pa.array([[1, 2], [3, 4]]) | ||
out = pa.array(list_offsets(list_arr)) | ||
assert out == list_arr.offsets | ||
|
||
|
||
def test_list_flatten_sliced_end(): | ||
list_arr = pa.array([[1, 2], [3, 4]]) | ||
sliced = list_arr.slice(1, 1) | ||
|
||
out = pa.array(list_offsets(sliced, logical=False)) | ||
assert out == pa.array([2, 4], type=pa.int32()) | ||
|
||
out = pa.array(list_offsets(sliced, logical=True)) | ||
assert out == pa.array([0, 2], type=pa.int32()) | ||
|
||
|
||
def test_list_flatten_sliced_start(): | ||
list_arr = pa.array([[1, 2], [3, 4]]) | ||
sliced = list_arr.slice(0, 1) | ||
|
||
out = pa.array(list_offsets(sliced, logical=False)) | ||
assert out == pa.array([0, 2], type=pa.int32()) | ||
|
||
out = pa.array(list_offsets(sliced, logical=True)) | ||
assert out == pa.array([0, 2], type=pa.int32()) |