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

Function test_duration

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

Source from the content-addressed store, hash-verified

487
488@pytest.mark.numpy
489def test_duration():
490 arr = np.array([0, 3600000000000], dtype='timedelta64[ns]')
491
492 units = ['us', 'ms', 's']
493
494 for i, unit in enumerate(units):
495 dtype = f'timedelta64[{unit}]'
496 arrow_arr = pa.array(arr.astype(dtype))
497 expected = datetime.timedelta(seconds=60*60)
498 assert isinstance(arrow_arr[1].as_py(), datetime.timedelta)
499 assert arrow_arr[1].as_py() == expected
500 assert (arrow_arr[1].value * 1000**(i+1) ==
501 expected.total_seconds() * 1e9)
502
503
504@pytest.mark.pandas

Callers

nothing calls this directly

Calls 2

as_pyMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected