(cuda_context, cpu_table, cuda_table,
cuda_arrays, cuda_recordbatch, schema)
| 3989 | |
| 3990 | |
| 3991 | def test_table_non_cpu(cuda_context, cpu_table, cuda_table, |
| 3992 | cuda_arrays, cuda_recordbatch, schema): |
| 3993 | verify_cuda_table(cuda_table, expected_schema=schema) |
| 3994 | N = cuda_table.num_rows |
| 3995 | |
| 3996 | # shape test |
| 3997 | assert cuda_table.shape == (10, 2) |
| 3998 | |
| 3999 | # columns() test |
| 4000 | assert len(cuda_table.columns) == 2 |
| 4001 | |
| 4002 | # add_column(), set_column() test |
| 4003 | for fn in [cuda_table.add_column, cuda_table.set_column]: |
| 4004 | cpu_col = pa.array([1] * N, pa.int8()) |
| 4005 | cuda_col = cpu_col.copy_to(cuda_context.memory_manager) |
| 4006 | new_table = fn(2, 'c2', cuda_col) |
| 4007 | verify_cuda_table(new_table, expected_schema=schema.append( |
| 4008 | pa.field('c2', pa.int8()))) |
| 4009 | new_table = fn(2, 'c2', cpu_col) |
| 4010 | assert new_table.is_cpu is False |
| 4011 | assert new_table.column(0).is_cpu is False |
| 4012 | assert new_table.column(1).is_cpu is False |
| 4013 | assert new_table.column(2).is_cpu is True |
| 4014 | |
| 4015 | # remove_column() test |
| 4016 | new_table = cuda_table.remove_column(1) |
| 4017 | verify_cuda_table(new_table, expected_schema=schema.remove(1)) |
| 4018 | |
| 4019 | # drop_columns() test |
| 4020 | new_table = cuda_table.drop_columns(['c1']) |
| 4021 | verify_cuda_table(new_table, expected_schema=schema.remove(1)) |
| 4022 | new_table = cuda_table.drop_columns(['c0', 'c1']) |
| 4023 | assert len(new_table.columns) == 0 |
| 4024 | assert new_table.is_cpu |
| 4025 | |
| 4026 | # select() test |
| 4027 | new_table = cuda_table.select(['c0']) |
| 4028 | verify_cuda_table(new_table, expected_schema=schema.remove(1)) |
| 4029 | |
| 4030 | # cast() test |
| 4031 | new_schema = pa.schema([pa.field('c0', pa.int64()), pa.field('c1', pa.int64())]) |
| 4032 | with pytest.raises(NotImplementedError): |
| 4033 | cuda_table.cast(new_schema) |
| 4034 | |
| 4035 | # drop_null() test |
| 4036 | null_col = pa.array([1] * N, mask=[True] * N).copy_to(cuda_context.memory_manager) |
| 4037 | cuda_table_with_nulls = cuda_table.add_column(2, 'c2', null_col) |
| 4038 | with pytest.raises(NotImplementedError): |
| 4039 | cuda_table_with_nulls.drop_null() |
| 4040 | |
| 4041 | # filter() test |
| 4042 | with pytest.raises(NotImplementedError): |
| 4043 | cuda_table.filter([True] * N) |
| 4044 | |
| 4045 | # take() test |
| 4046 | with pytest.raises(NotImplementedError): |
| 4047 | cuda_table.take([0]) |
| 4048 |
nothing calls this directly
no test coverage detected