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

Function _check_cast_case

python/pyarrow/tests/test_array.py:1589–1611  ·  view source on GitHub ↗
(case, *, safe=True, check_array_construction=True)

Source from the content-addressed store, hash-verified

1587
1588
1589def _check_cast_case(case, *, safe=True, check_array_construction=True):
1590 in_data, in_type, out_data, out_type = case
1591 if isinstance(out_data, pa.Array):
1592 assert out_data.type == out_type
1593 expected = out_data
1594 else:
1595 expected = pa.array(out_data, type=out_type)
1596
1597 # check casting an already created array
1598 if isinstance(in_data, pa.Array):
1599 assert in_data.type == in_type
1600 in_arr = in_data
1601 else:
1602 in_arr = pa.array(in_data, type=in_type)
1603 casted = in_arr.cast(out_type, safe=safe)
1604 casted.validate(full=True)
1605 assert casted.equals(expected)
1606
1607 # constructing an array with out type which optionally involves casting
1608 # for more see ARROW-1949
1609 if check_array_construction:
1610 in_arr = pa.array(in_data, type=out_type, safe=safe)
1611 assert in_arr.equals(expected)
1612
1613
1614@pytest.mark.numpy

Calls 4

equalsMethod · 0.80
arrayMethod · 0.45
castMethod · 0.45
validateMethod · 0.45

Tested by

no test coverage detected