Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ianna authored Sep 19, 2024
1 parent 9bbd8f6 commit da434dc
Showing 1 changed file with 68 additions and 4 deletions.
72 changes: 68 additions & 4 deletions tests-cuda/test_3140_cuda_slicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ def test_0127_tomask_operation():


def test_simple_slice_cpu():
arrg_cpu = ak.Array([[1, 2, 3], [0], [4, 5]])
out = arrg_cpu[:, 0]
arr = ak.Array([[1, 2, 3], [0], [4, 5]])
out = arr[:, 0]
expected = [1, 0, 4]
result = out.tolist()
cp.testing.assert_array_list_equal(
Expand All @@ -692,12 +692,76 @@ def test_simple_slice_cpu():


def test_simple_slice_gpu():
arrg_gpu = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
out = arrg_gpu[:, 0]
arr = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
out = arr[:, 0]
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}",
)


def test_simple_slice_cpu1():
arr = ak.Array([[1, 2, 3], [0], [4, 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}")


def test_simple_slice_gpu1():
arr = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
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}")


def test_simple_slice_cpu2():
arr = ak.Array([[1, 2, 3], [0], [4, 5]])
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}")


def test_simple_slice_gpu2():
arr = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
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}")


def test_simple_slice_cpu3():
arr = ak.Array([[1, 2, 3], [0], [4, 5]])
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}")


def test_simple_slice_gpu3():
arr = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
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}")


def test_simple_slice_cpu4():
arr = ak.Array([[1, 2, 3], [0], [4, 5]])
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}")


def test_simple_slice_gpu4():
arr = ak.Array([[1, 2, 3], [0], [4, 5]], backend="cuda")
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}")

0 comments on commit da434dc

Please sign in to comment.