Example #1
0
def test_second_layer() -> None:
    """ """
    programs = tree.load(io.StringIO(test_data))
    base = programs['ugml']
    holds = list(map(operator.attrgetter('name'), base.holds))

    assert list(sorted(holds)) == ['ebii', 'gyxo', 'jptl']
Example #2
0
def test_top_layer() -> None:
    """ """
    programs = tree.load(io.StringIO(test_data))
    base = programs['gyxo']
    holds = list(map(operator.attrgetter('name'), base.holds))

    assert list(sorted(holds)) == []
Example #3
0
def test_first_layer() -> None:
    """ """
    programs = tree.load(io.StringIO(test_data))
    base = programs['tknk']
    holds = list(map(operator.attrgetter('name'), base.holds))

    assert list(sorted(holds)) == ['fwft', 'padx', 'ugml']
Example #4
0
def test_find_imbalanced_program() -> None:
    """ """
    programs = tree.load(io.StringIO(test_data))
    print(programs)
    bottom = tree.find_bottom_of_tree(programs)

    program, weight = tree.find_wrong_weight(bottom)
    assert program.name == 'ugml'
    assert weight == 60
Example #5
0
def main(args=None):
    if args is None:
        args = sys.argv

    #n = tree.random_tree(20)
    #n = tree.life_tree()
    
    filename = args[1]
    n = tree.load(filename)
    
    l = CircleLayout(n)
    l.run()
    r = SvgRenderer(l)
    r.show_bounding = True
    r.render()
Example #6
0
    def OnImportFreeMind(self, event):
        if not self.CheckUnsaved(event):
            return
        
        wildcard = "FreeMind mindmap|*.mm"
        
        dlg = wx.FileDialog(
            self, message="Choose a file...", defaultDir=os.getcwd(), 
            defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.CHANGE_DIR
            )
        
        if dlg.ShowModal() == wx.ID_OK:
            paths = dlg.GetPaths()
            filename = paths[0]
            t = tree.load(filename)
            self.panel.SetTree(t, None)
            self.SetTitle("Snowflake")

        dlg.Destroy()
Example #7
0
    def OnFileOpen(self, event):
        if not self.CheckUnsaved(event):
            return
        
        wildcard = "Tree text file|*.txt"
        
        dlg = wx.FileDialog(
            self, message="Choose a file...", defaultDir=os.getcwd(), 
            defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.CHANGE_DIR
            )
        
        if dlg.ShowModal() == wx.ID_OK:
            paths = dlg.GetPaths()
            filename = paths[0]
            t = tree.load(filename)
            self.panel.SetTree(t, filename)
            self.SetTitle("Snowflake - " + self.panel.filename)

        dlg.Destroy()
Example #8
0
def test_find_bottom_of_tree() -> None:
    """ """
    programs = tree.load(io.StringIO(test_data))
    assert tree.find_bottom_of_tree(programs).name == 'tknk'
Example #9
0
def fence(length, loc, count):
    amount = int(length / 1.25)
    for i in range(1, amount):
        render(post, (loc[0] + (i * 1.25), loc[1], loc[2]),
               "Post " + str(count + i))
    return count + amount


# init models
house = house.load()
mailbox = mail_box.load()
sign = sign.load()
post = fencepost.load()
lab = lab.load()
floor = floor.load()
tree = tree.load()

render(floor, (0, 0, 0), "Floor")
render(house, (20, 55, 0), "House Left")
render(house, (47.5, 55, 0), "House Right")
render(lab, (45, 35, 0), "Lab")
render(mailbox, (18.5, 56, 0), "Mailbox Left")
render(mailbox, (45, 56, 0), "Mailbox Right")
render(sign, (30, 42.5, 0), "Sign")

c = fence(10, (20, 42.5, 0), 0)
c = fence(17.5, (45, 22.5, 0), c)
fence(20, (35, 5, 0), c)


def forest(start, end):