Skip to content

Commit 5f91dee

Browse files
author
CindeeM
committed
RF: change numpy import alias to common np instead of nmex
1 parent 6290ae7 commit 5f91dee

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

brainx/nxplot.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def draw_networkx_edges(G, pos,
484484
try:
485485
import matplotlib
486486
import matplotlib.pylab as pylab
487-
import numpy as nmex
487+
import numpy as np
488488
from matplotlib.colors import colorConverter,Colormap
489489
from matplotlib.collections import LineCollection
490490
except ImportError:
@@ -502,7 +502,7 @@ def draw_networkx_edges(G, pos,
502502
return None
503503

504504
# set edge positions
505-
edge_pos=nmex.asarray([(pos[e[0]],pos[e[1]]) for e in edgelist])
505+
edge_pos=np.asarray([(pos[e[0]],pos[e[1]]) for e in edgelist])
506506

507507
if not cb.iterable(width):
508508
lw = (width,)
@@ -512,16 +512,16 @@ def draw_networkx_edges(G, pos,
512512
if not cb.is_string_like(edge_color) \
513513
and cb.iterable(edge_color) \
514514
and len(edge_color)==len(edge_pos):
515-
if nmex.alltrue([cb.is_string_like(c)
515+
if np.alltrue([cb.is_string_like(c)
516516
for c in edge_color]):
517517
# (should check ALL elements)
518518
# list of color letters such as ['k','r','k',...]
519519
edge_colors = tuple([colorConverter.to_rgba(c,alpha)
520520
for c in edge_color])
521-
elif nmex.alltrue([not cb.is_string_like(c)
521+
elif np.alltrue([not cb.is_string_like(c)
522522
for c in edge_color]):
523523
# If color specs are given as (rgb) or (rgba) tuples, we're OK
524-
if nmex.alltrue([cb.iterable(c) and len(c) in (3,4)
524+
if np.alltrue([cb.iterable(c) and len(c) in (3,4)
525525
for c in edge_color]):
526526
edge_colors = tuple(edge_color)
527527
alpha=None
@@ -555,7 +555,7 @@ def draw_networkx_edges(G, pos,
555555
# just not work with an older mpl
556556
if edge_colors is None:
557557
if edge_cmap is not None: assert(isinstance(edge_cmap, Colormap))
558-
edge_collection.set_array(nmex.asarray(edge_color))
558+
edge_collection.set_array(np.asarray(edge_color))
559559
edge_collection.set_cmap(edge_cmap)
560560
if edge_vmin is not None or edge_vmax is not None:
561561
edge_collection.set_clim(edge_vmin, edge_vmax)
@@ -578,7 +578,7 @@ def draw_networkx_edges(G, pos,
578578
x2,y2=dst
579579
dx=x2-x1 # x offset
580580
dy=y2-y1 # y offset
581-
d=nmex.sqrt(float(dx**2+dy**2)) # length of edge
581+
d=np.sqrt(float(dx**2+dy**2)) # length of edge
582582
if d==0: # source and target at same position
583583
continue
584584
if dx==0: # vertical edge
@@ -588,9 +588,9 @@ def draw_networkx_edges(G, pos,
588588
ya=y2
589589
xa=dx*p+x1
590590
else:
591-
theta=nmex.arctan2(dy,dx)
592-
xa=p*d*nmex.cos(theta)+x1
593-
ya=p*d*nmex.sin(theta)+y1
591+
theta=np.arctan2(dy,dx)
592+
xa=p*d*np.cos(theta)+x1
593+
ya=p*d*np.sin(theta)+y1
594594

595595
a_pos.append(((xa,ya),(x2,y2)))
596596

@@ -602,10 +602,10 @@ def draw_networkx_edges(G, pos,
602602
)
603603

604604
# update view
605-
minx = nmex.amin(nmex.ravel(edge_pos[:,:,0]))
606-
maxx = nmex.amax(nmex.ravel(edge_pos[:,:,0]))
607-
miny = nmex.amin(nmex.ravel(edge_pos[:,:,1]))
608-
maxy = nmex.amax(nmex.ravel(edge_pos[:,:,1]))
605+
minx = np.amin(np.ravel(edge_pos[:,:,0]))
606+
maxx = np.amax(np.ravel(edge_pos[:,:,0]))
607+
miny = np.amin(np.ravel(edge_pos[:,:,1]))
608+
maxy = np.amax(np.ravel(edge_pos[:,:,1]))
609609

610610
w = maxx-minx
611611
h = maxy-miny

0 commit comments

Comments
 (0)