(
    op: "PlannedOperator",
    num_grids: Optional[float] = None,
    pgo: Optional[PGO] = None,
    data_schema: Dict[str, Any] = {},
)
Top level function: given a lale operator, returns a list of hp grids.

    Parameters
    ----------
    op : The lale PlannedOperator
    num_grids: integer or float, optional
        if set to an integer => 1, it will determine how many parameter grids will be returned (at most)
        if set to an float between 0 and 1, it will determine what fraction should be returned
        note that setting it to 1 is treated as in integer.  To return all results, use None
Top level function: given a lale operator, returns a list of hp grids.
Top level function : given a lale operator returns a list of hp grids .
def get_search_space_grids(
    op: "PlannedOperator",
    num_grids: Optional[float] = None,
    pgo: Optional[PGO] = None,
    data_schema: Dict[str, Any] = {},
) -> List[SearchSpaceGrid]:
    """Top level function: given a lale operator, returns a list of hp grids.

    Parameters
    ----------
    op : The lale PlannedOperator
    num_grids: integer or float, optional
        if set to an integer => 1, it will determine how many parameter grids will be returned (at most)
        if set to an float between 0 and 1, it will determine what fraction should be returned
        note that setting it to 1 is treated as in integer.  To return all results, use None
    """
    all_parameters = op_to_search_space_grids(op, pgo=pgo, data_schema=data_schema)
    if should_print_search_space("true", "all", "search_space_grids", "grids"):
        name = op.name()
        if not name:
            name = "an operator"
        print(
            f"search space grids for {name}:\n{search_space_grids_to_string(all_parameters)}"
        )
    if num_grids is None:
        return all_parameters
    else:
        if num_grids <= 0:
            warnings.warn(
                f"get_search_space_grids(num_grids={num_grids}) called with a non-positive value for lale_num_grids"
            )
            return []
        if num_grids >= 1:
            samples = math.ceil(num_grids)
            if samples >= len(all_parameters):
                return all_parameters
            else:
                warnings.warn(
                    f"get_search_space_grids(num_grids={num_grids}) sampling {math.ceil(num_grids)}/{len(all_parameters)}"
                )
                return random.sample(all_parameters, math.ceil(num_grids))
        else:
            samples = round(len(all_parameters) * num_grids)
            warnings.warn(
                f"get_search_space_grids(num_grids={num_grids}) sampling {samples}/{len(all_parameters)}"
            )
            return random.sample(all_parameters, samples)
def get_search_space_grids ( op : "PlannedOperator" , num_grids : Optional [ float ] = None , pgo : Optional [ PGO ] = None , data_schema : Dict [ str , Any ] = { } , ) -> List [ SearchSpaceGrid ] : all_parameters = op_to_search_space_grids ( op , pgo = pgo , data_schema = data_schema ) if should_print_search_space ( "true" , "all" , "search_space_grids" , "grids" ) : name = op . name ( ) if not name : name = "an operator" print ( f"search space grids for {name}:\n{search_space_grids_to_string(all_parameters)}" ) if num_grids is None : return all_parameters else : if num_grids <= 0 : warnings . warn ( f"get_search_space_grids(num_grids={num_grids}) called with a non-positive value for lale_num_grids" ) return [ ] if num_grids >= 1 : samples = math . ceil ( num_grids ) if samples >= len ( all_parameters ) : return all_parameters else : warnings . warn ( f"get_search_space_grids(num_grids={num_grids}) sampling {math.ceil(num_grids)}/{len(all_parameters)}" ) return random . sample ( all_parameters , math . ceil ( num_grids ) ) else : samples = round ( len ( all_parameters ) * num_grids ) warnings . warn ( f"get_search_space_grids(num_grids={num_grids}) sampling {samples}/{len(all_parameters)}" ) return random . sample ( all_parameters , samples )