(self)
| 797 | assert_(type(out3) is type(x)) |
| 798 | |
| 799 | def test_prepend(self): |
| 800 | x = np.arange(5) + 1 |
| 801 | assert_array_equal(diff(x, prepend=0), np.ones(5)) |
| 802 | assert_array_equal(diff(x, prepend=[0]), np.ones(5)) |
| 803 | assert_array_equal(np.cumsum(np.diff(x, prepend=0)), x) |
| 804 | assert_array_equal(diff(x, prepend=[-1, 0]), np.ones(6)) |
| 805 | |
| 806 | x = np.arange(4).reshape(2, 2) |
| 807 | result = np.diff(x, axis=1, prepend=0) |
| 808 | expected = [[0, 1], [2, 1]] |
| 809 | assert_array_equal(result, expected) |
| 810 | result = np.diff(x, axis=1, prepend=[[0], [0]]) |
| 811 | assert_array_equal(result, expected) |
| 812 | |
| 813 | result = np.diff(x, axis=0, prepend=0) |
| 814 | expected = [[0, 1], [2, 2]] |
| 815 | assert_array_equal(result, expected) |
| 816 | result = np.diff(x, axis=0, prepend=[[0, 0]]) |
| 817 | assert_array_equal(result, expected) |
| 818 | |
| 819 | assert_raises(ValueError, np.diff, x, prepend=np.zeros((3,3))) |
| 820 | |
| 821 | assert_raises(np.AxisError, diff, x, prepend=0, axis=3) |
| 822 | |
| 823 | def test_append(self): |
| 824 | x = np.arange(5) |
nothing calls this directly
no test coverage detected