(cuda_context, cpu_table, cuda_table,
cuda_arrays, cuda_recordbatch, schema)
| 3878 | |
| 3879 | |
| 3880 | def test_table_non_cpu(cuda_context, cpu_table, cuda_table, |
| 3881 | cuda_arrays, cuda_recordbatch, schema): |
| 3882 | verify_cuda_table(cuda_table, expected_schema=schema) |
| 3883 | N = cuda_table.num_rows |
| 3884 | |
| 3885 | # shape test |
| 3886 | assert cuda_table.shape == (10, 2) |
| 3887 | |
| 3888 | # columns() test |
| 3889 | assert len(cuda_table.columns) == 2 |
| 3890 | |
| 3891 | # add_column(), set_column() test |
| 3892 | for fn in [cuda_table.add_column, cuda_table.set_column]: |
| 3893 | cpu_col = pa.array([1] * N, pa.int8()) |
| 3894 | cuda_col = cpu_col.copy_to(cuda_context.memory_manager) |
| 3895 | new_table = fn(2, 'c2', cuda_col) |
| 3896 | verify_cuda_table(new_table, expected_schema=schema.append( |
| 3897 | pa.field('c2', pa.int8()))) |
| 3898 | new_table = fn(2, 'c2', cpu_col) |
| 3899 | assert new_table.is_cpu is False |
| 3900 | assert new_table.column(0).is_cpu is False |
| 3901 | assert new_table.column(1).is_cpu is False |
| 3902 | assert new_table.column(2).is_cpu is True |
| 3903 | |
| 3904 | # remove_column() test |
| 3905 | new_table = cuda_table.remove_column(1) |
| 3906 | verify_cuda_table(new_table, expected_schema=schema.remove(1)) |
| 3907 | |
| 3908 | # drop_columns() test |
| 3909 | new_table = cuda_table.drop_columns(['c1']) |
| 3910 | verify_cuda_table(new_table, expected_schema=schema.remove(1)) |
| 3911 | new_table = cuda_table.drop_columns(['c0', 'c1']) |
| 3912 | assert len(new_table.columns) == 0 |
| 3913 | assert new_table.is_cpu |
| 3914 | |
| 3915 | # select() test |
| 3916 | new_table = cuda_table.select(['c0']) |
| 3917 | verify_cuda_table(new_table, expected_schema=schema.remove(1)) |
| 3918 | |
| 3919 | # cast() test |
| 3920 | new_schema = pa.schema([pa.field('c0', pa.int64()), pa.field('c1', pa.int64())]) |
| 3921 | with pytest.raises(NotImplementedError): |
| 3922 | cuda_table.cast(new_schema) |
| 3923 | |
| 3924 | # drop_null() test |
| 3925 | null_col = pa.array([1] * N, mask=[True] * N).copy_to(cuda_context.memory_manager) |
| 3926 | cuda_table_with_nulls = cuda_table.add_column(2, 'c2', null_col) |
| 3927 | with pytest.raises(NotImplementedError): |
| 3928 | cuda_table_with_nulls.drop_null() |
| 3929 | |
| 3930 | # filter() test |
| 3931 | with pytest.raises(NotImplementedError): |
| 3932 | cuda_table.filter([True] * N) |
| 3933 | |
| 3934 | # take() test |
| 3935 | with pytest.raises(NotImplementedError): |
| 3936 | cuda_table.take([0]) |
| 3937 |
nothing calls this directly
no test coverage detected