Example #1
0
    def __init__(self, ml_repo):
        self._ml_repo = ml_repo
        self._output = widgets.Output(
            layout=Layout(width='100%', height='100%'))
        self._model_selection = widgets.RadioButtons(
            options=self._ml_repo.get_names(MLObjectType.MODEL),
            #     value='pineapple',
            description='model:',
            disabled=False)

        self._train_model_sel = widgets.RadioButtons(
            options=['training', 'model'],
            value='model',
            description='param type:',
            disabled=False)
        self._param_sel = widgets.Select(description='parameter',
                                         disabled=False)
        self._get_parameter()

        self._train_model_sel.observe(self._get_parameter, 'value')
        self._data_selection = widgets.SelectMultiple(options=[])
        self._get_measures()

        self._plot_button = widgets.Button(description='plot')
        self._plot_button.on_click(self.plot)
        self._widget_main = widgets.VBox(children=[
            widgets.HBox(children=[
                self._plot_button, self._data_selection, self._model_selection,
                self._train_model_sel, self._param_sel
            ]), self._output
        ])
 def __init__(self, node, disabled=None):
     if disabled == None:
         self.disabled = [False, False, False]
     else:
         self.disabled = disabled
     self.is_categorical = node.vartype == 'categorical'
     self.name = node.name
     self.text = wd.Label(value=self.name, layout=wd.Layout(width='180px'))
     self.none = wd.RadioButtons(options=['No intervention'], disabled=self.disabled[0], layout=wd.Layout(width='150px'))
     self.fixed = wd.RadioButtons(options=['Fixed'], disabled=self.disabled[1], layout=wd.Layout(width='70px'))
     self.fixed.index = None
     if self.is_categorical:
         fixed_arg = wd.Dropdown(options=node.categories, disabled=True, layout=wd.Layout(width='100px'))
     else:
         fixed_arg = wd.BoundedFloatText(disabled=True, layout=wd.Layout(width='70px'))
     self.fixed_arg = fixed_arg
     self.range_visibility = 'hidden' if self.is_categorical else 'visible'
     self.range = wd.RadioButtons(options=['Range'], disabled=self.disabled[2], layout=wd.Layout(width='70px', visibility=self.range_visibility))
     self.range.index = None
     self.range_arg1_text = wd.Label(value='from', layout=wd.Layout(visibility=self.range_visibility, width='30px'))
     self.range_arg1 = wd.BoundedFloatText(min=node.min, max=node.max, disabled=True, layout=wd.Layout(width='70px', visibility=self.range_visibility))
     self.range_arg2_text = wd.Label(value='to', layout=wd.Layout(visibility=self.range_visibility, width='15px'))
     self.range_arg2 = wd.BoundedFloatText(min=node.min, max=node.max, disabled=True, layout=wd.Layout(width='70px', visibility=self.range_visibility))
     self.range_rand = wd.Checkbox(description='Randomise Order', disabled=True, indent=False, layout=wd.Layout(visibility=self.range_visibility))
     self.none.observe(self.none_observer, names=['value'])
     self.fixed.observe(self.fixed_observer, names=['value'])
     self.range.observe(self.range_observer, names=['value'])
     self.box = wd.HBox([self.text, self.none, self.fixed, self.fixed_arg, self.range, self.range_arg1_text, self.range_arg1, self.range_arg2_text, self.range_arg2, self.range_rand])
Example #3
0
    def _ui(self) -> List[W.Widget]:
        horizontal_options = W.RadioButtons(
            description="Horizontal",
            options=(
                ("Left", "left"),
                ("Center", "center"),
                ("Right", "right"),
            ),
        )
        vertical_options = W.RadioButtons(
            description="Vertical",
            options=(
                ("Top", "top"),
                ("Center", "center"),
                ("Bottom", "bottom"),
            ),
        )
        inside_options = W.Checkbox(description="Inside")
        horizontal_priority_options = W.Checkbox(
            description="Horizontal Priority")

        T.link((self, "horizontal"), (horizontal_options, "value"))
        T.link((self, "vertical"), (vertical_options, "value"))
        T.link((self, "h_priority"), (horizontal_priority_options, "value"))
        T.link((self, "inside"), (inside_options, "value"))

        return [
            horizontal_options,
            vertical_options,
            W.VBox([inside_options, horizontal_priority_options]),
        ]
Example #4
0
    def init_rs_ui(self):
        """阻力支撑分析ui"""

        with self._init_tip_label_with_step_x(
                self._rs_line_analyse, u'支撑阻力线分析',
                with_step_x=False) as (widget_list, _):
            self.rs_mode = widgets.RadioButtons(options={
                u'只分析支撑线': 0,
                u'只分析阻力线': 1,
                u'支撑线和阻力线': 2
            },
                                                value=0,
                                                description=u'分析模式:',
                                                disabled=False)
            widget_list.append(self.rs_mode)
            self.only_last = widgets.RadioButtons(options={
                u'最近的阻力线和支撑线': True,
                u'所有的阻力线和支撑线': False
            },
                                                  value=True,
                                                  description=u'最近的阻力线和支撑线',
                                                  disabled=False)
            widget_list.append(self.only_last)
        return widgets.VBox(
            widget_list,  # border='solid 1px',
            layout=self.tool_layout)
 def __init__(self, names):
     self.names = names
     self.varsx = wd.RadioButtons(options=names, layout=wd.Layout(width='200px'))
     self.varsy = wd.RadioButtons(options=names, layout=wd.Layout(width='200px'))
     self.colx = wd.VBox([wd.Label(value='x-Axis Variable'), self.varsx])
     self.coly = wd.VBox([wd.Label(value='y-Axis Variable'), self.varsy])
     self.hbox = wd.HBox([self.colx, self.coly])
     self.box = wd.VBox([self.hbox], layout=wd.Layout(margin='0 0 20px 0'))
Example #6
0
    def __init__(
        self,
        df,
        group_keys=None,
        filter_key=None,
        filter_values=None,
        method='max',
        plot_type='bar',
        output_file=None,
        transpose=True,
    ):
        self.df = df
        self.filtered_df = df

        index_names = sorted(df.index.names)

        self.w_parameters = widgets.SelectMultiple(
            options=index_names,
            value=group_keys if group_keys is not None else [index_names[0]],
            description='Group By',
        )
        valid_methods = ['min', 'max', 'mean', 'box']
        self.w_method = widgets.RadioButtons(
            options=valid_methods,
            value=method if method in valid_methods else 'max')
        self.w_method.observe(self.update_available_plot_types)

        valid_plot_types = ['line', 'bar']
        self.w_plot_type = widgets.RadioButtons(
            options=valid_plot_types,
            value=plot_type if plot_type in valid_plot_types else 'bar',
        )

        self.w_transpose = widgets.Checkbox(description='transpose',
                                            value=transpose)
        self.w_filter_key = widgets.Select(
            options=[''] + index_names[:],
            description='Filter field',
            value=filter_key if filter_key is not None else '',
        )
        self.w_filter_value = widgets.SelectMultiple(
            options=[], description='Filter value')
        self.update_possible_filter_values(None)
        if filter_values is not None:
            self.w_filter_value.value = filter_values

        self.w_file_name = widgets.Text(
            value=output_file if output_file is not None else '',
            description='output CSV Path',
        )
        self.w_overwrite = widgets.Checkbox(
            description='allows overwriting output files')
        self.w_output_button = widgets.Button(description='Generate CSV')
        self.w_export_output = widgets.Output()

        self.w_filter_key.observe(self.update_possible_filter_values)
        self.w_output_button.on_click(self.csv_callback)
        self.display()
Example #7
0
    def __init__(self):
        """构建回测需要的各个组件形成tab"""

        tip_label1 = widgets.Label(u'最优参数grid search暂不支持实时网络数据模式', layout=widgets.Layout(width='300px'))
        tip_label2 = widgets.Label(u'非沙盒模式需先用\'数据下载界面操作\'进行下载', layout=widgets.Layout(width='300px'))
        """沙盒数据与开放数据模式切换"""
        self.date_mode = widgets.RadioButtons(
            options=[u'沙盒数据模式', u'开放数据模式'],
            value=u'沙盒数据模式' if ABuEnv._g_enable_example_env_ipython else u'开放数据模式',
            description=u'数据模式:',
            disabled=False
        )
        self.date_mode.observe(self.on_data_mode_change, names='value')
        date_mode_box = widgets.VBox([tip_label1, tip_label2, self.date_mode])

        self.sc = WidgetSymbolChoice()
        self.bf = BuyFactorWGManager(add_button_style='grid')
        self.sf = SellFactorWGManager(show_add_buy=False, add_button_style='grid')

        sub_widget_tab = widgets.Tab()
        sub_widget_tab.children = [self.bf.widget, self.sf.widget, self.sc.widget]
        for ind, name in enumerate([u'买策', u'卖策', u'股池']):
            sub_widget_tab.set_title(ind, name)

        self.begin_grid_search = widgets.Button(description=u'开始寻找策略最优参数组合', layout=widgets.Layout(width='98%'),
                                                button_style='danger')
        self.begin_grid_search.on_click(self.run_grid_search)

        self.widget = widgets.VBox([date_mode_box, sub_widget_tab, self.begin_grid_search])
Example #8
0
    def init_golden_line_ui(self):
        """黄金分割ui"""
        with self._init_tip_label_with_step_x(
                self._golden_line_analyse, u'黄金分割分析',
                with_step_x=False) as (widget_list, _):
            self.golden_line_mode = widgets.RadioButtons(options={
                u'可视化黄金分隔带': 0,
                u'可视化黄金分隔带+关键比例': 1,
                u'可视化关键比例': 2
            },
                                                         value=0,
                                                         description=u'分隔模式:',
                                                         disabled=False)
            widget_list.append(self.golden_line_mode)
            pt_tip_label = widgets.Label(u'比例设置仅对\'可视化关键比例\'生效',
                                         layout=self.label_layout)
            self.pt_range = widgets.FloatRangeSlider(
                value=[0.2, 0.8],
                min=0.1,
                max=0.9,
                step=0.1,
                description=u'比例设置:',
                disabled=False,
                continuous_update=False,
                orientation='horizontal',
                readout=True,
                readout_format='.1f',
            )
            pt_box = widgets.VBox([pt_tip_label, self.pt_range])
            widget_list.append(pt_box)

        return widgets.VBox(
            widget_list,
            # border='solid 1px',
            layout=self.tool_layout)
Example #9
0
 def init_pair_speed_ui(self):
     """趋势敏感速度分析ui"""
     with self._init_tip_label_with_step_x(
             self._pair_speed_analyse, u'趋势敏感速度分析',
             with_step_x=False) as (widget_list, _):
         self.pair_speed_mode = widgets.RadioButtons(options={
             u'对比收盘敏感速度': 'close',
             u'对比涨跌敏感速度': 'p_change',
             u'对比最高敏感速度': 'high',
             u'对比最低敏感速度': 'low'
         },
                                                     value='close',
                                                     description=u'对比模式:',
                                                     disabled=False)
         widget_list.append(self.pair_speed_mode)
         resample_tip_label = widgets.Label(u'趋势敏感速度计算重采样周期',
                                            layout=self.label_layout)
         self.pair_resample = widgets.IntSlider(value=5,
                                                min=3,
                                                max=10,
                                                step=1,
                                                description=u'重采样',
                                                disabled=False,
                                                orientation='horizontal',
                                                readout=True,
                                                readout_format='d')
         resample_box = widgets.VBox(
             [resample_tip_label, self.pair_resample])
         widget_list.append(resample_box)
     return widgets.VBox(
         widget_list,
         # border='solid 1px',
         layout=self.tool_layout)
Example #10
0
    def __init__(self, state, **kwargs):
        super(Color, self).__init__(**kwargs)
        self.state = state

        self.widget_color = widgets.ColorPicker(description='color')
        link((self.state, 'color'), (self.widget_color, 'value'), color2hex)

        cmap_mode_options = type(self.state).cmap_mode.get_choice_labels(self.state)
        self.widget_cmap_mode = widgets.RadioButtons(options=cmap_mode_options, description='cmap mode')
        link((self.state, 'cmap_mode'), (self.widget_cmap_mode, 'value'))

        self.widget_cmap_att = LinkedDropdown(self.state, 'cmap_att',
                                              ui_name='color attribute',
                                              label='color attribute')

        self.widget_cmap_vmin = widgets.FloatText(description='color min')
        self.widget_cmap_vmax = widgets.FloatText(description='color max')
        self.widget_cmap_v = widgets.VBox([self.widget_cmap_vmin, self.widget_cmap_vmax])
        link((self.state, 'cmap_vmin'), (self.widget_cmap_vmin, 'value'), lambda value: value or 0)
        link((self.state, 'cmap_vmax'), (self.widget_cmap_vmax, 'value'), lambda value: value or 1)

        self.widget_cmap = widgets.Dropdown(options=colormaps, description='colormap')
        link((self.state, 'cmap'), (self.widget_cmap, 'label'), lambda cmap: colormaps.name_from_cmap(cmap), lambda name: colormaps[name])

        dlink((self.widget_cmap_mode, 'value'), (self.widget_color.layout, 'display'),     lambda value: None if value == cmap_mode_options[0] else 'none')
        dlink((self.widget_cmap_mode, 'value'), (self.widget_cmap.layout, 'display'),     lambda value: None if value == cmap_mode_options[1] else 'none')
        dlink((self.widget_cmap_mode, 'value'), (self.widget_cmap_att.layout, 'display'), lambda value: None if value == cmap_mode_options[1] else 'none')
        dlink((self.widget_cmap_mode, 'value'), (self.widget_cmap_v.layout, 'display'), lambda value: None if value == cmap_mode_options[1] else 'none')
        self.children = (self.widget_cmap_mode, self.widget_color, self.widget_cmap_att, self.widget_cmap_v, self.widget_cmap)
Example #11
0
    def init_regress_ui(self):
        """线性拟合ui"""

        with self._init_tip_label_with_step_x(self._regress_analyse,
                                              u'线性拟合分析') as (widget_list,
                                                             step_x):
            self.regress_step_x = step_x
            self.regress_mode_description = widgets.Textarea(
                value=u'1. 技术线最少拟合次数:\n'
                u'检测至少多少次拟合曲线可以代表原始曲线y的走势,'
                u'通过度量始y值和均线y_roll_mean的距离和原始y值和拟合回归的趋势曲线y_fit的距离的方法,默认使用metrics_rmse\n'
                u'2. 技术线最优拟合次数:\n'
                u'寻找多少次多项式拟合回归的趋势曲线可以完美的代表原始曲线y的走势\n'
                u'3. 可视化技术线拟合曲线:\n'
                u'通过步长参数在子金融序列中进行走势拟合,形成拟合曲线及上下拟合通道曲线,返回三条拟合曲线,组成拟合通道',
                disabled=False,
                layout=self.description_layout)
            widget_list.append(self.regress_mode_description)
            self.regress_mode = widgets.RadioButtons(options={
                u'技术线最少拟合次数': 0,
                u'技术线最优拟合次数': 1,
                u'可视化技术线拟合曲线': 2
            },
                                                     value=0,
                                                     description=u'拟合模式:',
                                                     disabled=False)
            widget_list.append(self.regress_mode)
        return widgets.VBox(
            widget_list,
            # border='solid 1px',
            layout=self.tool_layout)
Example #12
0
    def __init__(self, vols, figsize=(40,20), vmin=None, vmax=None, init_z=0, colour=False, cmap=None, title=None, save=None, save_exit=False):
        self.vols = vols
        self.save=save
        self.title=title
        self.save_exit=save_exit
#        print(vols[0].shape)
        if type(vols) is not list:
            if(len(vols.shape)==3):
                self.vols = [vols]
        n = len(vols)
        self.init_z = init_z
        self.figsize = figsize
        self.colour=colour
        self.view = [1,2,3,0] if self.colour else [0,1,2]
        self.cmap = ['gray' for i in range(len(vols))] if cmap is None else cmap*n
        self.vmin = [np.min(vols[i]) for i in range(n)] if vmin is None else vmin*n
        self.vmax = [np.max(vols[i]) for i in range(n)] if vmax is None else vmax*n
        
        if vols[0].shape[-1]>1:
            ipyw.interact(self.view_selection, view=ipyw.RadioButtons(
                options=['x-y','y-z', 'z-x'], value='x-y', 
                description='Slice plane selection:', disabled=False,
                style={'description_width': 'initial'}))
        else:
            self.plot_slice(0)
Example #13
0
def create_multipleChoice_widget(description, options, correct_answer):
    if correct_answer not in options:
        options.append(correct_answer)

    correct_answer_index = options.index(correct_answer)

    radio_options = [(words, i) for i, words in enumerate(options)]
    alternativ = widgets.RadioButtons(options=radio_options,
                                      description='',
                                      disabled=False)

    description_out = widgets.Output()
    with description_out:
        print(description)

    feedback_out = widgets.Output()

    def check_selection(b):
        a = int(alternativ.value)
        if a == correct_answer_index:
            s = '\x1b[6;30;42m' + "Riktig." + '\x1b[0m' + "\n" + "\n" "Correct! PYNQ is a framework developed by Xilinx to integrate Python and Python based applications within an FPGA architecture. 'PYNQ' comes from Python + ZYNQ--Zynq referring to a specific FPGA architecture developed by Xilinx."
        else:
            s = '\x1b[5;30;41m' + "Feil. " + '\x1b[0m' + "\n"  #red color
        with feedback_out:
            clear_output()
            print(s)
        return

    check = widgets.Button(description="submit")
    check.on_click(check_selection)

    return widgets.VBox([description_out, alternativ, check, feedback_out])
Example #14
0
def coherence_widget(data):
    style = {'description_width': 'initial'}
    m = interactive(
        run_all,
        {
            'manual': True,
            'manual_name': 'Run'
        },
        data=fixed(data),
        model_type=widgets.RadioButtons(options=['NMF', 'FA', 'LDA'],
                                        description="Choose Model",
                                        style=style,
                                        layout=Layout(width='250px')),
        n_topics=widgets.IntSlider(min=1,
                                   max=100,
                                   step=1,
                                   description='Number of topics',
                                   style=style,
                                   value=10,
                                   continuous_update=False),
        # coherence=widgets.SelectMultiple(options=['u_mass', 'c_v', 'c_uci', 'c_nmpi','all'],
        #                                  description='Coherence Measure',
        #                                  disabled=False)
    )

    return m
Example #15
0
    def init_distances_ui(self):
        """距离分析ui"""

        with self._init_widget_list_action(self.distances_analyse, u'距离分析',
                                           -1) as widget_list:
            self.distances_mode = widgets.RadioButtons(options={
                u'曼哈顿距离(L1范数)': 0,
                u'欧式距离(L2范数)': 1,
                u'余弦距离': 2
            },
                                                       value=0,
                                                       description=u'距离模式:',
                                                       disabled=False)
            widget_list.append(self.distances_mode)

            scale_end_label = widgets.Label(u'对结果矩阵进行标准化处理',
                                            layout=self.label_layout)
            self.scale_end = widgets.Checkbox(value=True,
                                              description=u'标准化',
                                              disabled=False)
            scale_end_box = widgets.VBox([scale_end_label, self.scale_end])
            widget_list.append(scale_end_box)

            similar_tip_label = widgets.Label(u'对结果矩阵进行转换相关性',
                                              layout=self.label_layout)
            self.to_similar = widgets.Checkbox(value=False,
                                               description=u'转换相关',
                                               disabled=False)
            to_similar_box = widgets.VBox([similar_tip_label, self.to_similar])
            widget_list.append(to_similar_box)

        return widgets.VBox(
            widget_list,  # border='solid 1px',
            layout=self.tool_layout)
Example #16
0
    def create_ui(self):
        # Create the active UI components. Height and width are specified in 'em' units. This is
        # a html size specification, size relative to current font size.
        self.viewing_checkbox = widgets.RadioButtons(description= 'Interaction mode:', 
                                                     options= ['edit', 'view'], 
                                                     value = 'edit')

        self.clearlast_button = widgets.Button(description= 'Clear Last', 
                                               width= '7em', 
                                               height= '3em')
        self.clearlast_button.on_click(self.clear_last)

        self.clearall_button = widgets.Button(description= 'Clear All', 
                                              width= '7em', 
                                              height= '3em') 
        self.clearall_button.on_click(self.clear_all)

        self.slice_slider = widgets.IntSlider(description='image z slice:',
                                              min=0,
                                              max=self.npa.shape[0]-1, 
                                              step=1, 
                                              value = int((self.npa.shape[0]-1)/2),
                                              width='20em')
        self.slice_slider.observe(self.on_slice_slider_value_change, names='value')
        
        # Layout of UI components. This is pure ugliness because we are not using a UI toolkit. Layout is done
        # using the box widget and padding so that the visible UI components are spaced nicely.
        bx0 = widgets.Box(padding=7, children=[self.slice_slider])
        bx1 = widgets.Box(padding=7, children = [self.viewing_checkbox])
        bx2 = widgets.Box(padding = 15, children = [self.clearlast_button])
        bx3 = widgets.Box(padding = 15, children = [self.clearall_button])
        return widgets.HBox(children=[widgets.HBox(children=[bx1, bx2, bx3]),bx0])
def create_multipleChoice_widget(description, options, correct_answer):
    if correct_answer not in options:
        options.append(correct_answer)

    correct_answer_index = options.index(correct_answer)

    layout = widgets.Layout(width='auto', height='auto')  #set width and height

    radio_options = [(words, i) for i, words in enumerate(options)]
    alternativ = widgets.RadioButtons(options=radio_options,
                                      description='',
                                      disabled=False,
                                      layout=layout)

    description_out = widgets.Output()
    with description_out:
        print(description)

    feedback_out = widgets.Output()

    def check_selection(b):
        a = int(alternativ.value)
        if a == correct_answer_index:
            s = "✅ richtig"
        else:
            s = "🚫 falsch"  #"❌ falsch"
        with feedback_out:
            clear_output()
            print(s)
        return

    check = widgets.Button(description="submit")
    check.on_click(check_selection)

    return widgets.VBox([description_out, alternativ, check, feedback_out])
Example #18
0
    def __init__(self,
                 question_str,
                 choices,
                 answer_idx,
                 wrong_description='',
                 correct_description='',
                 html_inserted=False):
        super().__init__()
        self.question_str = question_str
        self.choices = choices
        self.answer_idx = answer_idx
        self.wrong_description = wrong_description
        self.correct_description = correct_description

        self.radio = widgets.RadioButtons(options=choices, disabled=False)
        self.check_answer_btn = widgets.Button(
            description='Check',
            disabled=False,
            button_style='warning',
            tooltip='',
            icon='check',
            layout=widgets.Layout(width='90px'))
        self.after_description = widgets.HTML('')
        if html_inserted == False:
            self.question_str = convert_str2html(question_str)
        self.box = widgets.VBox([
            widgets.HTML(self.question_str), self.radio, self.check_answer_btn,
            self.after_description
        ],
                                layout=widgets.Layout(border='solid 2px',
                                                      padding='1rem'))
        display(self.box)
        self.check_answer_btn.on_click(self.c_check_clicked)
        global question_list  # Add this object into widget list
        question_list.append(self)
 def __init__(self, experiment, show='all'):
     self.experiment = experiment
     self.x_options = list(experiment.node.network.keys())
     self.y_options = self.x_options.copy()
     if show != 'all':
         for i in self.x_options.copy():
             if i not in show:
                 self.x_options.remove(i)
                 self.y_options.remove(i)
     self.x_options.sort()
     self.y_options.sort()
     self.y_options += ['None (Distributions Only)']
     self.textbox1 = wd.Dropdown(
         description='x-Axis Variable: ',
         value=self.x_options[0],
         options=self.x_options
     )
     self.textbox2 = wd.Dropdown(
         description='y-Axis Variable: ',
         value=self.y_options[0],
         options=self.y_options
     )
     self.button = wd.RadioButtons(
         options=list(experiment.data.keys()) + ['All'],
         layout={'width': 'max-content'},
         description='Group',
         disabled=False
     )
     self.observe()
     self.initTraces()
Example #20
0
    def __init__(self, state, **kwargs):
        super(Size, self).__init__(**kwargs)
        self.state = state

        self.widget_size = widgets.FloatSlider(description='size', min=0, max=10, value=self.state.size)
        link((self.state, 'size'), (self.widget_size, 'value'))
        self.widget_scaling = widgets.FloatSlider(description='scale', min=0, max=2, value=self.state.size_scaling)
        link((self.state, 'size_scaling'), (self.widget_scaling, 'value'))

        options = type(self.state).size_mode.get_choice_labels(self.state)
        self.widget_size_mode = widgets.RadioButtons(options=options, description='size mode')
        link((self.state, 'size_mode'), (self.widget_size_mode, 'value'))

        self.widget_size_att = LinkedDropdown(self.state, 'size_att', ui_name='size attribute', label='size attribute')

        self.widget_size_vmin = widgets.FloatText(description='size min')
        self.widget_size_vmax = widgets.FloatText(description='size min')
        self.widget_size_v = widgets.VBox([self.widget_size_vmin, self.widget_size_vmax])
        link((self.state, 'size_vmin'), (self.widget_size_vmin, 'value'), lambda value: value or 0)
        link((self.state, 'size_vmax'), (self.widget_size_vmax, 'value'), lambda value: value or 1)

        dlink((self.widget_size_mode, 'value'), (self.widget_size.layout, 'display'),     lambda value: None if value == options[0] else 'none')
        dlink((self.widget_size_mode, 'value'), (self.widget_size_att.layout, 'display'), lambda value: None if value == options[1] else 'none')
        dlink((self.widget_size_mode, 'value'), (self.widget_size_v.layout, 'display'), lambda value: None if value == options[1] else 'none')

        self.children = (self.widget_size_mode, self.widget_size, self.widget_scaling, self.widget_size_att, self.widget_size_v)
Example #21
0
 def get_date_choice(choice = widgets.RadioButtons(
     options = [('Created','created_at'), ('Pushed','pushed_at'), ('Updated','updated_at')],
     value = 'pushed_at',
     description = 'Date choice:',
     style = dict(description_width='initial')
 )):
     query['date_choice'].value = choice
Example #22
0
def wi6():
    style = {'description_width': 'initial'}
    wi800 = wi.RadioButtons(options=['1st order', '2nd order'],
                            description='Hermite-Rodriguez function:',
                            style=style)
    w80 = wi.FloatSlider(value=1,
                         min=0.005,
                         max=100,
                         step=0.05,
                         description='MU${}_1$ $A_M$ [mV]:')
    w81 = wi.FloatSlider(value=130,
                         min=2,
                         max=200,
                         step=0.1,
                         description='MU${}_n$ $A_M$ [mV]:')
    w82 = wi.FloatSlider(value=3,
                         min=0.1,
                         max=10,
                         step=0.05,
                         description='MU${}_1$ $\\lambda_M$ [ms]:')
    w83 = wi.FloatSlider(value=1,
                         min=0.1,
                         max=10,
                         step=0.05,
                         description='MU${}_n$ $\\lambda_M$ [ms]:')
    vb800 = wi.VBox([wi800, w80, w81, w82, w83])
    l8 = {'add_hr': wi800, 'v1': w80, 'v2': w81, 'd1': w82, 'd2': w83}
    vb800.layout = wi.Layout(width='320px')
    for i in vb800.children:
        i.layout = wi.Layout(width='300px')
        i.style = style
        i.continuous_update = False
    return vb800, l8
Example #23
0
    def init_relative_corr_ui(self):
        """全市场相对相关分析ui"""

        with self._init_widget_list_action(self.corr_relative_market_analyse,
                                           u'全市场相对相关分析', 2) as widget_list:
            relative_description = widgets.Textarea(
                value=u'全市场相对相关分析: \n'
                u'度量的是两目标(a,b)相对整个市场的相关性评级,它不关心某一个股票具体相关性的数值的大小\n'
                u'1. 计算a与市场中所有股票的相关性\n'
                u'2. 将所有相关性进行rank排序\n'
                u'3. 查询股票b在rank序列中的位置,此位置值即为结果\n',
                disabled=False,
                layout=self.description_layout)
            widget_list.append(relative_description)

            tip_label1 = widgets.Label(u'全市场相对相关分析不支持实时网络数据模式',
                                       layout=self.label_layout)
            tip_label2 = widgets.Label(u'非沙盒模式需先用\'数据下载界面操作\'进行下载',
                                       layout=self.label_layout)
            self.relative_corr_data_mode = widgets.RadioButtons(
                options={
                    u'沙盒数据模式': True,
                    u'本地数据模式': False
                },
                value=True,
                description=u'数据模式:',
                disabled=False)
            corr_market_box = widgets.VBox(
                [tip_label1, tip_label2, self.relative_corr_data_mode])
            widget_list.append(corr_market_box)

        return widgets.VBox(
            widget_list,  # border='solid 1px',
            layout=self.tool_layout)
Example #24
0
def build_RadioButtons(description, options, value, width, border=None):
    w = widgets.RadioButtons(description=description,
                             options=options,
                             value=value,
                             width=to_px(width))
    w.border = border
    return w
Example #25
0
    def init_coint_corr_ui(self):
        """全市场协整相关分析ui"""
        with self._init_widget_list_action(self.coint_corr_market_analyse,
                                           u'全市场协整相关分析', 1) as widget_list:
            coint_similar_description = widgets.Textarea(
                value=u'全市场协整相关分析: \n'
                u'综合利用相关和协整的特性返回查询的股票是否有统计套利的交易机会\n'
                u'1. 通过相关性分析筛选出与查询股票最相关的前100支股票作为种子\n'
                u'2. 从种子中通过计算协整程度来度量查询股票是否存在统计套利机会\n'
                u'3. 可视化整个过程\n',
                disabled=False,
                layout=self.description_layout)
            widget_list.append(coint_similar_description)

            tip_label1 = widgets.Label(u'全市场相对相关分析不支持实时网络数据模式',
                                       layout=self.label_layout)
            tip_label2 = widgets.Label(u'非沙盒模式需先用\'数据下载界面操作\'进行下载',
                                       layout=self.label_layout)
            self.coint_corr_data_mode = widgets.RadioButtons(
                options={
                    u'沙盒数据模式': True,
                    u'本地数据模式': False
                },
                value=True,
                description=u'数据模式:',
                disabled=False)
            corr_market_box = widgets.VBox(
                [tip_label1, tip_label2, self.coint_corr_data_mode])
            widget_list.append(corr_market_box)
        return widgets.VBox(
            widget_list,  # border='solid 1px',
            layout=self.tool_layout)
def select_parameter(things, description=""):
    return widgets.RadioButtons(
        options=things,
        description=description,
        disabled=False,
        layout=Layout(min_width='800px')
    )
Example #27
0
def create_multipleChoice_widget(description, options, correct_answer):
    if correct_answer not in options:
        options.append(correct_answer)

    correct_answer_index = options.index(correct_answer)

    radio_options = [(words, i) for i, words in enumerate(options)]
    alternativ = widgets.RadioButtons(options=radio_options,
                                      description='',
                                      disabled=False)

    description_out = widgets.Output()
    with description_out:
        print(description)

    feedback_out = widgets.Output()

    def check_selection(b):
        a = int(alternativ.value)
        if a == correct_answer_index:
            s = '\x1b[6;30;42m' + "Riktig." + '\x1b[0m' + "\n"  # green color
        else:
            s = '\x1b[5;30;41m' + "Feil. " + '\x1b[0m' + "\n"  # red color
        with feedback_out:
            clear_output()
            print(s)
        return

    check = widgets.Button(description="submit")
    check.on_click(check_selection)

    return widgets.VBox([description_out, alternativ, check, feedback_out])
Example #28
0
 def __init__(self, description, options):
     self.widget = widgets.RadioButtons(
         options=options,
         description=description,
         layout={'width': 'max-content'},
         style={'description_width': 'initial'},
         disabled=True)
def wi2():
    style = {'description_width': 'initial'}
    #Interface configuration
    w42 = wi.FloatSlider(value = 0.05, min = 0, max = 1, step = 0.05, 
                         description='Plateau/maximum intensity [%]:')
    w43 = wi.IntSlider(value = 0.1, min = 0, max = 3000, step = 100, description='Onset [ms]:')
    w44 = wi.IntSlider(value = 0.1, min = 0, max = 6000, step = 100, description='Plateau on [ms]:')
    w45 = wi.IntSlider(value = 6000, min = 0, max = 6000, step = 100, description='Plateau off [ms]:')
    w46 = wi.IntSlider(value = 6000, min = 0, max = 6000, step = 100, 
                       description='Offset [ms]:', style = style)
    w47 = wi.FloatSlider(value = 0.5, min = 0, max = 2, step = 0.1, description='Frequency [Hz]:')
    w48 = wi.IntSlider(value = 6000, min = 1000, max = 40000, step = 500, 
                       description='Duration [ms]:', style = style)
    w49 = wi.IntSlider(value = 20000, min = 15000, max = 40000, step = 1000, description='Sampling [Hz]:')
    w40 = wi.RadioButtons(options = ['Trapezoidal', 'Sinusoidal'], description = 'Modulation:', style = style)
    ui = wi.VBox([w49,w48,w42,w40,w43,w44,w45,w46,w47])
    ws = {"intensity": w42, "t0": w43, "t1": w44, "t2": w45, "t3": w46, "freq_sin": w47,
          "sample_time": w49, "sim_time": w48, "mode": w40}
    l11 = wi.link((w48, 'value'), (w44, 'max'))
    l12 = wi.link((w48, 'value'), (w45, 'max'))
    l12 = wi.link((w48, 'value'), (w46, 'max'))
    l12 = wi.link((w48, 'value'), (w43, 'max'))
    
    ui.children[0].layout = wi.Layout(width= '350px')
    for i in ui.children:
        i.layout = wi.Layout(width = '320px')
        i.style = style
        i.continuous_update = False
    return ws, ui
Example #30
0
def nbquiz(question, options, correct_answer, title='Quiz', debug=False):
    import ipywidgets as widgets

    if isinstance(correct_answer, str):
        correct_answer = int(eval(correct_answer))

    radio_options = [(quiztext(words), i) for i, words in enumerate(options)]
    alternatives = widgets.RadioButtons(options=radio_options,
                                        description='',
                                        disabled=False)

    title_out = widgets.HTML(
        value=f'<h4>{quiztext(title)}</h4><strong>{quiztext(question)}</strong>'
    )

    check = widgets.Button()

    def clear_selection(change):
        check.description = 'Submit'

    clear_selection(None)

    def check_selection(change):
        answer = int(alternatives.value) + 1

        if answer == correct_answer:
            check.description = 'Correct!'
        else:
            check.description = 'Incorrect!'
        return

    check.on_click(check_selection)
    alternatives.observe(clear_selection, names='value')

    return widgets.VBox([title_out, alternatives, check])