upxo.interfaces.user_inputs.nbWidgets module
nbWidgets.py — Interactive ipywidgets controls for UPXO Jupyter notebooks.
All functions in this module are designed to be called inside a Jupyter cell. They render a widget panel immediately on call and return a state dict that can be read in the next cell after the user has interacted with the controls.
Functions
mdf_peak_selector Peak checklist for MDF downstream filtering. make_property_stats_widgets Control panel for grain-role property plots. read_property_stats_widgets Read current widget values into a plain dict.
- upxo.interfaces.user_inputs.nbWidgets.mdf_peak_selector(peaks: dict) dict[source]
Display an interactive ipywidgets checklist so the user can pick which MDF peaks to retain for downstream analysis.
All peaks are pre-ticked. Click Confirm selection to update
selected_peaks.
- upxo.interfaces.user_inputs.nbWidgets.selectProps_twinGS(props: list[str] | None = None, groups: list[str] | None = None, default_ncols: int = 2, default_fontsize: float = 12.0) dict[source]
Build and display the ipywidgets control panel for
plot_grain_role_property_stats.Returns a dict with keys
prop_checkboxes,group_checkboxes,ncols_slider, andfontsize_slider. Pass the returned dict directly toread_property_stats_widgets()to extract current values before calling the plot function.- Parameters:
props (list of str, optional) – Property names to show. Subset of
['area', 'aspect_ratio', 'perimeter', 'solidity', 'n_neighbours']. Only'area'is ticked by default.groups (list of str, optional) – Group names to show (all ticked by default). Subset of
['pure_parents', 'pure_twins', 'intermediates', 'non_role'].default_ncols (int) – Initial value of the columns slider (0 = single row).
default_fontsize (float) – Initial font size value.
- Returns:
- ``{‘prop_checkboxes’: dict, ‘group_checkboxes’: dict,
’ncols_slider’: IntSlider, ‘fontsize_slider’: FloatSlider}``
- Return type:
- upxo.interfaces.user_inputs.nbWidgets.readProps_twinGS(widgets_dict: dict) dict[source]
Read current values from the dict returned by
selectProps_twinGS().
- upxo.interfaces.user_inputs.nbWidgets.selectProps_reprComp(props: list[str] | None = None) dict[source]
Show a property-selection checklist for MC–EBSD comparison.
Lightweight variant of
selectProps_twinGS()with only property checkboxes — no grain-group controls, no layout sliders. All properties are pre-ticked. Must be called inside a Jupyter cell.- Parameters:
props (list of str, optional) – Property names to show. Defaults to the standard set of shared float properties between
prop_ebsd_merged_dfand MCgsset[k].prop.- Returns:
{'prop_checkboxes': dict}— pass toreadProps_reprComp().- Return type:
- upxo.interfaces.user_inputs.nbWidgets.readProps_reprComp(widgets_dict: dict) list[str][source]
Read selected property names from the dict returned by
selectProps_reprComp().- Parameters:
widgets_dict (dict) – The dict returned by
selectProps_reprComp().- Returns:
Names of the ticked properties.
- Return type:
- upxo.interfaces.user_inputs.nbWidgets.selectSlices_reprComp(grain_count_rank_ng) dict[source]
Show an ipywidgets checklist of MC time slices so the user can choose which to carry forward into property-distribution comparison.
Each checkbox label shows the slice key, grain count, ratio relative to the de-twinned EBSD, and eligibility. Eligible slices (
eligible == 1) are pre-ticked; ineligible slices are shown but unticked. Must be called inside a Jupyter cell.- Parameters:
grain_count_rank_ng (pd.DataFrame) – The DataFrame stored in
rg.grain_count_rank_ngafter callingrank_mcgs_by_n(). Expected columns:n_mc,ratio,eligible.- Returns:
{'slice_checkboxes': dict[key, Checkbox]}— pass toreadSlices_reprComp().- Return type:
- upxo.interfaces.user_inputs.nbWidgets.readSlices_reprComp(widgets_dict: dict) list[source]
Read selected slice keys from the dict returned by
selectSlices_reprComp().- Parameters:
widgets_dict (dict) – The dict returned by
selectSlices_reprComp().- Returns:
MC time-slice keys (same type as
grain_count_rank_ngindex) for the ticked entries.- Return type: