@@ -201,3 +201,65 @@ def test_auto_goal():
201201 simple (learner , auto_goal (duration = 1e-2 , learner = learner ))
202202 t_end = time .time ()
203203 assert t_end - t_start >= 1e-2
204+
205+
206+ def test_simple_points_per_ask ():
207+ """Test that the simple runner respects the points_per_ask parameter (PR #484)."""
208+
209+ def f (x ):
210+ return x ** 2
211+
212+ # Test with 1D learner asking for multiple points at once
213+ learner1 = Learner1D (f , (- 1 , 1 ))
214+ simple (learner1 , npoints_goal = 20 , points_per_ask = 5 )
215+ assert learner1 .npoints >= 20
216+
217+ # Test with 2D learner
218+ def f2d (xy ):
219+ x , y = xy
220+ return x ** 2 + y ** 2
221+
222+ learner2 = Learner2D (f2d , ((- 1 , 1 ), (- 1 , 1 )))
223+ simple (learner2 , npoints_goal = 32 , points_per_ask = 8 )
224+ assert learner2 .npoints >= 32
225+
226+ # Test that default behavior (points_per_ask=1) is preserved
227+ learner3 = Learner1D (f , (- 1 , 1 ))
228+ simple (learner3 , npoints_goal = 15 )
229+ assert learner3 .npoints >= 15
230+
231+ # Test performance improvement: more points per ask = fewer ask calls
232+ ask_count = 0
233+ original_ask = Learner1D .ask
234+
235+ def counting_ask (self , n , tell_pending = True ):
236+ nonlocal ask_count
237+ ask_count += 1
238+ return original_ask (self , n , tell_pending )
239+
240+ # Monkey patch to count ask calls
241+ Learner1D .ask = counting_ask
242+
243+ try :
244+ # Test with points_per_ask=1 (default)
245+ learner4 = Learner1D (f , (- 1 , 1 ))
246+ ask_count = 0
247+ simple (learner4 , npoints_goal = 10 , points_per_ask = 1 )
248+ ask_count_single = ask_count
249+
250+ # Test with points_per_ask=5
251+ learner5 = Learner1D (f , (- 1 , 1 ))
252+ ask_count = 0
253+ simple (learner5 , npoints_goal = 10 , points_per_ask = 5 )
254+ ask_count_batch = ask_count
255+
256+ # When asking for 5 points at a time, we should have fewer ask calls
257+ assert ask_count_batch < ask_count_single
258+
259+ # Both learners should have reached their goal
260+ assert learner4 .npoints >= 10
261+ assert learner5 .npoints >= 10
262+
263+ finally :
264+ # Restore original method
265+ Learner1D .ask = original_ask
0 commit comments