@@ -159,7 +159,7 @@ def interpolator(self, func):
159159 z = func (self .x , self .y )
160160 return self .tri .nn_extrapolator (z , bbox = self .xrange + self .yrange )
161161
162- def make_all_testfuncs (allfuncs = allfuncs ):
162+ def make_all_2d_testfuncs (allfuncs = allfuncs ):
163163 def make_test (func ):
164164 filenames = [
165165 '%s-%s' % (func .func_name , x ) for x in
@@ -186,4 +186,27 @@ def reference_test():
186186 for func in allfuncs :
187187 globals ()['test_%s' % func .func_name ] = make_test (func )
188188
189- make_all_testfuncs ()
189+ make_all_2d_testfuncs ()
190+
191+ # 1d and 0d grid tests
192+
193+ ref_interpolator = Triangulation ([0 ,10 ,10 ,0 ],
194+ [0 ,0 ,10 ,10 ]).linear_interpolator ([1 ,10 ,5 ,2.0 ])
195+
196+ def equal_arrays (a1 ,a2 , tolerance = 1e-10 ):
197+ return np .all (np .absolute (a1 - a2 ) < tolerance )
198+
199+ def test_1d_grid ():
200+ res = ref_interpolator [3 :6 :2j ,1 :1 :1j ]
201+ assert equal_arrays (res , [[1.6 ],[1.9 ]])
202+
203+ def test_0d_grid ():
204+ res = ref_interpolator [3 :3 :1j ,1 :1 :1j ]
205+ assert equal_arrays (res , [[1.6 ]])
206+
207+ @image_comparison (baseline_images = ['delaunay-1d-interp' ], extensions = ['png' ])
208+ def test_1d_plots ():
209+ x_range = slice (0.25 ,9.75 ,20j )
210+ x = np .mgrid [x_range ]
211+ for y in xrange (2 ,10 ,2 ):
212+ plt .plot (x , ref_interpolator [x_range ,y :y :1j ])
0 commit comments