| 3813 | |
| 3814 | |
| 3815 | def test_make_struct(): |
| 3816 | assert pc.make_struct(1, 'a').as_py() == {'0': 1, '1': 'a'} |
| 3817 | |
| 3818 | assert pc.make_struct(1, 'a', field_names=['i', 's']).as_py() == { |
| 3819 | 'i': 1, 's': 'a'} |
| 3820 | |
| 3821 | assert pc.make_struct([1, 2, 3], |
| 3822 | "a b c".split()) == pa.StructArray.from_arrays([ |
| 3823 | [1, 2, 3], |
| 3824 | "a b c".split()], names='0 1'.split()) |
| 3825 | |
| 3826 | with pytest.raises(ValueError, |
| 3827 | match="Array arguments must all be the same length"): |
| 3828 | pc.make_struct([1, 2, 3, 4], "a b c".split()) |
| 3829 | |
| 3830 | with pytest.raises(ValueError, match="0 arguments but 2 field names"): |
| 3831 | pc.make_struct(field_names=['one', 'two']) |
| 3832 | |
| 3833 | |
| 3834 | def test_map_lookup(): |