()
| 4231 | |
| 4232 | |
| 4233 | def test_run_end_encoded_from_buffers(): |
| 4234 | run_ends = [3, 5, 10, 19] |
| 4235 | values = [1, 2, 1, 3] |
| 4236 | |
| 4237 | ree_type = pa.run_end_encoded(run_end_type=pa.int32(), value_type=pa.uint8()) |
| 4238 | length = 19 |
| 4239 | buffers = [None] |
| 4240 | null_count = 0 |
| 4241 | offset = 0 |
| 4242 | children = [run_ends, values] |
| 4243 | |
| 4244 | ree_array = pa.RunEndEncodedArray.from_buffers(ree_type, length, buffers, |
| 4245 | null_count, offset, |
| 4246 | children) |
| 4247 | check_run_end_encoded(ree_array, run_ends, values, 19, 4, 0) |
| 4248 | # buffers = [] |
| 4249 | ree_array = pa.RunEndEncodedArray.from_buffers(ree_type, length, [], |
| 4250 | null_count, offset, |
| 4251 | children) |
| 4252 | check_run_end_encoded(ree_array, run_ends, values, 19, 4, 0) |
| 4253 | # null_count = -1 |
| 4254 | ree_array = pa.RunEndEncodedArray.from_buffers(ree_type, length, buffers, |
| 4255 | -1, offset, |
| 4256 | children) |
| 4257 | check_run_end_encoded(ree_array, run_ends, values, 19, 4, 0) |
| 4258 | # offset = 4 |
| 4259 | ree_array = pa.RunEndEncodedArray.from_buffers(ree_type, length - 4, buffers, |
| 4260 | null_count, 4, children) |
| 4261 | check_run_end_encoded(ree_array, run_ends, values, length - 4, 3, 1) |
| 4262 | # buffers = [None, None] |
| 4263 | with pytest.raises(ValueError): |
| 4264 | pa.RunEndEncodedArray.from_buffers(ree_type, length, [None, None], |
| 4265 | null_count, offset, children) |
| 4266 | # children = None |
| 4267 | with pytest.raises(ValueError): |
| 4268 | pa.RunEndEncodedArray.from_buffers(ree_type, length, buffers, |
| 4269 | null_count, offset, None) |
| 4270 | # len(children) == 1 |
| 4271 | with pytest.raises(ValueError): |
| 4272 | pa.RunEndEncodedArray.from_buffers(ree_type, length, buffers, |
| 4273 | null_count, offset, [run_ends]) |
| 4274 | # null_count = 1 |
| 4275 | with pytest.raises(ValueError): |
| 4276 | pa.RunEndEncodedArray.from_buffers(ree_type, length, buffers, |
| 4277 | 1, offset, children) |
| 4278 | |
| 4279 | |
| 4280 | @pytest.mark.numpy |
nothing calls this directly
no test coverage detected