(cuda_context, cpu_recordbatch, cuda_recordbatch,
cuda_arrays, schema)
| 3869 | |
| 3870 | |
| 3871 | def test_recordbatch_non_cpu(cuda_context, cpu_recordbatch, cuda_recordbatch, |
| 3872 | cuda_arrays, schema): |
| 3873 | verify_cuda_recordbatch(cuda_recordbatch, expected_schema=schema) |
| 3874 | N = cuda_recordbatch.num_rows |
| 3875 | |
| 3876 | # shape test |
| 3877 | assert cuda_recordbatch.shape == (5, 2) |
| 3878 | |
| 3879 | # columns() test |
| 3880 | assert len(cuda_recordbatch.columns) == 2 |
| 3881 | |
| 3882 | # add_column(), set_column() test |
| 3883 | for fn in [cuda_recordbatch.add_column, cuda_recordbatch.set_column]: |
| 3884 | col = pa.array([-2, -1, 0, 1, 2], pa.int8() |
| 3885 | ).copy_to(cuda_context.memory_manager) |
| 3886 | new_batch = fn(2, 'c2', col) |
| 3887 | verify_cuda_recordbatch( |
| 3888 | new_batch, expected_schema=schema.append(pa.field('c2', pa.int8()))) |
| 3889 | err_msg = ("Got column on device <DeviceAllocationType.CPU: 1>, " |
| 3890 | "but expected <DeviceAllocationType.CUDA: 2>.") |
| 3891 | with pytest.raises(TypeError, match=err_msg): |
| 3892 | fn(2, 'c2', [1] * N) |
| 3893 | |
| 3894 | # remove_column() test |
| 3895 | new_batch = cuda_recordbatch.remove_column(1) |
| 3896 | verify_cuda_recordbatch(new_batch, expected_schema=schema.remove(1)) |
| 3897 | |
| 3898 | # drop_columns() test |
| 3899 | new_batch = cuda_recordbatch.drop_columns(['c1']) |
| 3900 | verify_cuda_recordbatch(new_batch, expected_schema=schema.remove(1)) |
| 3901 | empty_batch = cuda_recordbatch.drop_columns(['c0', 'c1']) |
| 3902 | assert len(empty_batch.columns) == 0 |
| 3903 | assert empty_batch.device_type == pa.DeviceAllocationType.CUDA |
| 3904 | |
| 3905 | # select() test |
| 3906 | new_batch = cuda_recordbatch.select(['c0']) |
| 3907 | verify_cuda_recordbatch(new_batch, expected_schema=schema.remove(1)) |
| 3908 | |
| 3909 | # cast() test |
| 3910 | new_schema = pa.schema([pa.field('c0', pa.int64()), pa.field('c1', pa.int64())]) |
| 3911 | with pytest.raises(NotImplementedError): |
| 3912 | cuda_recordbatch.cast(new_schema) |
| 3913 | |
| 3914 | # drop_null() test |
| 3915 | null_col = pa.array([1] * N, mask=[True, False, True, False, True]).copy_to( |
| 3916 | cuda_context.memory_manager) |
| 3917 | cuda_recordbatch_with_nulls = cuda_recordbatch.add_column(2, 'c2', null_col) |
| 3918 | with pytest.raises(NotImplementedError): |
| 3919 | cuda_recordbatch_with_nulls.drop_null() |
| 3920 | |
| 3921 | # filter() test |
| 3922 | with pytest.raises(NotImplementedError): |
| 3923 | cuda_recordbatch.filter([True] * N) |
| 3924 | |
| 3925 | # take() test |
| 3926 | with pytest.raises(NotImplementedError): |
| 3927 | cuda_recordbatch.take([0]) |
| 3928 |
nothing calls this directly
no test coverage detected