MCPcopy Create free account
hub / github.com/apache/arrow / test_dictionary_from_strings

Function test_dictionary_from_strings

python/pyarrow/tests/test_convert_builtin.py:2236–2256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2234
2235
2236def 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'), [

Callers

nothing calls this directly

Calls 4

equalsMethod · 0.80
stringMethod · 0.45
dictionaryMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected