| 2830 | |
| 2831 | |
| 2832 | def test_interval_array_from_timedelta(): |
| 2833 | data = [ |
| 2834 | None, |
| 2835 | datetime.timedelta(days=1, seconds=1, microseconds=1, |
| 2836 | milliseconds=1, minutes=1, hours=1, weeks=1)] |
| 2837 | |
| 2838 | # From timedelta (explicit type required) |
| 2839 | arr = pa.array(data, pa.month_day_nano_interval()) |
| 2840 | assert isinstance(arr, pa.MonthDayNanoIntervalArray) |
| 2841 | assert arr.type == pa.month_day_nano_interval() |
| 2842 | expected_list = [ |
| 2843 | None, |
| 2844 | pa.MonthDayNano([0, 8, |
| 2845 | (datetime.timedelta(seconds=1, microseconds=1, |
| 2846 | milliseconds=1, minutes=1, |
| 2847 | hours=1) // |
| 2848 | datetime.timedelta(microseconds=1)) * 1000])] |
| 2849 | expected = pa.array(expected_list) |
| 2850 | assert arr.equals(expected) |
| 2851 | assert arr.to_pylist() == expected_list |
| 2852 | |
| 2853 | |
| 2854 | @pytest.mark.pandas |