Skip to content

Commit 52d9ae0

Browse files
author
yxdragon
committed
networkx upgrade
1 parent 1bd5aec commit 52d9ae0

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

imagepy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def show(ui = True):
2929
AS.AS_SHADOW_BITMAP,
3030
shadowcolour=shadow)
3131

32-
ImagePy(None).Show()
32+
ImagePy(None).Show()
3333
app.MainLoop()
3434

3535

imagepy/core/myvi/manager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ def draw(self):
221221
self.ctx.enable(moderngl.DEPTH_TEST)
222222
#self.ctx.enable(ModernGL.CULL_FACE)
223223
self.ctx.enable(moderngl.BLEND)
224-
for i in self.objs.values(): i.draw(self.mvp, self.light, self.bright, self.scatter)
224+
for i in self.objs.values():
225+
i.draw(self.mvp, self.light, self.bright, self.scatter)
225226

226227
def count_box(self):
227228
minb = np.array([i.box[0] for i in self.objs.values() if not i.box is None]).min(axis=0)
@@ -283,4 +284,4 @@ def show(self, title='Myvi'):
283284

284285
if __name__ == '__main__':
285286
img = imread('gis.png')
286-
build_surf2d(img)
287+
build_surf2d(img)

imagepy/ipyalg/graph/sknw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def draw_graph(img, graph, cn=255, ce=128):
122122
acc = np.cumprod((1,)+img.shape[::-1][:-1])[::-1]
123123
img = img.ravel()
124124
for idx in graph.nodes():
125-
pts = graph.node[idx]['pts']
125+
pts = graph.nodes[idx]['pts']
126126
img[np.dot(pts, acc)] = cn
127127
for (s, e) in graph.edges():
128128
eds = graph[s][e]

imagepy/menus/Analysis/Region Analysis/regionprops_plgs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run(self, ips, imgs, para = None):
6262
texts = [(i.centroid[::-1])+('id=%d'%n,) for i,n in zip(ls,range(len(ls)))]
6363
layer['body'].append({'type':'texts', 'body':texts})
6464
if para['cov']:
65-
ellips = [i.centroid[::-1] + (i.major_axis_length/2,i.minor_axis_length/2,i.orientation) for i in ls]
65+
ellips = [i.centroid[::-1] + (i.major_axis_length/2,i.minor_axis_length/2, i.orientation+np.pi/2) for i in ls]
6666
layer['body'].append({'type':'ellipses', 'body':ellips})
6767
mark['body'][i] = layer
6868

imagepy/menus/Analysis/Skeleton Network/graph_plgs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def draw(self, dc, f, **key):
2020
dc.SetFont(font)
2121

2222
ids = self.graph.nodes()
23-
pts = [self.graph.node[i]['o'] for i in ids]
23+
pts = [self.graph.nodes[i]['o'] for i in ids]
2424
pts = [f(i[1], i[0]) for i in pts]
2525
dc.DrawPointList(pts)
2626
dc.DrawTextList([str(i) for i in ids], pts)
@@ -53,7 +53,7 @@ def run(self, ips, imgs, para = None):
5353
comid = 0
5454
for g in nx.connected_component_subgraphs(ips.data, False):
5555
for idx in g.nodes():
56-
o = g.node[idx]['o']
56+
o = g.nodes[idx]['o']
5757
print(idx, g.degree(idx))
5858
nodes.append([comid, idx, g.degree(idx), round(o[1]*k,2), round(o[0]*k,2)])
5959
for (s, e) in g.edges():
@@ -166,8 +166,8 @@ def run(self, ips, imgs, para = None):
166166
if len(e1)!=1 or len(e2)!=1: continue
167167
e1, e2 = e1[0], e2[0]
168168
l1, l2 = e1['pts'], e2['pts']
169-
d1 = norm(l1[0]-g.node[n]['o']) > norm(l1[-1]-g.node[n]['o'])
170-
d2 = norm(l2[0]-g.node[n]['o']) < norm(l2[-1]-g.node[n]['o'])
169+
d1 = norm(l1[0]-g.nodes[n]['o']) > norm(l1[-1]-g.nodes[n]['o'])
170+
d2 = norm(l2[0]-g.nodes[n]['o']) < norm(l2[-1]-g.nodes[n]['o'])
171171
pts = np.vstack((l1[::[-1,1][d1]], l2[::[-1,1][d2]]))
172172
l = np.linalg.norm(pts[1:]-pts[:-1], axis=1).sum()
173173
g.remove_node(n)

imagepy/menus/Kit3D/Network 3D/toolkit3d_plgs.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def run(self, ips, imgs, para = None):
4949
balls, ids, rs, graph = [], [], [], ips.data
5050
for idx in graph.nodes():
5151
ids.append(idx)
52-
balls.append(graph.node[idx]['o'])
52+
balls.append(graph.nodes[idx]['o'])
5353
xs, ys, zs = [], [], []
5454
lxs, lys, lzs = [], [], []
5555
for (s, e) in graph.edges():
5656
eds = graph[s][e]
57-
st, ed = graph.node[s]['o'], graph.node[e]['o']
57+
st, ed = graph.nodes[s]['o'], graph.nodes[e]['o']
5858
lxs.append([st[0],ed[0]])
5959
lys.append([st[1],ed[1]])
6060
lzs.append([st[2],ed[2]])
@@ -102,14 +102,14 @@ def run(self, ips, imgs, para = None):
102102
balls, ids, rs, graph = [], [], [], ips.data
103103
for idx in graph.nodes():
104104
ids.append(idx)
105-
balls.append(graph.node[idx]['o'])
105+
balls.append(graph.nodes[idx]['o'])
106106

107107

108108
xs, ys, zs = [], [], []
109109
v1s, v2s = [], []
110110
for (s, e) in graph.edges():
111111
eds = graph[s][e]
112-
st, ed = graph.node[s]['o'], graph.node[e]['o']
112+
st, ed = graph.nodes[s]['o'], graph.nodes[e]['o']
113113
v1s.append(st)
114114
v2s.append(ed)
115115
for i in eds:
@@ -157,13 +157,13 @@ def run(self, ips, imgs, para = None):
157157
comid = 0
158158
for g in nx.connected_component_subgraphs(ips.data, False):
159159
for idx in g.nodes():
160-
o = g.node[idx]['o']
160+
o = g.nodes[idx]['o']
161161
nodes.append([comid, idx, g.degree(idx), round(o[1]*k,2), round(o[0]*k,2), round(o[2])])
162162
for (s, e) in g.edges():
163163
eds = g[s][e]
164164
for i in eds:
165165
l = round(eds[i]['weight']*k, 2)
166-
dis = round(np.linalg.norm(g.node[s]['o']-g.node[e]['o'])*k, 2)
166+
dis = round(np.linalg.norm(g.nodes[s]['o']-g.nodes[e]['o'])*k, 2)
167167
edges.append([comid, s, e, l, dis])
168168
comid += 1
169169

@@ -215,7 +215,7 @@ def run(self, ips, imgs, para = None):
215215
graph = ips.data
216216
datas = []
217217
for s in graph.nodes():
218-
o = graph.node[s]['o']
218+
o = graph.nodes[s]['o']
219219
x = graph[s]
220220
if len(x)<=1: continue
221221
rst = []
@@ -302,8 +302,8 @@ def run(self, ips, imgs, para = None):
302302
if len(e1)!=1 or len(e2)!=1: continue
303303
e1, e2 = e1[0], e2[0]
304304
l1, l2 = e1['pts'], e2['pts']
305-
d1 = norm(l1[0]-g.node[n]['o']) > norm(l1[-1]-g.node[n]['o'])
306-
d2 = norm(l2[0]-g.node[n]['o']) < norm(l2[-1]-g.node[n]['o'])
305+
d1 = norm(l1[0]-g.nodes[n]['o']) > norm(l1[-1]-g.nodes[n]['o'])
306+
d2 = norm(l2[0]-g.nodes[n]['o']) < norm(l2[-1]-g.nodes[n]['o'])
307307
pts = np.vstack((l1[::[-1,1][d1]], l2[::[-1,1][d2]]))
308308
l = np.linalg.norm(pts[1:]-pts[:-1], axis=1).sum()
309309
g.remove_node(n)

imagepy/menus/Plugins/Games/drawstep_plg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def build_graph(graph, dis, step=True):
4141
for i in eds:
4242
if step:ls.append(ls[-1].copy())
4343
pts = eds[i]['pts']
44-
ptss = graph.node[s]['pts']
45-
ptse = graph.node[e]['pts']
44+
ptss = graph.nodes[s]['pts']
45+
ptse = graph.nodes[e]['pts']
4646
pts = np.vstack((ptss,pts,ptse))
4747
draw_edge(ls[-1], dis, pts)
4848
return ls if step else ls[0]

0 commit comments

Comments
 (0)