(cuda_context, cpu_table, cuda_table,
cuda_arrays, cuda_recordbatch, schema)
| 4043 | |
| 4044 | |
| 4045 | def test_table_non_cpu(cuda_context, cpu_table, cuda_table, |
| 4046 | cuda_arrays, cuda_recordbatch, schema): |
| 4047 | verify_cuda_table(cuda_table, expected_schema=schema) |
| 4048 | N = cuda_table.num_rows |
| 4049 | |
| 4050 | # shape test |
| 4051 | assert cuda_table.shape == (10, 2) |
| 4052 | |
| 4053 | # columns() test |
| 4054 | assert len(cuda_table.columns) == 2 |
| 4055 | |
| 4056 | # add_column(), set_column() test |
| 4057 | for fn in [cuda_table.add_column, cuda_table.set_column]: |
| 4058 | cpu_col = pa.array([1] * N, pa.int8()) |
| 4059 | cuda_col = cpu_col.copy_to(cuda_context.memory_manager) |
| 4060 | new_table = fn(2, 'c2', cuda_col) |
| 4061 | verify_cuda_table(new_table, expected_schema=schema.append( |
| 4062 | pa.field('c2', pa.int8()))) |
| 4063 | new_table = fn(2, 'c2', cpu_col) |
| 4064 | assert new_table.is_cpu is False |
| 4065 | assert new_table.column(0).is_cpu is False |
| 4066 | assert new_table.column(1).is_cpu is False |
| 4067 | assert new_table.column(2).is_cpu is True |
| 4068 | |
| 4069 | # remove_column() test |
| 4070 | new_table = cuda_table.remove_column(1) |
| 4071 | verify_cuda_table(new_table, expected_schema=schema.remove(1)) |
| 4072 | |
| 4073 | # drop_columns() test |
| 4074 | new_table = cuda_table.drop_columns(['c1']) |
| 4075 | verify_cuda_table(new_table, expected_schema=schema.remove(1)) |
| 4076 | new_table = cuda_table.drop_columns(['c0', 'c1']) |
| 4077 | assert len(new_table.columns) == 0 |
| 4078 | assert new_table.is_cpu |
| 4079 | |
| 4080 | # select() test |
| 4081 | new_table = cuda_table.select(['c0']) |
| 4082 | verify_cuda_table(new_table, expected_schema=schema.remove(1)) |
| 4083 | |
| 4084 | # cast() test |
| 4085 | new_schema = pa.schema([pa.field('c0', pa.int64()), pa.field('c1', pa.int64())]) |
| 4086 | with pytest.raises(NotImplementedError): |
| 4087 | cuda_table.cast(new_schema) |
| 4088 | |
| 4089 | # drop_null() test |
| 4090 | null_col = pa.array([1] * N, mask=[True] * N).copy_to(cuda_context.memory_manager) |
| 4091 | cuda_table_with_nulls = cuda_table.add_column(2, 'c2', null_col) |
| 4092 | with pytest.raises(NotImplementedError): |
| 4093 | cuda_table_with_nulls.drop_null() |
| 4094 | |
| 4095 | # filter() test |
| 4096 | with pytest.raises(NotImplementedError): |
| 4097 | cuda_table.filter([True] * N) |
| 4098 | |
| 4099 | # take() test |
| 4100 | with pytest.raises(NotImplementedError): |
| 4101 | cuda_table.take([0]) |
| 4102 |
nothing calls this directly
no test coverage detected