()
| 2234 | |
| 2235 | |
| 2236 | def test_dictionary_from_strings(): |
| 2237 | for value_type in [pa.binary(), pa.string()]: |
| 2238 | typ = pa.dictionary(pa.int8(), value_type) |
| 2239 | a = pa.array(["", "a", "bb", "a", "bb", "ccc"], type=typ) |
| 2240 | |
| 2241 | assert isinstance(a.type, pa.DictionaryType) |
| 2242 | |
| 2243 | expected_indices = pa.array([0, 1, 2, 1, 2, 3], type=pa.int8()) |
| 2244 | expected_dictionary = pa.array(["", "a", "bb", "ccc"], type=value_type) |
| 2245 | assert a.indices.equals(expected_indices) |
| 2246 | assert a.dictionary.equals(expected_dictionary) |
| 2247 | |
| 2248 | # fixed size binary type |
| 2249 | typ = pa.dictionary(pa.int8(), pa.binary(3)) |
| 2250 | a = pa.array(["aaa", "aaa", "bbb", "ccc", "bbb"], type=typ) |
| 2251 | assert isinstance(a.type, pa.DictionaryType) |
| 2252 | |
| 2253 | expected_indices = pa.array([0, 0, 1, 2, 1], type=pa.int8()) |
| 2254 | expected_dictionary = pa.array(["aaa", "bbb", "ccc"], type=pa.binary(3)) |
| 2255 | assert a.indices.equals(expected_indices) |
| 2256 | assert a.dictionary.equals(expected_dictionary) |
| 2257 | |
| 2258 | |
| 2259 | @pytest.mark.parametrize(('unit', 'expected'), [ |
nothing calls this directly
no test coverage detected