Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ refactoring: Don't let ak.to_list act on v2 arrays (finishing #1201). #1203

Merged
merged 1 commit into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/awkward/_v2/contents/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def __getitem__(self, where):
and where._parameters is not None
and (where._parameters.get("__array__") in ("string", "bytestring"))
):
return self._getitem_fields(ak.to_list(where))
return self._getitem_fields(ak._v2.operations.convert.to_list(where))

elif isinstance(where, ak._v2.contents.emptyarray.EmptyArray):
return where.toNumpyArray(np.int64)
Expand Down
6 changes: 2 additions & 4 deletions src/awkward/operations/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,10 @@ def to_list(array):
ak._v2.highlevel.Record,
ak._v2.contents.Content,
ak._v2.record.Record,
ak._v2.highlevel.ArrayBuilder,
),
):
return array.to_list()

elif isinstance(array, ak._v2.highlevel.ArrayBuilder):
return array.snapshot().to_list()
raise TypeError("use ak._v2.operations.convert.to_list for v2 arrays (for now)")

elif isinstance(array, dict):
return dict((n, to_list(x)) for n, x in array.items())
Expand Down
4 changes: 3 additions & 1 deletion tests/v2/test_0111-jagged-and-masked-getitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ def test_array_slice_1():
check_valid=True,
).layout
array = v1_to_v2(array)
assert to_list(array[ak.from_iter(["y", "x"], highlevel=False)]) == [
assert to_list(
array[ak._v2.operations.convert.from_iter(["y", "x"], highlevel=False)]
) == [
{"y": 1.1, "x": 1},
{"y": 2.2, "x": 2},
{"y": 3.3, "x": 3},
Expand Down