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

Function test_numerics

python/pyarrow/tests/test_scalars.py:235–263  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

233
234
235def test_numerics():
236 # int64
237 s = pa.scalar(1)
238 assert isinstance(s, pa.Int64Scalar)
239 assert repr(s) == "<pyarrow.Int64Scalar: 1>"
240 assert str(s) == "1"
241 assert s.as_py() == 1
242 assert int(s) == 1
243
244 with pytest.raises(OverflowError):
245 pa.scalar(-1, type='uint8')
246
247 # float64
248 s = pa.scalar(1.5)
249 assert isinstance(s, pa.DoubleScalar)
250 assert repr(s) == "<pyarrow.DoubleScalar: 1.5>"
251 assert str(s) == "1.5"
252 assert s.as_py() == 1.5
253 assert float(s) == 1.5
254 assert int(s) == 1
255
256 # float16
257 s = pa.scalar(0.5, type='float16')
258 assert isinstance(s, pa.HalfFloatScalar)
259 assert repr(s) == "<pyarrow.HalfFloatScalar: 0.5>"
260 assert str(s) == "0.5"
261 assert s.as_py() == 0.5
262 assert float(s) == 0.5
263 assert int(s) == 0
264
265
266def test_decimal128():

Callers

nothing calls this directly

Calls 2

as_pyMethod · 0.80
scalarMethod · 0.45

Tested by

no test coverage detected