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

Function test_convert_options

python/pyarrow/tests/test_csv.py:301–396  ·  view source on GitHub ↗
(pickle_module)

Source from the content-addressed store, hash-verified

299
300
301def test_convert_options(pickle_module):
302 cls = ConvertOptions
303 opts = cls()
304
305 check_options_class(
306 cls, check_utf8=[True, False],
307 strings_can_be_null=[False, True],
308 quoted_strings_can_be_null=[True, False],
309 decimal_point=['.', ','],
310 include_columns=[[], ['def', 'abc']],
311 include_missing_columns=[False, True],
312 auto_dict_encode=[False, True],
313 timestamp_parsers=[[], [ISO8601, '%y-%m']])
314
315 check_options_class_pickling(
316 cls, pickler=pickle_module,
317 check_utf8=False,
318 strings_can_be_null=True,
319 quoted_strings_can_be_null=False,
320 decimal_point=',',
321 include_columns=['def', 'abc'],
322 include_missing_columns=False,
323 auto_dict_encode=True,
324 timestamp_parsers=[ISO8601, '%y-%m'])
325
326 with pytest.raises(ValueError):
327 opts.decimal_point = '..'
328
329 assert opts.auto_dict_max_cardinality > 0
330 opts.auto_dict_max_cardinality = 99999
331 assert opts.auto_dict_max_cardinality == 99999
332
333 assert opts.column_types == {}
334 # Pass column_types as mapping
335 opts.column_types = {'b': pa.int16(), 'c': pa.float32()}
336 assert opts.column_types == {'b': pa.int16(), 'c': pa.float32()}
337 opts.column_types = {'v': 'int16', 'w': 'null'}
338 assert opts.column_types == {'v': pa.int16(), 'w': pa.null()}
339 # Pass column_types as schema
340 schema = pa.schema([('a', pa.int32()), ('b', pa.string())])
341 opts.column_types = schema
342 assert opts.column_types == {'a': pa.int32(), 'b': pa.string()}
343 # Pass column_types as sequence
344 opts.column_types = [('x', pa.binary())]
345 assert opts.column_types == {'x': pa.binary()}
346
347 with pytest.raises(TypeError, match='DataType expected'):
348 opts.column_types = {'a': None}
349 with pytest.raises(TypeError):
350 opts.column_types = 0
351
352 assert isinstance(opts.null_values, list)
353 assert '' in opts.null_values
354 assert 'N/A' in opts.null_values
355 opts.null_values = ['xxx', 'yyy']
356 assert opts.null_values == ['xxx', 'yyy']
357
358 assert isinstance(opts.true_values, list)

Callers

nothing calls this directly

Calls 4

check_options_classFunction · 0.85
schemaMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected