Selectable Types
The select and multi_select methods enable categorical parameter configuration. These methods support both single and multiple value selection with flexible validation options.
I'll help improve the documentation for the select and multi_select parameters by adding the requested information. Here's the enhanced version:
Select & Multi_select Parameters
The select and multi_select methods enable categorical parameter configuration using either lists or dictionaries. These methods support both single and multiple value selection with flexible validation options.
Function Signatures
select
def select(
options: Union[Dict[ValidKeyType, Any], List[ValidKeyType]],
*,
name: str,
default: Optional[ValidKeyType] = None,
options_only: bool = False
) -> Anymulti_select
def multi_select(
options: Union[Dict[ValidKeyType, Any], List[ValidKeyType]],
*,
name: str,
default: List[ValidKeyType] = None,
options_only: bool = False
) -> List[Any]Parameters
options: Either a list of valid values or a dictionary mapping keys to valuesdefault: Default value(s) if none provided (single value for select, list for multi_select)options_only: When True, only allows values from the predefined options
Pre-defined Parameter Forms
List Form
Use when the parameter keys and values are identical:
Dictionary Form
Use when parameter keys need to map to different values:
Value Resolution
When using dictionary form, the configuration system maps input keys to their corresponding values:
When to Use Dictionary Form?
Dictionary form is recommended when working with:
Long string values:
{"haiku": "claude-3-haiku-20240307"}Precise numeric values:
{"small": 1.524322}Object references:
{"rf": RandomForest(n_estimators=100)}None values:
{"none": None}Complex objects like tuples:
{"small": (1, 2)}
Special Value Examples
Dictionary form enables you to define None values and complex objects that cannot be easily represented in list form:
Default Values
The default parameter must be a valid option from the predefined choices. For dictionary form, the default must be one of the keys (not values).
List Form Defaults
When using list form, the default must be one of the items in the list:
Dictionary Form Defaults
When using dictionary form, the default must be one of the dictionary keys:
Instantiating With Missing Default Values
If no default is provided, a value must be specified during configuration:
Value Validation
The options_only parameter determines how strictly values are validated:
Valid Instantiation Examples
Invalid Instantiation Examples
Required Name Parameter
All hp.* calls that you want to be overrideable must include an explicit name="..." argument.
Last updated
Was this helpful?