Skip to content

Commit a22c842

Browse files
committed
[refactor]migrate serialize_env_list_wschema and lazy_read
1 parent daacf25 commit a22c842

File tree

2 files changed

+271
-82
lines changed

2 files changed

+271
-82
lines changed

py/visdom/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#
66
# This source code is licensed under the license found in the
77
# LICENSE file in the root directory of this source tree.
8+
# __version__ = 'test'
89

910
import os.path
1011
import requests
@@ -405,7 +406,7 @@ def __init__(
405406
'base_url should not end with / as it is appended automatically'
406407

407408
self.ipv6 = ipv6
408-
self.env = env
409+
self.env = env
409410
self.env_list={f'{env}'} # default env
410411
self.send = send
411412
self.event_handlers = {} # Haven't registered any events
@@ -801,7 +802,7 @@ def get_env_list(self):
801802
This function returns a list of all of the env names that are currently
802803
in the server.
803804
"""
804-
if self.offline:
805+
if self.offline:
805806
return list(self.env_list)
806807
else:
807808
return json.loads(self._send({}, endpoint='env_state', quiet=True))
@@ -1694,7 +1695,7 @@ def line(self, Y, X=None, win=None, env=None, opts=None, update=None,
16941695
assert X.ndim == 1 or X.ndim == 2, 'X should have 1 or 2 dim'
16951696
else:
16961697
X = np.linspace(0, 1, Y.shape[0])
1697-
1698+
16981699
if Y.ndim == 2 and X.ndim == 1:
16991700
X = np.tile(X, (Y.shape[1], 1)).transpose()
17001701

@@ -2180,7 +2181,7 @@ def sunburst(self, labels, parents, values=None, win=None, env=None, opts=None):
21802181
line_width=opts.get("marker_width")
21812182

21822183
assert len(parents.tolist())==len(labels.tolist()), "length of parents and labels should be equal"
2183-
2184+
21842185
data_dict=[{
21852186
'labels': labels.tolist(),
21862187
"parents":parents.tolist(),
@@ -2196,7 +2197,7 @@ def sunburst(self, labels, parents, values=None, win=None, env=None, opts=None):
21962197

21972198
data_dict[0]['values']=values.tolist()
21982199

2199-
data=data_dict
2200+
data=data_dict
22002201
return self._send({
22012202
'data': data,
22022203
'win': win,
@@ -2397,7 +2398,7 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No
23972398
"""
23982399
This function draws interactive network graphs. It takes list of edges as one of the arguments.
23992400
The user can also provide custom edge Labels and node Labels in edgeLabels and nodeLabels respectively.
2400-
Along with that we have different parameters in opts for making it more user friendly.
2401+
Along with that we have different parameters in opts for making it more user friendly.
24012402
24022403
Args:
24032404
edges : list, required
@@ -2419,7 +2420,7 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No
24192420
except:
24202421
raise RuntimeError(
24212422
"networkx must be installed to plot Graph figures")
2422-
2423+
24232424
G = nx.Graph()
24242425
G.add_edges_from(edges)
24252426
node_data = list(G.nodes())
@@ -2434,7 +2435,7 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No
24342435
if nodeLabels is not None:
24352436
assert len(nodeLabels) == len(node_data),\
24362437
"length of nodeLabels does not match with the length of nodes {len1} != {len2}".format(len1 = len(nodeLabels), len2 = len(node_data))
2437-
2438+
24382439
for i in range(len(node_data)):
24392440
if i != node_data[i]:
24402441
raise RuntimeError("The nodes should be numbered from 0 to n-1 for n nodes! {} node is missing!".format(i))
@@ -2455,15 +2456,15 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No
24552456
edge["target"] = int(link_data[i][1])
24562457
edge["label"] = str(edgeLabels[i]) if edgeLabels is not None else str(link_data[i][0])+"-"+str(link_data[i][1])
24572458
edges.append(edge)
2458-
2459+
24592460
for i in range(len(node_data)):
24602461
node = {}
24612462
node["name"] = int(node_data[i])
24622463
node["label"] = str(nodeLabels[i]) if nodeLabels is not None else str(node_data[i])
24632464
if opts['scheme'] == 'different':
24642465
node["club"] = int(i)
24652466
nodes.append(node)
2466-
2467+
24672468

24682469
data = [{
24692470
'content': {"nodes": nodes, "edges": edges},

0 commit comments

Comments
 (0)