Skip to content

Instantly share code, notes, and snippets.

from bokeh.models.widgets import Button, Dropdown
from bokeh.layouts import column, widgetbox, row
from bokeh.io import show, curdoc, output_notebook
from bokeh.application.handlers import FunctionHandler
from bokeh.application import Application
def modify_doc(doc):
# This works with Bokeh server and jupyter:
main_button = Button(label='Refresh')
from bokeh.io import show, curdoc
from bokeh.models.widgets import Button
from bokeh.layouts import row, widgetbox
from bokeh.models import ColumnDataSource, CustomJS
from bokeh import events
button = Button(label = 'Send HelloWorld to console')
source = ColumnDataSource(data=dict())
@nicain
nicain / download_on_button_example.py
Last active June 14, 2017 18:40
bokeh JS download columndatasource
from bokeh.io import curdoc
from bokeh.models.widgets import Button, DataTable, TableColumn
from bokeh.layouts import column, widgetbox
from bokeh.models import ColumnDataSource, CustomJS
import pandas as pd
data_df = pd.DataFrame(dict(A=[0,1,2], B=[3,4,5]))
table_source = ColumnDataSource(data=data_df)
data_table = DataTable(source=table_source, width=200, height=200)
column_list = [TableColumn(field=key, title=key) for key in ['A', 'B']]
@nicain
nicain / add_tab.py
Created June 14, 2017 23:24
Create new tab for tabs
from bokeh.models.widgets import Panel, Tabs, Button
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.layouts import column, widgetbox
p1 = figure(plot_width=300, plot_height=300)
p1.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
tab1 = Panel(child=p1, title="circle")
p2 = figure(plot_width=300, plot_height=300)
from bokeh.models.widgets import Panel, Tabs, Button
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.layouts import column, widgetbox
p1 = figure(plot_width=300, plot_height=300)
p1.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
tab1 = Panel(child=p1, title="circle")
tabs = Tabs(tabs=[tab1])
@nicain
nicain / debug_required_pynwb.py
Created July 21, 2017 20:54
Example to help debug require=True not getting enforced on NWBGroupSpec
from pynwb.spec import NWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec
import numpy as np
from pynwb import get_class, load_namespaces
mylab = 'alleninstitute'
ns_path = "%s.namespace.yaml" % mylab
ext_source = "%s.extensions.yaml" % mylab
ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', mylab)
ext = NWBGroupSpec('A custom FiringRate for my lab',
@nicain
nicain / extension_1.py
Last active July 31, 2017 18:53
hackathon
from pynwb import NWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec
import numpy as np
ns_path = "mylab.namespace.yaml"
ext_source = "mylab.extensions.yaml"
nwb_as = NWBAttributeSpec('unit', 'str', 'the population name', value = 'Hz')
ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', "mylab")
ext = NWBGroupSpec('A custom TimeSeries for my lab',
import sys
sys.path.append('/Users/nicholasc/Janelia_NWB_Hackathon/pynwb/src')
from pynwb import NWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec
import numpy as np
from pynwb import get_class, load_namespaces
from datetime import datetime
from pynwb import NWBFile
from form.backends.hdf5 import HDF5IO
from pynwb import get_build_manager
@nicain
nicain / table_extension_sandbox.py
Created August 1, 2017 15:22
Table Extension model Sandbox (debug)
from pynwb import NWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec
from pynwb import get_class, load_namespaces
ns_path = "table.namespace.yaml"
ext_source = "table.extensions.yaml"
ns_builder = NWBNamespaceBuilder('A table namespace', "table")
ext = NWBGroupSpec('A table group',
neurodata_type_def='Table')
@nicain
nicain / extension_module_dataset_example.py
Created August 3, 2017 19:39
extension_module_dataset_example
from pynwb import NWBNamespaceBuilder, NWBDatasetSpec, NWBAttributeSpec
import numpy as np
from pynwb import get_class, load_namespaces
from datetime import datetime
from pynwb import NWBFile
from form.backends.hdf5 import HDF5IO
from pynwb import get_build_manager
ns_path = "mylab.namespace.yaml"