This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
from typing import Dict, Tuple, List, Optional | |
@dataclass(frozen=True) | |
class Arrow: | |
name: str | |
src: str | |
tgt: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass, field | |
from typing import Callable, Iterable, List, Dict, Tuple, Optional, Set, Any | |
import itertools | |
import math | |
import json | |
############################ | |
# GF(2) linear algebra | |
############################ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fractions import Fraction | |
from collections import deque, defaultdict | |
# Full implementation embedded from notebook; to keep file compact we import from the executed cell would be ideal, | |
# but for portability we replicate the functions here. | |
def decide_rep_type(V, A): | |
if len(set(V)) != len(V): | |
return {"errors":[{"code":"INPUT_INVALID","message":"vertex IDs must be unique"}]} | |
Vset = set(V) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fractions import Fraction | |
from collections import defaultdict, deque | |
from itertools import combinations | |
def lex(labels): return sorted(labels) | |
class Rational(Fraction): __slots__ = () | |
def run_procedure(adj): | |
removed_loops, removed_parallels = [], [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict, Counter, deque | |
from typing import Any, Dict, List, Tuple, Hashable, Optional, Set | |
# ---------------------------- | |
# Core API | |
# ---------------------------- | |
def classify_compact_surface_components( | |
V: List[Hashable], | |
E: List[Tuple[Hashable, Hashable]], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
CLI for running olmocr OCR on PDFs using LM Studio. | |
Based on: | |
https://jonathansoma.com/words/olmocr-on-macos-with-lm-studio.html | |
Requirements: | |
- openai | |
- olmocr | |
- pypdf |