main
Tait Hoyem 3 years ago
parent 5d90fe7b4c
commit d19b7a7223

@ -0,0 +1,4 @@
# graphs-and-tables
Some tools I developed while doing transcritpions of slides for a blind student at SFU (Simon Fraser University).

@ -0,0 +1,47 @@
from bs4 import BeautifulSoup as BS
table = list()
with open("table.csv", "r") as f:
for row in f:
fil = list()
for cell in row.split(","):
if cell[:2] == "$$":
cell = cell.replace("$$", "")
cell = "{% katex %}" + cell
cell = cell + "{% endkatex %}"
fil.append(cell)
table.append(fil)
def generate_table(table):
html = "<table><thead><tr>"
html += "<th colspan=\"2\"></th>"
html += "<th colspan=\"3\">Exponent</th>"
html += "<th colspan=\"2\">Fraction</th>"
html += "<th colspan=\"3\">Value</th>"
html += "</tr><tr>"
html += "<th>Description</th>"
html += "<th>Bit Representation/th>"
html += "<th>exp</th>"
html += "<th>E</th>"
html += "<th>{% katex %}2^{E}{% endkatex %}</th>"
html += "<th>frac</th>"
html += "<th>M</th>"
html += "<th>{% katex %}M 2^{E}{% endkatex %}</th>"
html += "<th>V</th>"
html += "<th>Decimal</th>"
html += "</tr></thead><tbody>"
for row in table:
html += "<tr>"
for cell in row:
html += "<td>" + cell + "</td>"
html += "</tr>"
html += "</tbody></table>"
return html
print("<!-- AUTO GENERATED FROM CUSTOM PYTHON CODE -->")
bs = BS(generate_table(table), "html.parser")
print(bs.prettify())
print("<!-- END OF GENERATED CODE -->")

@ -0,0 +1,29 @@
zero,0 000 00,0,-2,$$1/4$$,$$0/4$$,$$0/4$$,$$0/16$$,0,0.0
Smallest positive denormalized,0 000 01,0,-2,$$1/4$$,$$1/4$$,$$1/4$$,$$1/16$$,$$1/16$$,0.0625
,0 000 10,0,-2,$$1/4$$,$$2/4=1/2$$,$$2/4=1/2$$,$$2/16$$,$$2/16$$,0.125
Largest positive denormalized,0 000 11,0,-2,$$1/4$$,$$3/4$$,$$3/4$$,$$3/16$$,$$3/16$$,0.1875
Smallest positive normalized,0 001 00,1,-2,$$1/4$$,$$0/4$$,$$4/4=1$$,$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4$$,$$5/4$$,$$40/4$$,$$40/4$$,10
,0 110 10,6,3,8,$$2/4=1/2$$,$$6/4$$,$$48/4$$,$$48/4$$,12
Largest positive normalized,0 110 11,6,3,8,$$3/4$$,$$7/4$$,$$56/4$$,$$56/4$$,14
+ infinity,0 111 0,-,-,-,-,-,-,$$\infty$$,-
NaN,,-,-,-,-,-,-,NaN,-
1 zero 0 000 00 0 -2 $$1/4$$ $$0/4$$ $$0/4$$ $$0/16$$ 0 0.0
2 Smallest positive denormalized 0 000 01 0 -2 $$1/4$$ $$1/4$$ $$1/4$$ $$1/16$$ $$1/16$$ 0.0625
3 0 000 10 0 -2 $$1/4$$ $$2/4=1/2$$ $$2/4=1/2$$ $$2/16$$ $$2/16$$ 0.125
4 Largest positive denormalized 0 000 11 0 -2 $$1/4$$ $$3/4$$ $$3/4$$ $$3/16$$ $$3/16$$ 0.1875
5 Smallest positive normalized 0 001 00 1 -2 $$1/4$$ $$0/4$$ $$4/4=1$$ $$4/16$$ $$4/16$$ 0.25
6 0 001 01 1 -2 $$1/4$$ $$1/4$$ $$5/4$$ $$5/16$$ $$5/16$$ 0.3125
7 0 001 10 1 -2 $$1/4$$ $$2/4=1/2$$ $$6/4$$ $$6/16$$ $$6/16$$ 0.375
8 0 001 11 1 -2 $$1/4$$ $$3/4$$ $$7/4$$ $$7/16$$ $$7/16$$ 0.4375
9 0 010 00 2 -1 $$1/2$$ $$0/4$$ $$4/4=1$$ $$4/8$$ $$4/8$$ 0.5
10 0 010 01 2 -1 $$1/2$$ $$1/4$$ $$5/4$$ $$5/8$$ $$5/8$$ 0.625
11 0 010 11 2 -1 $$1/2$$ $$3/4$$ $$7/4$$ $$7/8$$ $$7/8$$ 0.875
12 One 0 011 00 3 0 1 $$0/4$$ $$4/4=1$$ $$4/4$$ $$4/4$$ 1.0
13 0 011 01 3 0 1 $$1/4$$ $$5/4$$ $$5/4$$ $$5/4$$ 1.25
14 0 011 10 3 0 1 $$2/4=1/2$$ $$6/4$$ $$6/4$$ $$6/4$$ 1.5
15 0 011 11 3 0 1 $$3/4$$ $$7/4$$ $$7/4$$ $$7/4$$ 1.75
16 0 100 00 4 1 2 $$0/4$$ $$4/4=1$$ $$8/4$$ $$8/4$$ 2
17 0 100 01 4 1 2 $$1/4$$ $$5/4$$ $$10/4$$ $$10/4$$ 2.5
18 0 100 10 4 1 2 $$2/4=1/2$$ $$6/4$$ $$12/4$$ $$12/4$$ 3
19 0 100 11 4 1 2 $$3/4$$ $$7/4$$ $$14/4$$ $$14/4$$ 3.5
20 0 101 00 5 2 4 $$0/4$$ $$4/4=1$$ $$16/4$$ $$16/4$$ 4
21 0 101 01 5 2 4 $$1/4$$ $$5/4$$ $$20/4$$ $$20/4$$ 5
22 0 101 10 5 2 4 $$2/4=1/2$$ $$6/4$$ $$24/4$$ $$24/4$$ 6
23 0 101 11 5 2 4 $$3/4$$ $$7/4$$ $$28/4$$ $$28/4$$ 7
24 0 110 00 6 3 8 $$0/4$$ $$4/4=1$$ $$32/4$$ $$32/4$$ 8
25 0 110 01 6 3 8 $$1/4$$ $$5/4$$ $$40/4$$ $$40/4$$ 10
26 0 110 10 6 3 8 $$2/4=1/2$$ $$6/4$$ $$48/4$$ $$48/4$$ 12
27 Largest positive normalized 0 110 11 6 3 8 $$3/4$$ $$7/4$$ $$56/4$$ $$56/4$$ 14
28 + infinity 0 111 0 - - - - - - $$\infty$$ -
29 NaN - - - - - - NaN -

18
to.py

@ -0,0 +1,18 @@
gid = "g12"
graph = {
"a": ["b"],
"b": ["a", "c"],
"c": ["b", "d", "e", "s"],
"d": ["c", "s"],
"e": ["c", "g"],
"f": ["h"],
"g": ["e", "h", "t"],
"h": ["f", "g", "t"],
"s": ["c", "d"],
"t": ["g", "h"],
}
print("node|connections")
print("---|---")
for node,vertexes in graph.items():
print("<span id=\"{0}-{1}\">{1}</span>|{2}".format(gid, node, ",".join(["<a href=\"#{1}-{0}\">{0}</a>".format(v, gid) for v in vertexes])))

1083
tree.py

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save