(self)
| 3133 | assert_almost_equal(np.interp(x0, x, y), x0) |
| 3134 | |
| 3135 | def test_right_left_behavior(self): |
| 3136 | # Needs range of sizes to test different code paths. |
| 3137 | # size ==1 is special cased, 1 < size < 5 is linear search, and |
| 3138 | # size >= 5 goes through local search and possibly binary search. |
| 3139 | for size in range(1, 10): |
| 3140 | xp = np.arange(size, dtype=np.double) |
| 3141 | yp = np.ones(size, dtype=np.double) |
| 3142 | incpts = np.array([-1, 0, size - 1, size], dtype=np.double) |
| 3143 | decpts = incpts[::-1] |
| 3144 | |
| 3145 | incres = interp(incpts, xp, yp) |
| 3146 | decres = interp(decpts, xp, yp) |
| 3147 | inctgt = np.array([1, 1, 1, 1], dtype=float) |
| 3148 | dectgt = inctgt[::-1] |
| 3149 | assert_equal(incres, inctgt) |
| 3150 | assert_equal(decres, dectgt) |
| 3151 | |
| 3152 | incres = interp(incpts, xp, yp, left=0) |
| 3153 | decres = interp(decpts, xp, yp, left=0) |
| 3154 | inctgt = np.array([0, 1, 1, 1], dtype=float) |
| 3155 | dectgt = inctgt[::-1] |
| 3156 | assert_equal(incres, inctgt) |
| 3157 | assert_equal(decres, dectgt) |
| 3158 | |
| 3159 | incres = interp(incpts, xp, yp, right=2) |
| 3160 | decres = interp(decpts, xp, yp, right=2) |
| 3161 | inctgt = np.array([1, 1, 1, 2], dtype=float) |
| 3162 | dectgt = inctgt[::-1] |
| 3163 | assert_equal(incres, inctgt) |
| 3164 | assert_equal(decres, dectgt) |
| 3165 | |
| 3166 | incres = interp(incpts, xp, yp, left=0, right=2) |
| 3167 | decres = interp(decpts, xp, yp, left=0, right=2) |
| 3168 | inctgt = np.array([0, 1, 1, 2], dtype=float) |
| 3169 | dectgt = inctgt[::-1] |
| 3170 | assert_equal(incres, inctgt) |
| 3171 | assert_equal(decres, dectgt) |
| 3172 | |
| 3173 | def test_scalar_interpolation_point(self): |
| 3174 | x = np.linspace(0, 1, 5) |
nothing calls this directly
no test coverage detected