How to use node_size method in avocado

Best Python code snippet using avocado_python

micro_level_delaunay.py

Source: micro_level_delaunay.py Github

copy

Full Screen

1import networkx as nx2import matplotlib.pyplot as plt3import numpy as np4from math import sqrt5circ_color = [0.1,1,0.1]6node_color = '#F1F1F4'7border_color = 'white'8edge_color = 'white'9node_size = 20010bg_color = [0,0,0]11pause_time = 1.212def cercle_circonscrit(T):13 (x1, y1), (x2, y2), (x3, y3) = T14 A = np.array([[x3-x1,y3-y1],[x3-x2,y3-y2]])15 Y = np.array([(x3**2 + y3**2 - x1**2 - y1**2),(x3**2+y3**2 - x2**2-y2**2)])16 if np.linalg.det(A) == 0:17 return False18 Ainv = np.linalg.inv(A)19 X = 0.5*np.dot(Ainv,Y)20 x,y = X[0],X[1]21 r = sqrt((x-x1)**2+(y-y1)**2)22 return (x,y),r23def draw_circles(T):24 print("DRAW CIRCLES ")25 # T = (v1_c,v2_c, v3_c )26 my_circ = cercle_circonscrit(T)27 Drawing_uncolored_circle = plt.Circle( my_circ[0], my_circ[1] , fill = False, color=circ_color, linestyle = "dashed",linewidth=1,zorder=0)28 ax.add_artist( Drawing_uncolored_circle )29 30g = nx.Graph()31# fig, ax = plt.subplots()32fig = plt.figure()33ax = fig.add_subplot(111)34fig.set_size_inches(18.5, 10.5)35fig.set_dpi(100)36# plt.rcParams["figure.figsize"] = [7.00, 3.50]37# plt.rcParams["figure.autolayout"] = True38# plt.rcParams['axes.facecolor'] = 'black'39# plt.rcParams['figure.facecolor'] = 'black'40ax.set_xlim([-20,120])41ax.set_ylim([-20,120])42ax.set_aspect( 1 )43# ax.set_facecolor(bg_color) 44pos=nx.get_node_attributes(g,'pos')45nx.draw(g, pos, with_labels = True)46plt.pause(pause_time) 47plt.grid()48# --------------------- SCENE 1 -----------------------------------------------------------49plt.cla()50g.add_node(1,pos=(20,20))51g.add_node(2,pos=(15,40))52g.add_node(3,pos = (17,60))53g.add_node(4,pos = (38,53))54g.add_node(5,pos = (35,35))55g.add_node(6,pos = (36,20))56g.add_node(7,pos = (60,20))57g.add_node(8,pos = (65,40))58g.add_node(9,pos = (46,64))59circle1 = plt.Circle((0, 0), 0.2, color='r')60g.add_edge(1, 2 , color=edge_color)61g.add_edge(2, 3 , color=edge_color)62g.add_edge(3, 4 , color=edge_color)63g.add_edge(2, 4 , color=edge_color)64g.add_edge(4, 5 , color=edge_color)65g.add_edge(2, 5)66g.add_edge(1, 5)67g.add_edge(1, 6)68g.add_edge(5, 6)69g.add_edge(6, 7)70g.add_edge(5, 7)71g.add_edge(8, 7)72g.add_edge(8, 5)73g.add_edge(8, 4)74g.add_edge(9, 4)75g.add_edge(9, 3)76g.add_edge(9, 8)77pos=nx.get_node_attributes(g,'pos')78colors = nx.get_edge_attributes(g,'color').values()79nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)80fig.set_facecolor(bg_color)81plt.pause(pause_time) 82# --------------------- SCENE 2 - new point -----------------------------------------------------------83plt.cla()84g.add_node(10,pos = (26,43))85pos=nx.get_node_attributes(g,'pos')86colors = nx.get_edge_attributes(g,'color').values()87nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)88fig.set_facecolor(bg_color)89plt.pause(pause_time) 90# --------------------- SCENE 3 - new edges -----------------------------------------------------------91plt.cla()92g.add_edge(10,2)93g.add_edge(10,4)94g.add_edge(10,5)95pos=nx.get_node_attributes(g,'pos')96colors = nx.get_edge_attributes(g,'color').values()97nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)98fig.set_facecolor(bg_color)99plt.pause(pause_time) 100# --------------------- SCENE 4 test triangle 1 -----------------------------------------------------------101plt.cla()102T = ((15,40),(38,53),(26,43))103draw_circles(T)104pos=nx.get_node_attributes(g,'pos')105colors = nx.get_edge_attributes(g,'color').values()106nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)107fig.set_facecolor(bg_color)108plt.pause(pause_time) 109# --------------------- SCENE 5 remove edge -----------------------------------------------------------110plt.cla()111g.remove_edge(2,4)112pos=nx.get_node_attributes(g,'pos')113colors = nx.get_edge_attributes(g,'color').values()114nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)115fig.set_facecolor(bg_color)116plt.pause(pause_time) 117# --------------------- SCENE 6 add fli[] edge -----------------------------------------------------------118plt.cla()119g.add_edge(3,10)120pos=nx.get_node_attributes(g,'pos')121colors = nx.get_edge_attributes(g,'color').values()122nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)123fig.set_facecolor(bg_color)124plt.pause(pause_time) 125# --------------------- SCENE 7 add fli[] edge -----------------------------------------------------------126plt.cla()127T = ((26,43),(17,60),(38,53))128draw_circles(T)129pos=nx.get_node_attributes(g,'pos')130colors = nx.get_edge_attributes(g,'color').values()131nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)132fig.set_facecolor(bg_color)133plt.pause(pause_time) 134# --------------------- SCENE 8 -----------------------------------------------------------135plt.cla()136pos=nx.get_node_attributes(g,'pos')137colors = nx.get_edge_attributes(g,'color').values()138nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)139fig.set_facecolor(bg_color)140plt.pause(pause_time) 141# --------------------- SCENE 9 add fli[] edge -----------------------------------------------------------142plt.cla()143T = ((26,43),(17,60),(15,40))144draw_circles(T)145pos=nx.get_node_attributes(g,'pos')146colors = nx.get_edge_attributes(g,'color').values()147nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)148fig.set_facecolor(bg_color)149plt.pause(pause_time) 150# --------------------- SCENE 10 -----------------------------------------------------------151plt.cla()152pos=nx.get_node_attributes(g,'pos')153colors = nx.get_edge_attributes(g,'color').values()154nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)155fig.set_facecolor(bg_color)156plt.pause(pause_time) 157# --------------------- SCENE 11 add fli[] edge -----------------------------------------------------------158plt.cla()159T = ((26,43),(38,53),(35,35))160draw_circles(T)161pos=nx.get_node_attributes(g,'pos')162colors = nx.get_edge_attributes(g,'color').values()163nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)164fig.set_facecolor(bg_color)165plt.pause(pause_time) 166# --------------------- SCENE 12 -----------------------------------------------------------167plt.cla()168pos=nx.get_node_attributes(g,'pos')169colors = nx.get_edge_attributes(g,'color').values()170nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)171fig.set_facecolor(bg_color)172plt.pause(pause_time) 173# --------------------- SCENE 13 add fli[] edge -----------------------------------------------------------174plt.cla()175T = ((26,43),(15,40),(35,35))176draw_circles(T)177pos=nx.get_node_attributes(g,'pos')178colors = nx.get_edge_attributes(g,'color').values()179nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)180fig.set_facecolor(bg_color)181plt.pause(pause_time) 182# --------------------- SCENE 14 -----------------------------------------------------------183plt.cla()184pos=nx.get_node_attributes(g,'pos')185colors = nx.get_edge_attributes(g,'color').values()186nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)187fig.set_facecolor(bg_color)188plt.pause(pause_time) 189# --------------------- SCENE 15 -----------------------------------------------------------190plt.cla()191g.remove_edge(2,5)192pos=nx.get_node_attributes(g,'pos')193colors = nx.get_edge_attributes(g,'color').values()194nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)195fig.set_facecolor(bg_color)196plt.pause(pause_time)197# --------------------- SCENE 16 -----------------------------------------------------------198plt.cla()199g.add_edge(10,1)200pos=nx.get_node_attributes(g,'pos')201colors = nx.get_edge_attributes(g,'color').values()202nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)203fig.set_facecolor(bg_color)204plt.pause(pause_time) 205# --------------------- SCENE 17 add fli[] edge -----------------------------------------------------------206plt.cla()207T = ((26,43),(15,40),(20,20))208draw_circles(T)209pos=nx.get_node_attributes(g,'pos')210colors = nx.get_edge_attributes(g,'color').values()211nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)212fig.set_facecolor(bg_color)213plt.pause(pause_time) 214# --------------------- SCENE 18 -----------------------------------------------------------215plt.cla()216g.add_edge(10,1)217pos=nx.get_node_attributes(g,'pos')218colors = nx.get_edge_attributes(g,'color').values()219nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)220fig.set_facecolor(bg_color)221plt.pause(pause_time) 222# --------------------- SCENE 19 add fli[] edge -----------------------------------------------------------223plt.cla()224T = ((26,43),(35,35),(20,20))225draw_circles(T)226pos=nx.get_node_attributes(g,'pos')227colors = nx.get_edge_attributes(g,'color').values()228nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)229fig.set_facecolor(bg_color)230plt.pause(pause_time) 231# --------------------- SCENE 18 -----------------------------------------------------------232plt.cla()233g.add_edge(10,1)234pos=nx.get_node_attributes(g,'pos')235colors = nx.get_edge_attributes(g,'color').values()236nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color, edge_color=colors)237fig.set_facecolor(bg_color)238plt.pause(pause_time) 239# # --------------------- SCENE 2 -----------------------------------------------------------240# g.add_edge(4,3)241# T = ((1,1),(20,20),(1,20))242# draw_circles(T)243# pos=nx.get_node_attributes(g,'pos')244# nx.draw(g, pos, with_labels = True, node_color=node_color, node_size= node_size, edgecolors = border_color)245# plt.pause(pause_time) ...

Full Screen

Full Screen

network_viz_03.py

Source: network_viz_03.py Github

copy

Full Screen

1import networkx as nx2import matplotlib.pyplot as plt3from networkx import graphviz_layout4from pySPARROW import Network, Reach5workspace = "/​home/​user/​pysparrow-read-only/​examples/​testing_on_sample_sparrow_dataset/​"6test_reach = '5012'7net = Network(workspace + 'test.h5')8max2= 09id2 = 010#for i in net._g:11# if len(net.get_upstream_reaches(i)) > 1000: 12# print str(len(net.get_upstream_reaches(i))) + " " + str(i._ComID)13 14G=net._g.subgraph(net.get_upstream_reaches(net.get_reach(test_reach)))15pos=nx.graphviz_layout(G,prog='neato',args='')16plt.figure(figsize=(8,8))17lab = {}18node_size = []19node_color = []20for r in G:21 lab[r] = r._ComID22 #print r._AreaHa23 if r._AreaHa >= 1000.0: 24 node_size.append((r.get_tot_runoff() /​ r._AreaHa ) ** 2.0 )25 node_color.append((r.get_tot_runoff() /​ r._AreaHa ) ** 2.0 )26 else:27 node_size.append(1.0)28 node_color.append(1.0)29 30plt.subplot(2,3,1)31plt.title('Total')32nx.draw(G,pos, \33 node_size=node_size, \34 alpha=0.5, \35 node_color=node_color, \36 font_size = 8,37 style='dashed',38 with_labels=False)39lab = {}40node_size = []41node_color = []42for r in G:43 lab[r] = r._ComID44 #print r._AreaHa45 if r._AreaHa >= 1000.0: 46 node_size.append((r.get_atm_runoff() /​ r._AreaHa ) ** 2.0 )47 node_color.append((r.get_atm_runoff() /​ r._AreaHa ) ** 2.0 )48 else:49 node_size.append(1.0)50 node_color.append(1.0)51 52plt.subplot(2,3,2)53plt.title('Atmosphere')54nx.draw(G,pos, \55 node_size=node_size, \56 alpha=0.5, \57 node_color=node_color, \58 font_size = 8,59 style='dashed',60 with_labels=False) 61 62lab = {}63node_size = []64node_color = []65for r in G:66 lab[r] = r._ComID67 #print r._AreaHa68 if r._AreaHa >= 1000.0: 69 node_size.append((r.get_forest_runoff() /​ r._AreaHa ) ** 2.0 )70 node_color.append((r.get_forest_runoff() /​ r._AreaHa ) ** 2.0 )71 else:72 node_size.append(1.0)73 node_color.append(1.0)74 75plt.subplot(2,3,3)76plt.title('Nonag')77nx.draw(G,pos, \78 node_size=node_size, \79 alpha=0.5, \80 node_color=node_color, \81 font_size = 8,82 style='dashed',83 with_labels=False)84 85lab = {}86node_size = []87node_color = []88for r in G:89 lab[r] = r._ComID90 #print r._AreaHa91 if r._AreaHa >= 1000.0: 92 node_size.append((r.get_fert_runoff() /​ r._AreaHa ) ** 2.0 )93 node_color.append((r.get_fert_runoff() /​ r._AreaHa ) ** 2.0 )94 else:95 node_size.append(1.0)96 node_color.append(1.0)97 98plt.subplot(2,3,4)99plt.title('Fertilizer')100nx.draw(G,pos, \101 node_size=node_size, \102 alpha=0.5, \103 node_color=node_color, \104 font_size = 8,105 style='dashed',106 with_labels=False)107lab = {}108node_size = []109node_color = []110for r in G:111 lab[r] = r._ComID112 #print r._AreaHa113 if r._AreaHa >= 1000.0: 114 node_size.append((r.get_waste_runoff() /​ r._AreaHa ) ** 2.0 )115 node_color.append((r.get_waste_runoff() /​ r._AreaHa ) ** 2.0 )116 else:117 node_size.append(1.0)118 node_color.append(1.0)119 120plt.subplot(2,3,5)121plt.title('Waste')122nx.draw(G,pos, \123 node_size=node_size, \124 alpha=0.5, \125 node_color=node_color, \126 font_size = 8,127 style='dashed',128 with_labels=False)129lab = {}130node_size = []131node_color = []132for r in G:133 lab[r] = r._ComID134 #print r._AreaHa135 if r._AreaHa >= 1000.0: 136 node_size.append((r.get_pnt_runoff() /​ r._AreaHa ) ** 2.0 )137 node_color.append((r.get_pnt_runoff() /​ r._AreaHa ) ** 2.0 )138 else:139 node_size.append(1.0)140 node_color.append(1.0)141 142plt.subplot(2,3,6)143plt.title('Point')144nx.draw(G,pos, \145 node_size=node_size, \146 alpha=0.5, \147 node_color=node_color, \148 font_size = 8,149 style='dashed',150 with_labels=False)151 152plt.axis('equal')153plt.savefig('network_viz_03.png')154plt.close()...

Full Screen

Full Screen

abstract_size.py

Source: abstract_size.py Github

copy

Full Screen

1class AbstractSizeHandler:2 def __init__(self,builder):3 self._builder = builder4 self._standard_node_size = 305 def standard(self):6 return [self._standard_node_size for node in self._builder.v_nodes()]7 def class_type(self):8 node_sizes = []9 for node in self._builder.v_nodes():10 if self._builder.get_rdf_type(node) is None:11 node_sizes.append(self._standard_node_size/​2)12 else:13 node_sizes.append(self._standard_node_size)14 return node_sizes15 def centrality(self):16 node_sizes = []17 for node in self._builder.v_nodes():18 node_size = 1 + len(self._builder.in_edges(node)) + len(self._builder.out_edges(node))19 node_size = int((node_size * self._standard_node_size) /​ 4)20 if node_size > 100:21 node_size = 10022 if node_size < self._standard_node_size/​2:23 node_size = self._standard_node_size24 node_sizes.append(node_size)25 return node_sizes26 def in_centrality(self):27 node_sizes = []28 for node in self._builder.v_nodes():29 node_size = 1 + len(self._builder.in_edges(node))30 node_size = int((node_size * self._standard_node_size) /​ 2)31 if node_size > 100:32 node_size = 10033 if node_size < self._standard_node_size/​2:34 node_size = self._standard_node_size35 node_sizes.append(node_size)36 return node_sizes37 def out_centrality(self):38 node_sizes = []39 for node in self._builder.v_nodes():40 node_size = 1 + len(self._builder.out_edges(node))41 node_size = int((node_size * self._standard_node_size) /​ 2)42 if node_size > 100:43 node_size = 10044 if node_size < self._standard_node_size/​2:45 node_size = self._standard_node_size46 node_sizes.append(node_size)47 return node_sizes...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Nov’22 Updates: Live With Automation Testing On OTT Streaming Devices, Test On Samsung Galaxy Z Fold4, Galaxy Z Flip4, &#038; More

Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.

Considering Agile Principles from a different angle

In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.

How To Choose The Best JavaScript Unit Testing Frameworks

JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.

How To Write End-To-End Tests Using Cypress App Actions

When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.

[LambdaTest Spartans Panel Discussion]: What Changed For Testing &#038; QA Community And What Lies Ahead

The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful