| 2145 | |
| 2146 | |
| 2147 | def test_map_from_tuples(): |
| 2148 | expected = [[(b'a', 1), (b'b', 2)], |
| 2149 | [(b'c', 3)], |
| 2150 | [(b'd', 4), (b'e', 5), (b'f', None)], |
| 2151 | [(b'g', 7)]] |
| 2152 | |
| 2153 | arr = pa.array(expected, type=pa.map_(pa.binary(), pa.int32())) |
| 2154 | |
| 2155 | assert arr.to_pylist() == expected |
| 2156 | |
| 2157 | # With omitted values |
| 2158 | expected[1] = None |
| 2159 | |
| 2160 | arr = pa.array(expected, type=pa.map_(pa.binary(), pa.int32())) |
| 2161 | |
| 2162 | assert arr.to_pylist() == expected |
| 2163 | |
| 2164 | # Invalid tuple size |
| 2165 | for entry in [[(5,)], [()], [('5', 'foo', True)]]: |
| 2166 | with pytest.raises(ValueError, match="(?i)tuple size"): |
| 2167 | pa.array([entry], type=pa.map_('i4', 'i4')) |
| 2168 | |
| 2169 | |
| 2170 | def test_dictionary_from_boolean(): |