Skip to content

expselectionfilter

expselectionfilter

Module for experiment selection filters

Classes

ExpCheckboxSelectionFilter

ExpCheckboxSelectionFilter(default_selected=3)

Bases: ExperimentFilter

Filters experiments with checkboxes

Source code in niceml/experiments/filters/expselectionfilter.py
def __init__(self, default_selected: int = 3):
    self.default_selected = default_selected
Functions
filter
filter(exp_list)

Filters experiments with checkboxes

Source code in niceml/experiments/filters/expselectionfilter.py
def filter(self, exp_list: List[ExperimentData]) -> List[ExperimentData]:
    """Filters experiments with checkboxes"""
    exp_out_list: List[ExperimentData] = []
    st.sidebar.markdown("Experiments:")
    for idx, exp_data in enumerate(exp_list):
        if st.sidebar.checkbox(
            exp_format_func(exp_data), value=(idx < self.default_selected)
        ):
            exp_out_list.append(exp_data)
    return exp_out_list
render
render(exp_list)

Not required because experiments should be filtered at the end

Source code in niceml/experiments/filters/expselectionfilter.py
def render(self, exp_list: List[ExperimentData]):
    """Not required because experiments should be filtered at the end"""
    pass

ExpMultiSelectFilter

ExpMultiSelectFilter(default_selected=3)

Bases: ExperimentFilter

Filters experiments with multiselect

Source code in niceml/experiments/filters/expselectionfilter.py
def __init__(self, default_selected: int = 3):
    self.default_selected = default_selected
Functions
filter
filter(exp_list)

Filters experiments with multiselect

Source code in niceml/experiments/filters/expselectionfilter.py
def filter(self, exp_list: List[ExperimentData]) -> List[ExperimentData]:
    """Filters experiments with multiselect"""
    id_dict = {exp_format_func(x): x for x in exp_list}
    id_list = list(id_dict.keys())
    default_values = id_list[: self.default_selected]
    selects = st.sidebar.multiselect(
        label="Experiments", options=id_list, default=default_values
    )
    return [id_dict[cur_id] for cur_id in selects]
render
render(exp_list)

Not required because experiments should be filtered at the end

Source code in niceml/experiments/filters/expselectionfilter.py
def render(self, exp_list: List[ExperimentData]):
    """Not required because experiments should be filtered at the end"""
    pass

Functions

exp_format_func

exp_format_func(exp_data)

default formatting for experiments in the dashboard

Source code in niceml/experiments/filters/expselectionfilter.py
def exp_format_func(exp_data: ExperimentData) -> str:
    """default formatting for experiments in the dashboard"""
    out_str: str = (
        f"{exp_data.exp_info.experiment_prefix}-"
        f"{exp_data.get_short_id()}-{exp_data.get_run_date().date()}"
    )
    return out_str