-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdouble-split.py
More file actions
executable file
·108 lines (78 loc) · 2.33 KB
/
double-split.py
File metadata and controls
executable file
·108 lines (78 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""
Double
https://houseofgraphs.org/graphs/422
"""
from collections import defaultdict
import operator as op
from functools import partial
from pprint import pprint as pp
from hyperway.stepper import run_stepper, StepperC
from hyperway.graph import Graph
from hyperway.edges import Connection, as_connections, make_edge, get_connections
from hyperway.graph import add, connect
from hyperway.nodes import Unit, as_unit
from hyperway.reader import read_linear_chain, read_tree_chain, flat_graph
# import smoke_tests
import hyperway.tools as t
from hyperway.writer import set_graphviz
set_graphviz('./Graphviz-12.0.0-win64/bin/')
f = t.factory
f.commute = True
def main():
return run()
def forloop_stepper(stepper):
try:
for rows in stepper:
print('-- result', rows)
except StopIteration as e:
print('-- Stop called: ', e)
def forloop_iterator(stepper):
try:
it = stepper.iterator()
for rows in next(it):
print('-- result', rows)
except StopIteration as e:
print('-- Stop called: ', e)
def manual_stepped(stepper):
v = stepper.step()
print('1: ', v)
v = stepper.step()
print('2: ', v)
v = stepper.step()
print('3: ', v)
v = stepper.step()
print('4: ', v)
v = stepper.step()
print('5: ', v) #empty.
## overstep will result in a restart, #but the stash remains untouched.
v = stepper.step()
print('6: ', v)
v = stepper.step()
print('7: ', v)
def while_step(stepper):
rows = stepper.step()
while len(rows) > 0:
rows = stepper.step()
print('Rows', rows)
print('done', stepper.stash)
def run():
g = Graph()
split = as_unit(f.add_2)
join = as_unit(f.add_2)
cs = g.connect(f.add_1, split)
g.connect(split, f.add_3, join)
g.connect(split, f.add_4, join)
g.connect(join, f.add_1)
s = g.stepper(cs[0].a, 1)
while_step(s)
pp(s.stash)
g.write('double-split', directory='renders/', direction='LR')#, engine='neato')
# print('---')
# cr = read_linear_chain(g, cs[0].a)
# print('linear chain', cr)
# print('---')
# result = run_stepper(g, con.a, 1)
# print(result)
return g #, s
if __name__ == '__main__':
g = main()