Esempio n. 1
0
    def _create_loss_figure(self,
                            df: pd.DataFrame,
                            width: int = 1000,
                            height: int = 300):
        colors = itertools.cycle(palette)
        df.columns = [str(i) for i in df.columns]
        ds = ColumnDataSource(df)

        fig = Figure(y_axis_type="log", width=width, height=height)
        fig.below[0].formatter.use_scientific = False
        for column, color in zip(df.columns, colors):
            glyph = fig.line(x='index', y=column, source=ds, color=color)
            fig.add_tools(
                HoverTool(tooltips=[("epoch", "@index")] +
                          [(f"loss_{column}", f"@{column}")],
                          mode='vline',
                          renderers=[glyph]))

        def update_epoch(self: App, event):
            epoch = reduce(lambda a, b: a if a[0] < b[0] else b,
                           [(abs(e - event.x), e)
                            for e in self.state.epochs])[1]
            self.widget_epoch_select.value = str(epoch)

        fig.on_event(DoubleTap, partial(update_epoch, self))
        return fig
Esempio n. 2
0
def update_Cr_value(attr,old,new):
    glCollision['Crval'] = new #      /output

crSlider = LatexSlider(
                   title="\\text{Coefficient of Restitution:}",
                   value=1, start=0, end=1, step=0.1,width=2*slider_width+10
                  )
crSlider.on_change('value',update_Cr_value)

#################### Moving the balls through the mouse #######################

def on_mouse_move(event):
    if not glob_active.data["Active"][0]:
        system.modify_location(event)

playGround.on_event(Pan, on_mouse_move)


'''
###############################################################################
Change language
###############################################################################
'''
def changeLanguage():
    [lang] = flags.data["lang"]
    if lang == "en":
        setDocumentLanguage('de')
    elif lang == "de":
        setDocumentLanguage('en')

def setDocumentLanguage(lang):
Esempio n. 3
0
plot = Figure(plot_width=400, plot_height=400)
plot.line('x',
          'y',
          source=source,
          line_width=3,
          line_alpha=0.6,
          color='#ed5565')
plot.add_tools(MoveUpTool())


def move_up_callback(event):
    print("adaddaad")


plot.on_event(MoveUpEvent, move_up_callback)

callback_single = CustomJS(args=dict(source=source),
                           code="""
            var data = source.data;
            var f = cb_obj.value
            var x = data['x']
            var y = data['y']
            for (var i = 0; i < x.length; i++) {
                y[i] = Math.pow(x[i], f)
            }
            source.change.emit();
        """)

callback_ion = CustomJS(args=dict(source=source),
                        code="""