コード例 #1
0
    def build(self):
        '''constructs the main layout'''
        self.doc.title = "Covid-19 Graphs"

        self.entities_layout = lyt.column([], width_policy="max")
        self.build_entity_ui_rows(self.entities_layout)
        self.add_entity_layout = self.build_add_entity_layout()
        self.options_layout = self.build_options_layout()
        self.sources_layout = self.build_sources_layout()

        # Make tabs
        self.view_tab = mdl.Panel(child=self.entities_layout,
                                  title='View/Remove')
        self.add_tab = mdl.Panel(child=self.add_entity_layout, title='Add')
        self.options_tab = mdl.Panel(child=self.options_layout,
                                     title='Options')
        self.sources_tab = mdl.Panel(child=self.sources_layout, title='Info')
        self.tabs = mdl.Tabs(tabs=[
            self.view_tab, self.add_tab, self.options_tab, self.sources_tab
        ])
        for tab in self.tabs.tabs:
            tab.child.width_policy = 'min'
        self.tabs.width_policy = 'min'

        # Create a row layout for tabs + plot

        # actual plot will be replace by make_plot when we have data, and
        # are ready to draw
        self.plot = bokeh.plotting.figure(title="Dummy placeholder plot")
        self.updated = mdl.Title(text=self.UPDATE_FETCHING,
                                 align="right",
                                 text_font_size="8pt",
                                 text_font_style="normal")
        self.plot.add_layout(self.updated, "below")

        self.controls_plot = mdl.Row(self.tabs, self.plot)
        self.controls_plot.sizing_mode = "stretch_both"

        self.save_button = self.build_save_button()
        self.main_layout = mdl.Column(self.controls_plot,
                                      self.save_button,
                                      sizing_mode='stretch_both')
        self.doc.add_root(self.main_layout)

        self.add_updated_local_time_callback()
コード例 #2
0
ファイル: main.py プロジェクト: ltalirz/CCGenome
    When switching between bond_type color and something else,
    the plot needs to be redrawn.
    """
    global redraw_plot
    if (new == 'bond_type' or old == 'bond_type') and new != old:
        redraw_plot = True

    check_uniqueness(attr, old, new)


inp_x.on_change('value', check_uniqueness)
inp_y.on_change('value', check_uniqueness)
inp_clr.on_change('value', on_change_clr)

# Create a panel with a new layout
sizing_mode = 'fixed'
inputs = widgetbox(*controls, sizing_mode=sizing_mode)
l = layout([
    [inputs, p],
    [info_block],
], sizing_mode=sizing_mode)
update()

# Create each of the tabs
tab = bmd.Panel(child=l, title='Scatter plot')
tabs = bmd.widgets.Tabs(tabs=[tab])

# Put the tabs in the current document for display
curdoc().title = "C-C Cross-Coupling Genome"
curdoc().add_root(layout([html, tabs]))
コード例 #3
0
 def panel_file_management(self):
     # list_objects):
     self.layout_file_management()
     # list_objects)
     return bk_models.Panel(child=self.layout, title='File Management')
コード例 #4
0
        [[
            [[applet], [citation]],
            [[table_widget(entry)], [btn_download_table]],
        ],
         [
             get_grids(
                 cof_name,
                 df_tailcorrection=df_tailcorrection,
                 df_no_tailcorrection=df_no_tailcorrection,
             )
         ], [rdf_plot(cof_name)], [plot_info_]],
        sizing_mode=sizing_mode,
    )

else:
    l = layout(
        [[[[table_widget(entry)], [btn_download_table]]],
         [plot_info_not_sampled]],
        sizing_mode=sizing_mode,
    )

# We add this as a tab
tab = bmd.Panel(child=l, title=cof_name)
tabs = bmd.widgets.Tabs(tabs=[tab])

# Put the tabs in the current document for display
curdoc().title = (
    "Applicability of tail-corrections in the molecular simulations of porous materials"
)
curdoc().add_root(layout([html, tabs]))
コード例 #5
0
ファイル: sixteam.py プロジェクト: ArushiJeloka/scouting2020
 def panel(self, match):
     layout = self.create_layout(match)
     return bk_models.Panel(child=layout, title='Six Team Charts')
コード例 #6
0
 def panel(self):
     self.layout = self.create_layout()
     return bmodels.Panel(child=self.layout, title='Points Chart')
コード例 #7
0
    When switching between bond_type color and something else,
    the plot needs to be redrawn.
    """
    global redraw_plot
    if (new == "group" or old == "group") and new != old:
        redraw_plot = True

    check_uniqueness(attr, old, new)


inp_x.on_change("value", check_uniqueness)
inp_y.on_change("value", check_uniqueness)
inp_clr.on_change("value", on_change_clr)

# Create a panel with a new layout
sizing_mode = "fixed"
inputs = widgetbox(*controls, sizing_mode=sizing_mode)
l = layout([[inputs, p], [info_block]], sizing_mode=sizing_mode)
update()

# Create each of the tabs
tab = bmd.Panel(child=l, title="Scatter plot")
tabs = bmd.widgets.Tabs(tabs=[tab])

# Put the tabs in the current document for display
curdoc().title = (
    "Applicability of tail-corrections in the molecular simulations of porous materials"
)
curdoc().add_root(layout([html, tabs]))
コード例 #8
0
 def panel_1t(self, team, tasks):
     self.layout_1t(team, tasks)
     return bk_models.Panel(child=self.layout, title='One Team Charts')
コード例 #9
0
 def panel(self):
     self.layout = self.create_layout()
     return bmodels.Panel(child=self.layout, title='Ranking Table')
コード例 #10
0
tab3_plot = bkp.figure(title=title, plot_width=1600, plot_height=700)
# Format some stuff
tab3_plot.xaxis.axis_label = 'Phase'
tab3_plot.yaxis.axis_label = 'Flux'

# Add data to it
tab3_plot.scatter(x='phase', y='flux', source=tab3_data, color=color)

#### Lets add a slider
slider = bkm.Slider(title='Flux offset',
                    start=-1,
                    end=1,
                    value=0.0,
                    width=600,
                    step=0.01)
#TODO:
slider.on_change('value', alter_data)

# Make layouts, and add to document
tab1_layout = bkl.row(p)
tab2_layout = bkl.row(table)
tab3_layout = bkl.column([tab3_plot, slider])

tab1 = bkm.Panel(child=tab1_layout, title='Temperature Plot')
tab2 = bkm.Panel(child=tab2_layout, title='Heart Disease Data')
tab3 = bkm.Panel(child=tab3_layout, title='Slider demo')

tabs = bkm.widgets.Tabs(tabs=[tab1, tab2, tab3])

bkp.curdoc().add_root(tabs)
bkp.curdoc().add_periodic_callback(monitor_file, 10)
コード例 #11
0
ファイル: fit1d.py プロジェクト: DBerke/DRAGONS
    def __init__(self,
                 data_source,
                 fitting_parameters,
                 config,
                 reinit_params=None,
                 reinit_extras=None,
                 reinit_live=False,
                 order_param="order",
                 tab_name_fmt='{}',
                 xlabel='x',
                 ylabel='y',
                 domains=None,
                 function=None,
                 title=None,
                 **kwargs):
        """
        Parameters
        ----------
        data_source : array or function
            input data or the function to calculate the input data.  The input data
            should be [x, y] or [x, y, weights] or [[x, y], [x, y],.. or [[x, y, weights], [x, y, weights]..
            or, if a function, it accepts (config, extras) where extras is a dict of values based on reinit_extras
            and returns [[x, y], [x, y].. or [[x, y, weights], [x, y, weights], ...
        fitting_parameters : list of :class:`~geminidr.interactive.fit.fit1d.FittingParameters` or :class:`~geminidr.interactive.fit.fit1d.FittingParameters`
            Description of parameters to use for `fit_1d`
        config : Config instance describing primitive parameters and limitations
        reinit_params : list of str
            list of parameter names in config related to reinitializing fit arrays.  These cause the `data_source`
            function to be run to get the updated coordinates/weights.  Should not be passed if `data_source` is
            not a function.
        reinit_extras :
            Extra parameters to show on the left side that can affect the output of `data_source` but
            are not part of the primitive configuration.  Should not be passed if `data_source` is not a function.
        reinit_live :
            If False, supplies a button to call the `data_source` function and doesn't do so automatically when inputs
            are adjusted.  If `data_source` is known to be inexpensive, you can set this to `True`
        order_param : str
            Name of the parameter this primitive uses for `order`, to infer the min/max suggested values
        tab_name_fmt : str
            Format string for naming the tabs
        xlabel : str
            String label for X axis
        ylabel : str
            String label for Y axis
        domains : list
            List of domains for the inputs
        function : str
            ID of fit_1d function to use, if not a configuration option
        title : str
            Title for UI (Interactive <Title>)
        """
        super().__init__(config=config, title=title)

        # title_div = None
        # if title is not None:
        #     title_div = Div(text='<h2>%s</h2>' % title)

        # Make the widgets accessible from external code so we can update
        # their properties if the default setup isn't great
        self.widgets = {}

        # Make the panel with widgets to control the creation of (x, y) arrays

        # Function - either a dropdown or a label for the single option
        if 'function' in config._fields:
            fn = config.function
            fn_allowed = [k for k in config._fields['function'].allowed.keys()]

            # Dropdown for selecting fit_1D function
            self.function = Select(title="Fitting Function:",
                                   value=fn,
                                   options=fn_allowed)

            def fn_select_change(attr, old, new):
                def refit():
                    for fit in self.fits:
                        fit.set_function(new)
                        fit.perform_fit()

                self.do_later(refit)

            self.function.on_change('value', fn_select_change)
        else:
            if function is None:
                function = 'chebyshev'
            self.function = Div(text='Function: %s' % function)

        if reinit_params is not None or reinit_extras is not None:
            # Create left panel
            reinit_widgets = self.make_widgets_from_config(
                reinit_params, reinit_extras, reinit_live)

            # This should really go in the parent class, like submit_button
            if not reinit_live:
                self.reinit_button = bm.Button(label="Reconstruct points")
                self.reinit_button.on_click(self.reconstruct_points)
                self.make_modal(
                    self.reinit_button,
                    "<b>Recalculating Points</b><br/>This may take 20 seconds")
                reinit_widgets.append(self.reinit_button)

            self.reinit_panel = column(self.function, *reinit_widgets)
        else:
            # left panel with just the function selector (Chebyshev, etc.)
            self.reinit_panel = column(self.function)

        # Grab input coordinates or calculate if we were given a callable
        # TODO revisit the raging debate on `callable` for Python 3
        if callable(data_source):
            self.reconstruct_points_fn = data_source
            data = data_source(config, self.extras)
            # For this, we need to remap from
            # [[x1, y1, weights1], [x2, y2, weights2], ...]
            # to allx=[x1,x2..] ally=[y1,y2..] all_weights=[weights1,weights2..]
            allx = list()
            ally = list()
            all_weights = list()
            for dat in data:
                allx.append(dat[0])
                ally.append(dat[1])
                if len(dat) >= 3:
                    all_weights.append(dat[2])
            if len(all_weights) == 0:
                all_weights = None
        else:
            self.reconstruct_points_fn = None
            if reinit_params:
                raise ValueError(
                    "Saw reinit_params but data_source is not a callable")
            if reinit_extras:
                raise ValueError(
                    "Saw reinit_extras but data_source is not a callable")
            allx = data_source[0]
            ally = data_source[1]
            if len(data_source) >= 3:
                all_weights = data_source[2]
            else:
                all_weights = None

        # Some sanity checks now
        if isinstance(fitting_parameters, list):
            if not (len(fitting_parameters) == len(allx) == len(ally)):
                raise ValueError("Different numbers of models and coordinates")
            self.nfits = len(fitting_parameters)
        else:
            if allx.size != ally.size:
                raise ValueError("Different (x, y) array sizes")
            self.nfits = 1

        self.reinit_extras = [] if reinit_extras is None else reinit_extras

        kwargs.update({'xlabel': xlabel, 'ylabel': ylabel})
        if order_param and order_param in self.config._fields:
            field = self.config._fields[order_param]
            if hasattr(field, 'min') and field.min:
                kwargs['min_order'] = field.min
            else:
                kwargs['min_order'] = 1
            if hasattr(field, 'max') and field.max:
                kwargs['max_order'] = field.max
            else:
                kwargs['max_order'] = field.default * 2
        else:
            kwargs['min_order'] = 1
            kwargs['max_order'] = 10

        self.tabs = bm.Tabs(tabs=[], name="tabs")
        self.tabs.sizing_mode = 'scale_width'
        self.fits = []
        if self.nfits > 1:
            if domains is None:
                domains = [None] * len(fitting_parameters)
            if all_weights is None:
                all_weights = [None] * len(fitting_parameters)
            for i, (fitting_parms, domain, x, y, weights) in \
                    enumerate(zip(fitting_parameters, domains, allx, ally, all_weights), start=1):
                tui = Fit1DPanel(self, fitting_parms, domain, x, y, weights,
                                 **kwargs)
                tab = bm.Panel(child=tui.component,
                               title=tab_name_fmt.format(i))
                self.tabs.tabs.append(tab)
                self.fits.append(tui.fit)
        else:
            tui = Fit1DPanel(self, fitting_parameters[0], domains, allx[0],
                             ally[0], all_weights[0], **kwargs)
            tab = bm.Panel(child=tui.component, title=tab_name_fmt.format(1))
            self.tabs.tabs.append(tab)
            self.fits.append(tui.fit)
コード例 #12
0
 def panel(self, team):
     layout = self.layout_1t(team)
     return bk_models.Panel(child=layout, title='One Team Charts')