| 2040 | class TestDiff: |
| 2041 | @pytest.mark.parametrize("dtype", ["M8[ns]", "m8[ns]"]) |
| 2042 | def test_diff_datetimelike_nat(self, dtype): |
| 2043 | # NaT - NaT is NaT, not 0 |
| 2044 | arr = np.arange(12).astype(np.int64).view(dtype).reshape(3, 4) |
| 2045 | arr[:, 2] = arr.dtype.type("NaT", "ns") |
| 2046 | result = algos.diff(arr, 1, axis=0) |
| 2047 | |
| 2048 | expected = np.ones(arr.shape, dtype="timedelta64[ns]") * 4 |
| 2049 | expected[:, 2] = np.timedelta64("NaT", "ns") |
| 2050 | expected[0, :] = np.timedelta64("NaT", "ns") |
| 2051 | |
| 2052 | tm.assert_numpy_array_equal(result, expected) |
| 2053 | |
| 2054 | result = algos.diff(arr.T, 1, axis=1) |
| 2055 | tm.assert_numpy_array_equal(result, expected.T) |
| 2056 | |
| 2057 | def test_diff_ea_axis(self): |
| 2058 | dta = date_range("2016-01-01", periods=3, tz="US/Pacific")._data |