MCPcopy Create free account
hub / github.com/numpy/numpy / test_right_left_behavior

Method test_right_left_behavior

numpy/lib/tests/test_function_base.py:2831–2867  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2829 assert_almost_equal(np.interp(x0, x, y), x0)
2830
2831 def test_right_left_behavior(self):
2832 # Needs range of sizes to test different code paths.
2833 # size ==1 is special cased, 1 < size < 5 is linear search, and
2834 # size >= 5 goes through local search and possibly binary search.
2835 for size in range(1, 10):
2836 xp = np.arange(size, dtype=np.double)
2837 yp = np.ones(size, dtype=np.double)
2838 incpts = np.array([-1, 0, size - 1, size], dtype=np.double)
2839 decpts = incpts[::-1]
2840
2841 incres = interp(incpts, xp, yp)
2842 decres = interp(decpts, xp, yp)
2843 inctgt = np.array([1, 1, 1, 1], dtype=float)
2844 dectgt = inctgt[::-1]
2845 assert_equal(incres, inctgt)
2846 assert_equal(decres, dectgt)
2847
2848 incres = interp(incpts, xp, yp, left=0)
2849 decres = interp(decpts, xp, yp, left=0)
2850 inctgt = np.array([0, 1, 1, 1], dtype=float)
2851 dectgt = inctgt[::-1]
2852 assert_equal(incres, inctgt)
2853 assert_equal(decres, dectgt)
2854
2855 incres = interp(incpts, xp, yp, right=2)
2856 decres = interp(decpts, xp, yp, right=2)
2857 inctgt = np.array([1, 1, 1, 2], dtype=float)
2858 dectgt = inctgt[::-1]
2859 assert_equal(incres, inctgt)
2860 assert_equal(decres, dectgt)
2861
2862 incres = interp(incpts, xp, yp, left=0, right=2)
2863 decres = interp(decpts, xp, yp, left=0, right=2)
2864 inctgt = np.array([0, 1, 1, 2], dtype=float)
2865 dectgt = inctgt[::-1]
2866 assert_equal(incres, inctgt)
2867 assert_equal(decres, dectgt)
2868
2869 def test_scalar_interpolation_point(self):
2870 x = np.linspace(0, 1, 5)

Callers

nothing calls this directly

Calls 2

interpFunction · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected