@@ -621,29 +621,15 @@ def tune_kernel(
621
621
if strategy in strategy_map :
622
622
strategy = strategy_map [strategy ]
623
623
else :
624
- raise ValueError (f"Unkown strategy { strategy } , must be one of: { ', ' .join (list (strategy_map .keys ()))} " )
625
-
626
- # make strategy_options into an Options object
627
- if tuning_options .strategy_options :
628
- if not isinstance (strategy_options , Options ):
629
- tuning_options .strategy_options = Options (strategy_options )
630
-
631
- # select strategy based on user options
632
- if "fraction" in tuning_options .strategy_options and not tuning_options .strategy == "random_sample" :
633
- raise ValueError (
634
- 'It is not possible to use fraction in combination with strategies other than "random_sample". '
635
- 'Please set strategy="random_sample", when using "fraction" in strategy_options'
636
- )
637
-
638
- # check if method is supported by the selected strategy
639
- if "method" in tuning_options .strategy_options :
640
- method = tuning_options .strategy_options .method
641
- if method not in strategy .supported_methods :
642
- raise ValueError ("Method %s is not supported for strategy %s" % (method , tuning_options .strategy ))
643
-
644
- # if no strategy_options dict has been passed, create empty dictionary
645
- else :
646
- tuning_options .strategy_options = Options ({})
624
+ # check for user-defined strategy
625
+ if hasattr (strategy , "tune" ) and callable (strategy .tune ):
626
+ # user-defined strategy
627
+ pass
628
+ else :
629
+ raise ValueError (f"Unkown strategy { strategy } , must be one of: { ', ' .join (list (strategy_map .keys ()))} " )
630
+
631
+ # ensure strategy_options is an Options object
632
+ tuning_options .strategy_options = Options (strategy_options or {})
647
633
648
634
# if no strategy selected
649
635
else :
0 commit comments