Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 8, 2022
1 parent 1fe6228 commit 23a3ef4
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions tests/v2/test_0733-run_lengths.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ def test():
assert ak._v2.operations.structure.run_lengths(array).tolist() == [3, 2, 4, 1, 2]

array = ak._v2.Array([[3, 3, 3, 5], [5], [], [9, 9], [9, 9], [1, 3, 3]])
assert ak._v2.operations.structure.run_lengths(array).tolist() == [[3, 1], [1], [], [2], [2], [1, 2]]
assert ak._v2.operations.structure.run_lengths(array).tolist() == [
[3, 1],
[1],
[],
[2],
[2],
[1, 2],
]


@pytest.mark.skip(reason="ak.unflatten unimplemented")
def test_groupby():
Expand All @@ -28,7 +36,9 @@ def test_groupby():
sorted = array[ak._v2.operations.structure.argsort(array.x)]
assert sorted.x.tolist() == [1, 1, 1, 2, 2, 3]
assert ak._v2.operations.structure.run_lengths(sorted.x).tolist() == [3, 2, 1]
assert ak.unflatten(sorted, ak._v2.operations.structure.run_lengths(sorted.x)).tolist() == [
assert ak.unflatten(
sorted, ak._v2.operations.structure.run_lengths(sorted.x)
).tolist() == [
[{"x": 1, "y": 1.1}, {"x": 1, "y": 1.1}, {"x": 1, "y": 1.1}],
[{"x": 2, "y": 2.2}, {"x": 2, "y": 2.2}],
[{"x": 3, "y": 3.3}],
Expand All @@ -42,8 +52,13 @@ def test_groupby():
)
sorted = array[ak._v2.operations.structure.argsort(array.x)]
assert sorted.x.tolist() == [[1, 1, 2], [1, 2, 3]]
assert ak._v2.operations.structure.run_lengths(sorted.x).tolist() == [[2, 1], [1, 1, 1]]
counts = ak._v2.operations.structure.flatten(ak._v2.operations.structure.run_lengths(sorted.x), axis=None)
assert ak._v2.operations.structure.run_lengths(sorted.x).tolist() == [
[2, 1],
[1, 1, 1],
]
counts = ak._v2.operations.structure.flatten(
ak._v2.operations.structure.run_lengths(sorted.x), axis=None
)
assert ak.unflatten(sorted, counts, axis=-1).tolist() == [
[[{"x": 1, "y": 1.1}, {"x": 1, "y": 1.1}], [{"x": 2, "y": 2.2}]],
[[{"x": 1, "y": 1.1}], [{"x": 2, "y": 2.2}], [{"x": 3, "y": 3.3}]],
Expand All @@ -59,5 +74,11 @@ def test_onstrings1():


def test_onstrings2():
data = ak._v2.Array([["one", "one"], ["one", "two", "two"], ["three", "two", "two"]])
assert ak._v2.operations.structure.run_lengths(data).tolist() == [[2], [1, 2], [1, 2]]
data = ak._v2.Array(
[["one", "one"], ["one", "two", "two"], ["three", "two", "two"]]
)
assert ak._v2.operations.structure.run_lengths(data).tolist() == [
[2],
[1, 2],
[1, 2],
]

0 comments on commit 23a3ef4

Please sign in to comment.