Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various minor fixes #341

Merged
merged 6 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion panel/io/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ def sig_exit(*args, **kwargs):

def do_stop(*args, **kwargs):
server.io_loop.stop()
signal.signal(signal.SIGINT, sig_exit)

try:
signal.signal(signal.SIGINT, sig_exit)
except ValueError:
pass # Can't use signal on a thread

if start:
server.start()
Expand Down
2 changes: 1 addition & 1 deletion panel/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _process_links(cls, root_view, root_model):
for link, src, tgt in found:
cb = cls._callbacks[type(link)]
if src is None or (getattr(link, '_requires_target', False)
and tgt is None):
and tgt is None):
continue
callbacks.append(cb(root_model, link, src, tgt))
return callbacks
Expand Down
1 change: 0 additions & 1 deletion panel/models/vtk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export class VTKPlotView extends HTMLBoxView {
delete state.vtkCamera;
delete state.viewPlaneNormal;
this.model.camera = state;
this.model.properties.camera.change.emit();
this._setting = false;
}
}
Expand Down
24 changes: 18 additions & 6 deletions panel/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ def hashable(x):

def isIn(obj, objs):
"""
Checks if the object is in the list of objects, unlike the ``in``
Python operator this will check only for identity not equality.
Checks if the object is in the list of objects safely.
"""
return any(o is obj for o in objs)
for o in objs:
if o is obj:
return True
try:
if o == obj:
return True
except:
pass
return False


def indexOf(obj, objs):
Expand All @@ -42,9 +49,14 @@ def indexOf(obj, objs):
list.index method this function only checks for identity not
equality.
"""
indexes = [i for i, o in enumerate(objs) if o is obj]
if indexes:
return indexes[0]
for i, o in enumerate(objs):
if o is obj:
return i
try:
if o == obj:
return i
except:
pass
raise ValueError('%s not in list' % obj)


Expand Down
2 changes: 1 addition & 1 deletion panel/viewable.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def _repr_mimebundle_(self, include=None, exclude=None):
model = self.get_root(doc, comm)
if config.embed:
embed_state(self, model, doc,
json=config.json,
json=config.embed_json,
save_path=config.embed_save_path,
load_path=config.embed_load_path)
return render_model(model)
Expand Down
24 changes: 24 additions & 0 deletions panel/widgets/tests/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@ def test_select_list_constructor():
assert select.options == ['A', 1]


def test_select_float_option_with_equality():
opts = {'A': 3.14, '1': 2.0}
select = Select(options=opts, value=3.14, name='Select')
assert select.value == 3.14

select.value = 2
assert select.value == 2.0

select.value = 3.14
assert select.value == 3.14


def test_select_text_option_with_equality():
opts = {'A': 'ABC', '1': 'DEF'}
select = Select(options=opts, value='DEF', name='Select')
assert select.value == 'DEF'

select.value = 'ABC'
assert select.value == 'ABC'

select.value = 'DEF'
assert select.value == 'DEF'


def test_select(document, comm):
opts = {'A': 'a', '1': 1}
select = Select(options=opts, value=opts['1'], name='Select')
Expand Down