diff --git a/py/visdom/__init__.py b/py/visdom/__init__.py index e291fd33..499284b9 100644 --- a/py/visdom/__init__.py +++ b/py/visdom/__init__.py @@ -140,7 +140,7 @@ def _title2str(opts): def _scrub_dict(d): - if type(d) is dict: + if isinstance(d, dict): return {k: _scrub_dict(v) for k, v in list(d.items()) if v is not None and _scrub_dict(v) is not None} else: @@ -1469,7 +1469,7 @@ def scatter(self, X, Y=None, win=None, env=None, opts=None, update=None, - `opts.markerborderwidth`: marker border line width (`float`; default = 0.5) - `opts.dash` : dash type (`np.array`; default = 'solid'`) - `opts.textlabels` : text label for each point (`list`: default = `None`) - - `opts.legend` : `list` containing legend names + - `opts.legend` : `list` or `tuple` containing legend names """ if update == 'remove': assert win is not None @@ -1561,9 +1561,10 @@ def scatter(self, X, Y=None, win=None, env=None, opts=None, update=None, _assert_opts(opts) if opts.get('legend'): - assert type(opts['legend']) == list and K <= len(opts['legend']), \ - 'largest label should not be greater than size of the ' \ - 'legends table' + assert isinstance(opts['legend'], (tuple, list)) \ + and K <= len(opts['legend']), \ + 'largest label should not be greater than size of ' \ + 'the legends table' data = [] trace_opts = opts.get('traceopts', {'plotly': {}})['plotly'] @@ -1669,7 +1670,7 @@ def line(self, Y, X=None, win=None, env=None, opts=None, update=None, - `opts.markersize` : marker size (`number`; default = `'10'`) - `opts.linecolor` : line colors (`np.array`; default = None) - `opts.dash` : line dash type (`np.array`; default = None) - - `opts.legend` : `list` containing legend names + - `opts.legend` : `list` or `tuple` containing legend names If `update` is specified, the figure will be updated without creating a new plot -- this can be used for efficient updating. diff --git a/py/visdom/server.py b/py/visdom/server.py index 33829751..e7cf23d0 100644 --- a/py/visdom/server.py +++ b/py/visdom/server.py @@ -407,7 +407,7 @@ def get_messages(self): to_send = [] while len(self.messages) > 0: message = self.messages.pop() - if type(message) is dict: + if isinstance(message, dict): # Not all messages are being formatted the same way (JSON) # TODO investigate message = json.dumps(message) @@ -656,7 +656,7 @@ def get_messages(self): to_send = [] while len(self.messages) > 0: message = self.messages.pop() - if type(message) is dict: + if isinstance(message, dict): # Not all messages are being formatted the same way (JSON) # TODO investigate message = json.dumps(message) @@ -769,7 +769,7 @@ def window(args): def broadcast(self, msg, eid): for s in self.subs: - if type(self.subs[s].eid) is list: + if isinstance(self.subs[s].eid, dict): if eid in self.subs[s].eid: self.subs[s].write_message(msg) else: