def test_add_metamer(): g = MTG() add_plant(g) vid_plant, vid_axe, metamers = find_metamers(g) assert len(metamers) == 1 vid = add_vegetative_metamer(g) vid_plant, vid_axe, metamers = find_metamers(g) metamer = g.node(vid) assert len(metamers) == 2 assert metamer.label == 'metamer1'
def test_insert_elements(): g = MTG() labels = g.property('label') add_plant(g) elts = [{'label': 'elt1'}, {'label': 'elt2'}] collar = find_label('collar', g)[0] insert_elements(g, collar, elts) elt1 = find_label('elt1', g)[0] assert labels[g.parent(elt1)] == 'baseElement' assert labels[g.children(elt1)[0]] == 'elt2'
def test_add_axe(): g = MTG() labels = g.property('label') p1 = add_plant(g) p2 = add_plant(g) vid_axe = add_axe(g, 'T0') assert g.complex(vid_axe) == p1 assert labels[g.parent(vid_axe)] == 'MS' vid_axe = add_axe(g, 'T1.3', plant_number=2) assert g.complex(vid_axe) == p2 assert labels[g.parent(vid_axe)] == 'T1' vid_metamer0 = g.component_roots_at_scale(vid_axe, 3)[0] assert labels[g.parent(vid_metamer0)] == "metamer3"
def build_stand(self): g = MTG() plants = self.axeT() sample = [int(p) for p in plantSample(self.pars)] for i, plant in plants.groupby('plant'): plant_properties = {'position': self.positions[i - 1], 'azimuth': self.plant_azimuths[i - 1], 'refplant_id': sample[i - 1]} ms = plant.loc[plant['axe'] == 'MS', :].to_dict('list') ms_properties = {'HS_final': float(ms['HS_final'][0]), 'nff': int(ms['nf'][0]), 'hasEar': bool(int(ms['hasEar'][0])), 'azimuth': float(ms['azTb'][0])} add_plant(g, i, plant_properties=plant_properties, axis_properties=ms_properties) return g
def test_add_plant(): g = MTG() vid = add_plant(g) plant = g.node(vid) assert plant.label == 'plant1' vid = add_plant(g) plant = g.node(vid) assert plant.label == 'plant2' vid = add_plant(g, 5) plant = g.node(vid) assert plant.label == 'plant5' vid = add_plant(g) plant = g.node(vid) assert plant.label == 'plant6' vid = add_plant(g, 1) plant = g.node(vid) assert plant.label == 'plant1' assert len(find_plants(g)) == 4