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

Function test_array_from_numpy_timedelta

python/pyarrow/tests/test_array.py:2756–2775  ·  view source on GitHub ↗
(dtype, type)

Source from the content-addressed store, hash-verified

2754 ('timedelta64[ns]', pa.duration('ns'))
2755])
2756def test_array_from_numpy_timedelta(dtype, type):
2757 data = [
2758 None,
2759 datetime.timedelta(1),
2760 datetime.timedelta(0, 1)
2761 ]
2762
2763 # from numpy array
2764 np_arr = np.array(data, dtype=dtype)
2765 arr = pa.array(np_arr)
2766 assert isinstance(arr, pa.DurationArray)
2767 assert arr.type == type
2768 expected = pa.array(data, type=type)
2769 assert arr.equals(expected)
2770 assert arr.to_pylist() == data
2771
2772 # from list of numpy scalars
2773 arr = pa.array(list(np.array(data, dtype=dtype)))
2774 assert arr.equals(expected)
2775 assert arr.to_pylist() == data
2776
2777
2778@pytest.mark.numpy

Callers

nothing calls this directly

Calls 3

listFunction · 0.85
equalsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected