Skip to content
Polytope

Code

Code sits in a black exhibit panel. Comments are mustard, so the explanation reads before the syntax.

Stable Class names and props are not expected to change before 1.0.


In this chapter 14 pages

Code panels

train.py
# one step of message passing on a simplicial complex
def step(x, boundary, weight):
    up = boundary.T @ (boundary @ x)     # neighbors through shared cofaces
    down = boundary @ (boundary.T @ x)   # neighbors through shared faces
    return torch.relu((x + up + down) @ weight)

for epoch in range(200):
    loss = F.cross_entropy(model(x), y)
astro
<Code lang="python" title="train.py" code={source} />
PropEffectDefault
codeThe source text
langLanguage for highlightingtxt
titleShown in the bar; defaults to the language
copyShow the copy buttontrue

In plain HTML, wrap a <pre> in .ply-code and add a .ply-code__bar with a [data-ply-copy] button; copy.js handles the click. Spans with classes c, k, s, and n color comments, keywords, strings, and numbers if you highlight by hand.

Inline code and keys

Inline code like torch.sparse.mm sits on the wall gray. Keys look like this: Ctrl + K.

The highlighting theme

The panel colors are also a TextMate theme at dist/code-theme.json, for Shiki, Astro's Markdown, and VS Code. See Other targets.