Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Sep 19, 2024
1 parent da434dc commit 5ed2072
Showing 1 changed file with 50 additions and 18 deletions.
68 changes: 50 additions & 18 deletions tests-cuda/test_3140_cuda_slicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,63 +705,95 @@ def test_simple_slice_gpu():

def test_simple_slice_cpu1():
arr = ak.Array([[1, 2, 3], [0], [4, 5]])
out = arr[:,1:]
expected = [[2, 3], [], [5]]
out = arr[:, 1:]
expected = [[2, 3], [], [5]]
result = out.tolist()
cp.testing.assert_array_list_equal(result, expected, err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}")
cp.testing.assert_array_list_equal(
result,
expected,
err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}",
)


def test_simple_slice_gpu1():
arr = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
out = arr[:,1:]
expected = [[2, 3], [], [5]]
out = arr[:, 1:]
expected = [[2, 3], [], [5]]
result = out.tolist()
cp.testing.assert_array_list_equal(result, expected, err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}")
cp.testing.assert_array_list_equal(
result,
expected,
err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}",
)


def test_simple_slice_cpu2():
arr = ak.Array([[1, 2, 3], [0], [4, 5]])
out = arr[:,:1]
out = arr[:, :1]
expected = [[1], [0], [4]]
result = out.tolist()
cp.testing.assert_array_list_equal(result, expected, err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}")
cp.testing.assert_array_list_equal(
result,
expected,
err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}",
)


def test_simple_slice_gpu2():
arr = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
out = arr[:,:1]
out = arr[:, :1]
expected = [[1], [0], [4]]
result = out.tolist()
cp.testing.assert_array_list_equal(result, expected, err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}")
cp.testing.assert_array_list_equal(
result,
expected,
err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}",
)


def test_simple_slice_cpu3():
arr = ak.Array([[1, 2, 3], [0], [4, 5]])
out = arr[:,1::2]
out = arr[:, 1::2]
expected = [[2], [], [5]]
result = out.tolist()
cp.testing.assert_array_list_equal(result, expected, err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}")
cp.testing.assert_array_list_equal(
result,
expected,
err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}",
)


def test_simple_slice_gpu3():
arr = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
out = arr[:,1::2]
out = arr[:, 1::2]
expected = [[2], [], [5]]
result = out.tolist()
cp.testing.assert_array_list_equal(result, expected, err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}")
cp.testing.assert_array_list_equal(
result,
expected,
err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}",
)


def test_simple_slice_cpu4():
arr = ak.Array([[1, 2, 3], [0], [4, 5]])
out = arr[:,::-1]
out = arr[:, ::-1]
expected = [[3, 2, 1], [0], [5, 4]]
result = out.tolist()
cp.testing.assert_array_list_equal(result, expected, err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}")
cp.testing.assert_array_list_equal(
result,
expected,
err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}",
)


def test_simple_slice_gpu4():
arr = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
out = arr[:,::-1]
out = arr[:, ::-1]
expected = [[3, 2, 1], [0], [5, 4]]
result = out.tolist()
cp.testing.assert_array_list_equal(result, expected, err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}")
cp.testing.assert_array_list_equal(
result,
expected,
err_msg=f"Slice of [[1, 2, 3], [0], [4, 5]] should be {expected}, but got {result}",
)

0 comments on commit 5ed2072

Please sign in to comment.