Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def interact(obj):
tab = widgets.Tab()
base_style = widgets.ButtonStyle()
selected_style = widgets.ButtonStyle(button_color='#DDFFDD', font_weight='bold')
if isinstance(obj, hl.Table):
glob = widgets.Button(description='globals',
layout=widgets.Layout(width='150px', height='30px'))
rows = widgets.Button(description='rows',
layout=widgets.Layout(width='150px', height='200px'))
rows.style = selected_style
globals_frames = []
globals_frames.append(widgets.HTML(
f'<p><big>Global fields, with one value in the dataset.</big></p>\n'
f'<p>Commonly used methods:</p>\n'
f'<ul>'
f'<li>{html_link("annotate_globals", "https://hail.is/docs/0.2/hail.Table.html#hail.Table.annotate_globals")}: '
f'add new global fields.</li>'
f'</ul>'
))
append_struct_frames(obj.globals.dtype, globals_frames)
row_frames = []
row_frames.append(widgets.HTML(
def __init__(self, lsid="", **kwargs):
super(GPModuleWidget, self).__init__(lsid)
widgets.DOMWidget.__init__(self, **kwargs)
self.lsid = lsid
def pick_backend(self):
backends = get_backend_list()
fields_to_display = ["codename", "date", "protocol", "argv"]
if backends is None or len(backends) == 0:
return None
names = sorted(list(backends.keys()))
select = widgets.Dropdown(options=names, value=names[len(names) - 1])
button = widgets.Button(description="Connect")
max_len = 0
for f in fields_to_display:
if len(f) > max_len:
max_len = len(f)
# setup labels to display fields from `fields_to_display`
label_hboxes = []
dynamic_labels = {}
for f in fields_to_display:
static_label = widgets.Label(value="{} :".format(f))
dynamic_label = widgets.Label(value="")
dynamic_labels[f] = dynamic_label
label_hboxes.append(widgets.HBox([static_label, dynamic_label]))
Q1=interactive(
csem_fields_app,
rho0=FloatText(value=1e8, description='$\\rho_{0} \ (\Omega m)$'),
rho1=FloatText(value=0.3, description='$\\rho_{1} \ (\Omega m)$'),
rho2=FloatText(value=1., description='$\\rho_{2} \ (\Omega m)$'),
rho3=FloatText(value=100., description='$\\rho_{3} \ (\Omega m)$'),
rho4=FloatText(value=1., description='$\\rho_{4} \ (\Omega m)$'),
zsrc=FloatText(value=-950., description='src height (m)'),
rv_rh=FloatText(value=1., description='$\\rho_{2 \ v} / \\rho_{2 \ h}$'),
dz1=FloatText(value=1000., description="dz1 (m)"),
dz2=FloatText(value=1000., description="dz2 (m)"),
dz3=FloatText(value=200., description="dz3 (m)"),
frequency=FloatText(value=0.5, description='f (Hz)'),
Field=ToggleButtons(options =['E','H','P'],value='E'),
Plane=ToggleButtons(options =['XZ','YZ'],value='XZ'),
Fixed=widgets.widget_bool.Checkbox(value=False),
vmin=FloatText(value=None),
vmax=FloatText(value=None),
__manual=True
)
return Q1
def lazy_tabs(in_dict: dict, node, style: GroupingWidget = widgets.Tab) -> GroupingWidget:
"""Creates a lazy tab object where multiple visualizations can be used for a single node and are generated on the
fly
Parameters
----------
in_dict: dict
keys are labels for tabs and values are functions
node: NWBDataInterface
instance of neurodata type to visualize
style: ipywidgets.Tab or ipywidgets.Accordion, optional
which way to present the data
Returns
-------
tab: widget
def _createAdvancedWidgets(self, advancedOpts, continuousReplot=False):
# Max time slider
if not advancedOpts['maxTime'][-1]:
maxTime = advancedOpts['maxTime']
widget = widgets.FloatSlider(value=maxTime[0], min=maxTime[1],
max=maxTime[2], step=maxTime[3],
readout_format='.' + str(utils._count_sig_decimals(str(maxTime[3]))) + 'f',
description='Simulation time:',
style={'description_width': 'initial'},
# layout=widgets.Layout(width='50%'),
disabled=False,
continuous_update=continuousReplot)
self._widgetsExtraParams['maxTime'] = widget
# Random seed input field
if not advancedOpts['randomSeed'][-1]:
widget = widgets.IntText(
value=advancedOpts['randomSeed'][0],
description='Random seed:',
style={'description_width': 'initial'},
disabled=False
def make_img_widget(img:bytes, layout=Layout(height='250px', width='300px'), format='jpg') -> widgets.Image:
"Returns an image widget for specified file name `img`."
return widgets.Image(value=img, format=format, layout=layout)
super().__init__()
self.units = units
self.trials = self.get_trials()
if self.trials is None:
self.children = [widgets.HTML('No trials present')]
return
groups = list(self.trials.colnames)
rows_controller = widgets.Dropdown(options=[None] + list(groups), description='rows')
cols_controller = widgets.Dropdown(options=[None] + list(groups), description='cols')
trial_event_controller = make_trial_event_controller(self.trials)
unit_controller = widgets.Dropdown(options=range(len(units['spike_times'].data)), value=unit_index,
description='unit')
before_slider = widgets.FloatSlider(.1, min=0, max=5., description='before (s)', continuous_update=False)
after_slider = widgets.FloatSlider(1., min=0, max=5., description='after (s)', continuous_update=False)
self.controls = {
'units': fixed(units),
'time_intervals': fixed(self.trials),
'index': unit_controller,
'after': after_slider,
'before': before_slider,
'align_by': trial_event_controller,
'rows_label': rows_controller,
'cols_label': cols_controller
}
if self.dtype == 'float':
slider_kwargs.update(
readout_format='.1f',
step=0.1,
description='time window (s)',
layout=Layout(width='100%')
)
slider_kwargs.update(kwargs)
return widgets.FloatRangeSlider(**slider_kwargs)
elif self.dtype == 'int':
slider_kwargs.update(
description='unit window',
layout=Layout(height='100%')
)
slider_kwargs.update(kwargs)
return widgets.IntRangeSlider(**slider_kwargs)
else:
raise ValueError('Unrecognized dtype: {}'.format(self.dtype))
for i in range(ch1+1-ch0):
ax[bd].plot(xx, data[:, i] - mu_array[i] + yticks[i])
ax[bd].set_ylabel('Ch #', fontsize=20)
ax[bd].set_yticks(yticks)
ax[bd].set_yticklabels([str(i) for i in range(ch0, ch1+1)])
ax[bd].tick_params(axis='both', which='major', labelsize=16)
ax[bd].set_xlabel('Time [ms]', fontsize=20)
return fig
nSamples = node.data.shape[0]
nChannels = node.data.shape[1]
nBands = node.data.shape[2]
fs = node.rate
# Controls
field_lay = widgets.Layout(max_height='40px', max_width='100px',
min_height='30px', min_width='70px')
x0 = widgets.BoundedIntText(value=0, min=0, max=int(1000*nSamples/fs-100),
layout=field_lay)
x1 = widgets.BoundedIntText(value=nSamples, min=100, max=int(1000*nSamples/fs),
layout=field_lay)
ch0 = widgets.BoundedIntText(value=0, min=0, max=int(nChannels-1), layout=field_lay)
ch1 = widgets.BoundedIntText(value=10, min=0, max=int(nChannels-1), layout=field_lay)
controls = {
'x0': x0,
'x1': x1,
'ch0': ch0,
'ch1': ch1
}
out_fig = widgets.interactive_output(control_plot, controls)