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

Function test_half_float_array_from_python

python/pyarrow/tests/test_array.py:1870–1881  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1868
1869
1870def test_half_float_array_from_python():
1871 # GH-46611
1872 vals = [-5, 0, 1.0, 2.0, 3, None, 12345.6789, 1.234567, float('inf')]
1873 arr = pa.array(vals, type=pa.float16())
1874 assert arr.type == pa.float16()
1875 assert arr.to_pylist() == [-5, 0, 1.0, 2.0, 3, None, 12344.0,
1876 1.234375, float('inf')]
1877 assert str(arr) == ("[\n -5,\n 0,\n 1,\n 2,\n 3,\n null,\n 12344,"
1878 "\n 1.234375,\n inf\n]")
1879 msg1 = "Could not convert 'a' with type str: tried to convert to float16"
1880 with pytest.raises(pa.ArrowInvalid, match=msg1):
1881 arr = pa.array(['a', 3, None], type=pa.float16())
1882
1883
1884def test_decimal_to_int_safe():

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.45

Tested by

no test coverage detected