def get_main_widgets(image_list, continuous_update): # Define test_name selector image_selector = widgets.Dropdown(options=image_list, value=image_list[0], description='Img Name:', continuous_update=continuous_update, layout=widgets.Layout( width='100%', grid_area='im_selector')) # Define selectors for int range sliders; We'll define value and max, min # once we know image size x_size_selector = widgets.IntRangeSlider( step=1, description='Width:', continuous_update=continuous_update, orientation='horizontal', layout=widgets.Layout(width='98%', grid_area='width')) y_size_selector = widgets.IntRangeSlider( step=1, description='Height:', continuous_update=continuous_update, orientation='vertical', layout=widgets.Layout(height='90%', width='auto', grid_area='height')) return image_selector, x_size_selector, y_size_selector
def draw_app(self, h, s, v): """ Draw the sliders and the output widget This just runs once at app startup. """ self.sliders = dict() self.sliders['h'] = w.IntRangeSlider(value=h, min=0, max=180, step=1, description='Hue: ', continuous_update=False) self.sliders['s'] = w.IntRangeSlider(value=s, min=0, max=255, step=1, description='Sat: ', continuous_update=False) self.sliders['v'] = w.IntRangeSlider(value=v, min=0, max=255, step=1, description='Val: ', continuous_update=False) self.slider_line = w.HBox( [self.sliders['h'], self.sliders['s'], self.sliders['v']]) self.out = w.interactive_output(self.update_marker, self.sliders) self.container.children = [self.slider_line, self.output_widget] self.update_marker(self.sliders['h'].value, self.sliders['s'].value, self.sliders['v'].value)
def hsv_select_live(limit = 10, fps = 4): global current_display_id display = IPython.display.display('', display_id=current_display_id) current_display_id += 1 # Create sliders h = widgets.IntRangeSlider(value=[0, 179], min=0, max=179, description='Hue:', continuous_update=True, layout=widgets.Layout(width='100%')) s = widgets.IntRangeSlider(value=[0, 255], min=0, max=255, description='Saturation:', continuous_update=True, layout=widgets.Layout(width='100%')) v = widgets.IntRangeSlider(value=[0, 255], min=0, max=255, description='Value:', continuous_update=True, layout=widgets.Layout(width='100%')) display.update(h) display.update(s) display.update(v) # Live masked video for the thread def show_masked_video(): global cap, released if not released: cap.release() released = True cap = cv2.VideoCapture(video_port) resize_cap(cap, resize_width, resize_height) released = False start = time.time() while time.time() - start < limit: frame = None try: frame = cap.read()[1] except: print('Video feed is in use. Please run again or restart kernel.') if frame is None: print('Video feed is in use. Please run again or restart kernel.') break else: try: hsv_min = (h.value[0], s.value[0], v.value[0]) hsv_max = (h.value[1], s.value[1], v.value[1]) frame = cv2.flip(frame, 1) frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) img_hsv = cv2.cvtColor(frame, cv2.COLOR_RGB2HSV) mask = cv2.inRange(img_hsv, hsv_min, hsv_max) img_masked = cv2.bitwise_and(frame, frame, mask = mask) f = BytesIO() PIL.Image.fromarray(img_masked).save(f, 'jpeg') img_jpeg = IPython.display.Image(data=f.getvalue()) display.update(img_jpeg) time.sleep(1.0 / fps) except Exception as e: print(e) break cap.release() released = True print('END OF HSV SELECT') # Open video on new thread (needed for slider update) hsv_thread = threading.Thread(target=show_masked_video) hsv_thread.start()
def interactive(self): """Create an interactive plot""" xlim_slider = widgets.IntRangeSlider(min=0, max=self.Nx-1, value=[0,self.Nx-1]) ylim_slider = widgets.IntRangeSlider(min=0, max=self.Ny-1, value=[0,self.Ny-1]) self.iplot = interactive(self.plot, field=['U','V','W','T'], time=(0, self.Ntimes-1), index=(0, self.N-1), xlim=xlim_slider, ylim=ylim_slider) display(self.iplot)
def with_trend_lines(self, field="Close", panel=0, edge_periods=3, rescale_digits=4, degrees=(-90, 90), angles=30, rho_digits=2): plt.close(self.fig) accumulation, lookup =\ ta_trend_lines(get_pandas_object(self.df, field), edge_periods, rescale_digits, degrees, angles, rho_digits) def plot_trend_line(time, touches): ax = self.axis[panel] td = timedelta(days=time[0]), timedelta(days=time[1]) # first remove all previous trend lines ax.lines = [ l for l in ax.lines if not l.get_label().startswith(".Trend") ] # then select the lines from the lookup table filtered = lookup[(lookup["touch"] >= touches[0]) & (lookup["touch"] <= touches[1])] filtered = filtered[(filtered["distance"] >= td[0]) & (filtered["distance"] <= td[1])] for i, tl in filtered.iterrows(): points = tl["points"][0], tl["points"][-1] ax.plot([p[0] for p in points], [p[1] for p in points], label=".Trend") return self.fig # TODO later add a wg.IntSlider to extend the trend lines from ots last point min_ts, max_ts = 2, len(self.df) time_silder = wg.IntRangeSlider(value=[max_ts, max_ts], min=min_ts, max=max_ts, step=1, continuous_update=False, description='Period:') min_to, max_to = 2, lookup["touch"].max() touch_silder = wg.IntRangeSlider(value=[min_to, max_to], min=min_to, max=max_to, step=1, continuous_update=False, description='Touches:') wg.interact(plot_trend_line, time=time_silder, touches=touch_silder) self.fig.show() return self
def interactive_plot_shot( traces, figsize=(30, 10), initial_xlim=(0, 50), initial_ylim=(0, 100), fontsize=15, xticklabel=None, **kwargs, ): plt.rcParams.update({'font.size': fontsize}) fr = widgets.IntRangeSlider(min=0, max=traces.shape[0], step=5, value=[ max([initial_xlim[0], 0]), min([traces.shape[0], initial_xlim[1]]) ], continuous_update=False) gain = widgets.FloatSlider(min=.0000001, max=2000, step=1, value=1, continuous_update=False) clip = fixed(1) ylim = widgets.IntRangeSlider(min=0, max=traces.shape[1], step=5, value=[ max([0, initial_ylim[0]]), min([traces.shape[1], initial_ylim[1]]) ], continuous_update=False) traces = fixed(traces) figsize = fixed(figsize) def plot_traces(picks): interact( plot_shot, traces=traces, picks=fixed(picks), figsize=figsize, fr=fr, gain=gain, clip=clip, ylim=ylim, xticklabel=fixed(xticklabel), **kwargs, ) return plot_traces
def __init__(self, state: ntm.TopicModelContainer): super().__init__(state=state) slider_opts: dict = { 'continuous_update': False, 'layout': dict(width='140px'), 'readout': False, 'handle_color': 'lightblue', } self.text_id: str = f"{str(uuid.uuid4())[:6]}" self.network_data: pd.DataFrame = None self.topic_proportions: pd.DataFrame = None self.titles: pd.DataFrame = None timespan: tuple[int, int] = self.inferred_topics.timespan yearspan: tuple[int, int] = self.inferred_topics.startspan(10) self._text: w.HTML = wu.text_widget(self.text_id) self._year_range_label: w.HTML = w.HTML("Years") self._year_range: w.IntRangeSlider = w.IntRangeSlider( min=timespan[0], max=timespan[1], step=1, value=yearspan, **slider_opts ) self._scale_label: w.HTML = w.HTML("<b>Scale</b>") self._scale: w.FloatSlider = w.FloatSlider(min=0.0, max=1.0, step=0.01, value=0.1, **slider_opts) self._threshold_label: w.HTML = w.HTML("<b>Threshold</b>") self._threshold: w.FloatSlider = w.FloatSlider(min=0.01, max=1.0, step=0.01, value=0.10, **slider_opts) self._network_layout: w.Dropdown = w.Dropdown( options=LAYOUT_OPTIONS, value='Fruchterman-Reingold', layout=dict(width='140px') ) self._output_format: w.Dropdown = w.Dropdown( description='', options=OUTPUT_OPTIONS, value='network', layout=dict(width='140px') ) self._output: w.Output = w.Output() self._content_placeholder: w.Box = None self._extra_placeholder: w.Box = w.VBox() self._topic_ids: w.SelectMultiple = w.SelectMultiple( options=self.topic_id_options(), value=[], rows=11, layout=dict(width='120px') ) self._exclude_or_include: w.ToggleButton = w.ToggleButton( value=True, description='Exclude', icon='', layout=dict(width="120px") ) self._topics_ids_header: w.HTML = w.HTML("<b>Topics</b>") self._n_docs_label: w.HTML = w.HTML("<b>Documents in common</b>") self._n_docs: w.IntSlider = w.IntSlider(min=1, max=100, step=1, value=10, **slider_opts) self._node_range_label: w.HTML = w.HTML("<b>Node size</b>") self._node_range: w.IntRangeSlider = w.IntRangeSlider(min=10, max=100, step=1, value=(20, 60), **slider_opts) self._edge_range_label: w.HTML = w.HTML("<b>Edge size</b>") self._edge_range: w.IntRangeSlider = w.IntRangeSlider(min=1, max=20, step=1, value=(2, 6), **slider_opts)
def get_hidden_widgets(image_list, continuous_update): # Define mod sliders for cropping function; We'll define value and max, min # once we know image size x_mod = widgets.IntRangeSlider(layout=widgets.Layout(display='none')) y_mod = widgets.IntRangeSlider(continuous_update=continuous_update, step=1, layout=widgets.Layout(display='none')) im_mod = widgets.Select(options=image_list, value=image_list[0], layout=widgets.Layout(width='0%', height='0%', visibility='hidden')) return im_mod, x_mod, y_mod
def __init__(self, state: TopicModelContainer | dict): super().__init__(state=state) slider_opts = { 'continuous_update': False, 'layout': dict(width='140px'), 'readout': False, 'handle_color': 'lightblue', } timespan: tuple[int, int] = self.inferred_topics.year_period yearspan: tuple[int, int] = self.inferred_topics.startspan(10) self._threshold_label: w.HTML = w.HTML("<b>Threshold</b>") self._threshold: w.FloatSlider = w.FloatSlider(min=0.01, max=1.0, value=0.05, step=0.01, **slider_opts) self._max_count_label: w.HTML = w.HTML("<b>Max result count</b>") self._max_count: w.IntSlider = w.IntSlider(min=1, max=50000, value=500, **slider_opts) self._year_range_label: w.HTML = w.HTML("Years") self._year_range: w.IntRangeSlider = w.IntRangeSlider( min=timespan[0], max=timespan[1], step=1, value=yearspan, **slider_opts ) self._output: w.Output = w.Output(layout={'width': '50%'}) self._extra_placeholder: w.Box = None self._content_placeholder: w.Box = None self._compute: w.Button = w.Button(description='Show!', button_style='Success', layout={'width': '140px'}) self._auto_compute: w.ToggleButton = w.ToggleButton(description="auto", value=False, layout={'width': '140px'}) self._table_widget: TableWidget = None self.click_handler: Callable[[pd.Series, Any], None] = None
def BV_LPR_interact(self, anodic_range=0.15, cathodic_range=0.15): """ interact method of BV_LPR_manual anodic/cathodic range vs open circuit, default initial value +-0.15 V """ import ipywidgets as widgets layout = widgets.Layout(width="500px", height="40px") df_IE = self.data # define good range start_val = self.info.get_quick_Ecorr() - cathodic_range end_val = self.info.get_quick_Ecorr() + anodic_range start = (np.abs(self.info.data["E"].values - (start_val))).argmin() end = (np.abs(self.info.data["E"].values - (end_val))).argmin() # remove unused line try: self.line_bvf.remove() except: pass #### widgets.interact( self.BV_LPR_manual, data_range=widgets.IntRangeSlider( min=0, max=len(df_IE), step=1, value=[start, end], continuous_update=False, layout=layout, ), df_IE=widgets.fixed(df_IE), fname=widgets.fixed(self.info.filename), taf_init=widgets.IntSlider( min=0, max=len(df_IE), step=1.0, value=200, continuous_update=False, layout=layout, ), R=widgets.FloatSlider( min=-20000, max=20000, step=1.0, value=0, continuous_update=False, layout=layout, ), auto_zoom=widgets.Checkbox(value=True, description="Auto_zoom", disabled=False), grid_on=widgets.Checkbox(value=True, description="Grid_on", disabled=False), logx=widgets.Checkbox(value=True, description="logx", disabled=False), )
def integerRange(self): """Return a IntRangeSlider.""" return widgets.IntRangeSlider(value=self.start, min=self.min, max=self.max, step=self.step, description=self.description, orientation=self.orientation)
def __init__(self, pivot_key_specs: ox.PivotKeySpecArg, state: ntm.TopicModelContainer, **kwargs): super().__init__(pivot_key_specs, state=state, **kwargs) slider_opts: dict = { 'continuous_update': False, 'layout': dict(width='140px'), 'readout': False, 'handle_color': 'lightblue', } self.text_id: str = f"{str(uuid.uuid4())[:6]}" self.network_data: pd.DataFrame = None self.topic_proportions: pd.DataFrame = None self.titles: pd.DataFrame = None self.topics_ids_header: str = "<b>Ignore topics</b>" self.default_threshold: float = 0.5 timespan: tuple[int, int] = self.inferred_topics.timespan yearspan: tuple[int, int] = self.inferred_topics.startspan(10) self._text: w.HTML = wu.text_widget(self.text_id) self._year_range_label: w.HTML = w.HTML("Years") self._year_range: w.IntRangeSlider = w.IntRangeSlider(min=timespan[0], max=timespan[1], step=1, value=yearspan, **slider_opts) self._scale_label: w.HTML = w.HTML("Scale") self._scale: w.FloatSlider = w.FloatSlider(min=0.0, max=1.0, step=0.01, value=0.1, **slider_opts) self._threshold_label: w.HTML = w.HTML("<b>Threshold</b>") self._threshold: w.FloatSlider = w.FloatSlider(min=0.0, max=1.0, step=0.01, value=0.10, **slider_opts) self._network_layout: w.Dropdown = w.Dropdown( options=LAYOUT_OPTIONS, value='Fruchterman-Reingold', layout=dict(width='140px')) self._output_format: w.Dropdown = w.Dropdown( description='', options=OUTPUT_OPTIONS, value='network', layout=dict(width='140px')) self._output: w.Output = w.Output() self._content_placeholder: w.Box = None self._extra_placeholder: w.Box = w.VBox() self._topic_ids: w.SelectMultiple = w.SelectMultiple( options=self.topic_id_options(), value=[], rows=8, layout=dict(width='180px'))
def _init_widget(self): """构建AbuPickStockShiftDistance策略参数界面""" self.description = widgets.Textarea( value=u'位移路程比选股因子策略:\n' u'将交易目标走势每月计算价格位移路程比,根据比值进行选股,选取波动程度不能太大,也不太小的目标:\n' u'1. 定义位移路程比大于参数阀值的月份为大波动月\n' u'2. 一年中大波动月数量 < 最大波动月个数\n' u'3. 一年中大波动月数量 > 最小波动月个数\n', description=u'位移路程', disabled=False, layout=self.description_layout) threshold_sd_label1 = widgets.Label(u'设大波动位移路程比阀值,期货市场建议2.0及以上', layout=self.label_layout) threshold_sd_label2 = widgets.Label(u'设大波动位移路程比阀值,股票市场建议3.0及以上', layout=self.label_layout) self.threshold_sd = widgets.FloatSlider( value=2.0, min=1.0, max=6.0, step=0.1, description=u'阀值', disabled=False, orientation='horizontal', readout=True, readout_format='.1f', ) self.threshold_sd_box = widgets.VBox( [threshold_sd_label1, threshold_sd_label2, self.threshold_sd]) max_cnt_label = widgets.Label(u'选取大波动月数量 < 下面设定的最大波动月个数', layout=self.label_layout) min_cnt_label = widgets.Label(u'选取大波动月数量 > 下面设定的最小波动月个数', layout=self.label_layout) self.min_max_range = widgets.IntRangeSlider( value=[1, 4], min=0, max=10, step=1, description=u'范围', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d', ) self.min_max_box = widgets.VBox( [max_cnt_label, min_cnt_label, self.min_max_range]) # 这个策略不要可自定义xd,限定选股周期为1年 self.widget = widgets.VBox( [ self.description, self.threshold_sd_box, self.min_max_range, self.reversed_box, self.add_box ], # border='solid 1px', layout=self.widget_layout)
def make_range_slider(value, _min, _max, step, description, disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d'): widg = widgets.IntRangeSlider(value=value, min=_min, max=_max, description=description, disabled=disabled, continuous_update=continuous_update, orientation=orientation, readout=readout, readout_format=readout_format) return widg
def getRangeSlider(val0, val1, des=""): return widgets.IntRangeSlider(value=[val0, val1], min=1, max=60, step=1, description=des, disabled=False, continuous_update=False, orientation='horizontal', readout=True)
def envpartners_distances(dynophore): """ Plot interaction distances for a superfeatures as frame series or histogram. Parameters ---------- dynophore : dynophores.Dynophore Dynophore. Returns ------- function Parameterized IPyWidgets interact function. """ style = {"description_width": "initial"} superfeature_ids = (dynophore.frequency.loc["any", :].sort_values( ascending=False).index.to_list()) func = interact_manual( plot.static.envpartners_distances, dynophore=fixed(dynophore), superfeature_ids=widgets.SelectMultiple( options=superfeature_ids, value=[superfeature_ids[0]], description="Superfeature ID(s):", style=style, ), kind=widgets.ToggleButtons( options=["line", "hist"], description="Plot style", button_style="", tooltips=["Series", "Histogram"], ), frame_range=widgets.IntRangeSlider( value=[0, dynophore.n_frames], min=0, max=dynophore.n_frames, step=1, description="Frames range:", style=style, ), frame_step_size=widgets.BoundedIntText( # Default value results in displayed 1000 frames value=math.floor(dynophore.n_frames / 1000), min=1, max=dynophore.n_frames - 1, step=1, description="Frames step size:", style=style, ), ) return func
def setUp(self): self.slider = widgets.IntRangeSlider(value=[5, 7], min=0, max=10, step=1, description='Test:', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d')
def get_color_widget(color_name): return widgets.IntRangeSlider( value=[0, 255], min=0, max=255, step=1, description=color_name + ':', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d')
def get_para_widgets(): para_selector = widgets.IntRangeSlider(value=[10, 30], min=3, max=60, step=1, description="True Strength Index", disabled=False, continuous_update=False, orientation='horizontal', readout=True) para_selector_widgets = [para_selector] return para_selector_widgets
def inter_set_params(self): self.read_metadata() t0, tf = (self.metadata['frames'][0], self.metadata['frames'][-1]) available_fov_list = self.metadf["fov"].unique().tolist() selection = ipyw.interactive(self.set_params, {"manual":True}, fov_list=ipyw.SelectMultiple(options=available_fov_list),\ t_range=ipyw.IntRangeSlider(value=[t0, tf],\ min=t0,max=tf,step=1,description='Time Range:',disabled=False), organism=ipyw.Textarea(value='',\ placeholder='Organism imaged in this experiment.',description='Organism:',disabled=False),\ microscope=ipyw.Textarea(value='',placeholder='Microscope used in this experiment.',\ description='Microscope:',disabled=False),notes=ipyw.Textarea(value='',\ placeholder='General experiment notes.',description='Notes:',disabled=False),) display(selection)
def __init__(self, name="Unknown"): import ipywidgets self.image_widget = ipywidgets.Output( layout={'border': '1px solid black'}) self.image_widget2 = ipywidgets.Output() self.frame_bounds_widgets = [ipywidgets.Output(), ipywidgets.Output()] self.name_widget = ipywidgets.Text(name) self.ok = ipywidgets.Button(description="\tTrophallaxis", icon="check-circle") self.ok.on_click(lambda x: self.on_click(action="trophallaxis")) self.antennation = ipywidgets.Button(description="\tAntennation", icon="check-circle") self.antennation.on_click( lambda x: self.on_click(action="antennation")) self.nope = ipywidgets.Button(description="\tNothing", icon="ban") self.nope.on_click(lambda x: self.on_click(action="nothing")) self.idk = ipywidgets.Button(description="\tMaybe troph.", icon="puzzle-piece") self.idk.on_click(lambda x: self.on_click(action="unsure")) self.skip = ipywidgets.Button(description="\tSkip", icon="recycle") self.skip.on_click(lambda x: self.on_click(action="skip")) self.frame_idx_slider = ipywidgets.IntRangeSlider( value=[0, 0], step=1, description="Frames:", min=0, readout=True, readout_format="d", continuous_update=False) self.frame_idx_slider.observe(self.on_slider_changed, names='value') from IPython.display import display display(self.name_widget) display(self.image_widget) display( ipywidgets.VBox([ ipywidgets.HBox([self.frame_idx_slider]), ipywidgets.HBox([self.ok, self.antennation, self.idk]), ipywidgets.HBox([self.nope, self.skip]) ])) display( ipywidgets.HBox([ self.image_widget2, ipywidgets.VBox(self.frame_bounds_widgets) ])) self.current_interaction_idx = 0 self.generator = None
def bins_range_slider(desc: str) -> ipw.IntRangeSlider: return ipw.IntRangeSlider( value=[0, LAST_BIN], min=0, max=LAST_BIN, step=1, description=desc, disabled=False, continuous_update=False, orientation="horizontal", readout=False, readout_format="d", )
def get_region_data(): @widgets.interact(region_name=widgets.Dropdown( options=regions, value='Central', description='Region:', disabled=False,), selected_years=widgets.IntRangeSlider(min=2010, max=2018, value=(2015,2016))) def get_region_data_fun(region_name, selected_years, do_plot=True): start_year, end_year = selected_years meteo_files = sorted([f for f in Path(f'./data/meteo/{region_name}/').glob(f"{region_name}.20??")]) years = [int(f.name.split(".")[1]) for f in meteo_files] do_files = [f for y, f in zip(years, meteo_files) if start_year <= y <= end_year] if do_plot: plot_meteo(do_files) else: return do_files
def plot(): widgets.interact( plot_, var=widgets.Dropdown(description="variable", options=["GDP", "Investment"]), unit=widgets.RadioButtons(description="units", options=["chained", "current"]), years=widgets.IntRangeSlider( description="years", min=1966, max=2017, value=[1980, 2017], continuous_update=False, ), )
def int_range_widget(title, value, min, max, step): style = {'description_width': 'initial'} return ipw.IntRangeSlider(value=value, min=min, max=max, step=step, description=title, disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d', layout=ipw.Layout(width='auto'), style=style)
def superfeatures_occurrences(dynophore): """ Generate interactive widget to plot the superfeatures' occurrences as barcode. Parameters ---------- dynophore : dynophores.Dynophore Dynophore. Returns ------- function Parameterized IPyWidgets interact function. """ style = {"description_width": "initial"} superfeature_ids = (dynophore.frequency.loc["any", :].sort_values( ascending=False).index.to_list()) func = interact_manual( plot.static.superfeatures_occurrences, dynophore=fixed(dynophore), superfeature_ids=widgets.SelectMultiple( options=["all"] + superfeature_ids, value=["all"], description="Superfeature ID(s):", style=style, ), color_by_feature_type=widgets.Checkbox( value=True, description="Color by feature type"), frame_range=widgets.IntRangeSlider( value=[0, dynophore.n_frames], min=0, max=dynophore.n_frames, step=1, description="Frames range:", style=style, ), frame_step_size=widgets.BoundedIntText( # Default value results in displayed 1000 frames value=math.floor(dynophore.n_frames / 1000), min=1, max=dynophore.n_frames - 1, step=1, description="Frames step size:", style=style, ), ) return func
def bins_range_slider(desc: str, binning: int) -> ipw.IntRangeSlider: last_bin = binning - 1 return ipw.IntRangeSlider( value=[0, last_bin], min=0, max=last_bin, step=1, description=desc, disabled=False, continuous_update=False, orientation="horizontal", readout=False, readout_format="d", )
def __init__(self, state: mc.TopicModelContainer): super().__init__(state=state) # FIXME, calculator: tm.MemoizedTopicPrevalenceOverTimeCalculator if caching.... slider_opts = { 'continuous_update': False, 'layout': dict(width='140px'), 'readout': False, 'handle_color': 'lightblue', } timespan: tuple[int, int] = self.inferred_topics.timespan yearspan: tuple[int, int] = self.inferred_topics.startspan(10) self.titles: pd.DataFrame = None weighings = [(x['description'], x['key']) for x in tm.YEARLY_AVERAGE_COMPUTE_METHODS] self._text_id: str = TEXT_ID self._text: w.HTML = widgets_utils.text_widget(TEXT_ID) self._flip_axis: w.ToggleButton = w.ToggleButton( value=False, description='Flip', icon='', layout=dict(width="80px")) self._aggregate: w.Dropdown = w.Dropdown(options=weighings, value='max_weight', layout=dict(width="140px")) self._threshold_label: w.HTML = w.HTML("<b>Threshold</b>") self._threshold: w.FloatSlider = w.FloatSlider(min=0.01, max=1.0, value=0.05, step=0.01, **slider_opts) self._year_range_label: w.HTML = w.HTML("Years") self._year_range: w.IntRangeSlider = w.IntRangeSlider(min=timespan[0], max=timespan[1], step=1, value=yearspan, **slider_opts) self._output_format: w.Dropdown = w.Dropdown( options=['Heatmap', 'Table'], value='Heatmap', layout=dict(width="140px")) self._auto_compute.layout.width = "80px" self._output: w.Output = w.Output() self._content_placeholder: w.Box = None self._extra_placeholder: w.Box = None
def envpartners_all_in_one(dynophore): """ Plot interaction data for a superfeature, i.e. occurrences (frame series) and distances (frame series and histogram). Parameters ---------- dynophore : dynophores.Dynophore Dynophore. Returns ------- function Parameterized IPyWidgets interact function. """ style = {"description_width": "initial"} superfeature_ids = (dynophore.frequency.loc["any", :].sort_values( ascending=False).index.to_list()) func = interact_manual( plot.static.envpartners_all_in_one, dynophore=fixed(dynophore), superfeature_id=widgets.Select( options=superfeature_ids, value=superfeature_ids[0], description="Superfeature ID(s):", style=style, ), frame_range=widgets.IntRangeSlider( value=[0, dynophore.n_frames], min=0, max=dynophore.n_frames, step=1, description="Frames range:", style=style, ), frame_step_size=widgets.BoundedIntText( # Default value results in displayed 1000 frames value=math.floor(dynophore.n_frames / 1000), min=1, max=dynophore.n_frames - 1, step=1, description="Frames step size:", style=style, ), ) return func
def remove_outlier_interact(self, ): import ipywidgets as widgets layout = widgets.Layout(width="500px", height="40px") widgets.interact( self.remove_outlier_manual, data_range=widgets.IntRangeSlider( min=0, max=0, step=1, value=[0, len(self.data)], continuous_update=False, layout=layout, ), )