|
| 1 | +# Research note: Algebrica |
| 2 | + |
| 3 | +Sources: |
| 4 | + |
| 5 | +- <https://github.com/antoniolupetti/algebrica> |
| 6 | +- <https://algebrica.org> |
| 7 | + |
| 8 | +Algebrica is a free, ad-free mathematics knowledge base whose repository publishes source Markdown and editable SVG diagrams. Its README describes an editorial goal that is directly relevant to Python By Example: **reduce without distorting**. Pages are written from multiple university-level sources, reconciled into a coherent exposition, and revised as adjacent pages expose gaps or inconsistencies. |
| 9 | + |
| 10 | +## What we can learn |
| 11 | + |
| 12 | +### 1. Strong pages have a deliberate progression |
| 13 | + |
| 14 | +Algebrica pages do not read like disconnected fact lists. A page such as `definite-integrals` moves through a clear learning arc: |
| 15 | + |
| 16 | +```text |
| 17 | +geometric intuition |
| 18 | +→ approximation |
| 19 | +→ formal definition |
| 20 | +→ computation rule |
| 21 | +→ properties |
| 22 | +→ worked examples |
| 23 | +→ edge cases |
| 24 | +→ links to deeper pages |
| 25 | +``` |
| 26 | + |
| 27 | +For Python By Example, broad examples should have a comparable editorial progression: |
| 28 | + |
| 29 | +```text |
| 30 | +why this exists |
| 31 | +→ smallest concrete form |
| 32 | +→ runtime/protocol model |
| 33 | +→ common operations |
| 34 | +→ boundary or edge case |
| 35 | +→ worked output |
| 36 | +→ neighboring concepts |
| 37 | +``` |
| 38 | + |
| 39 | +The former `Operators and Literals` page failed this test: it sampled useful syntax but did not provide a coherent map. Splitting it into `Operators` and `Literals` improved the title-to-content contract. |
| 40 | + |
| 41 | +### 2. Reduce without distorting |
| 42 | + |
| 43 | +Small examples are valuable only when they preserve the concept. If an example compresses too much into one cell, it can become technically correct but educationally shallow. |
| 44 | + |
| 45 | +Example risk: |
| 46 | + |
| 47 | +```text |
| 48 | +Bytes and Bytearray: encode, length contrast, decode, and mutation all in one cell. |
| 49 | +``` |
| 50 | + |
| 51 | +Better progression: |
| 52 | + |
| 53 | +```text |
| 54 | +text → UTF-8 bytes |
| 55 | +bytes → text |
| 56 | +bytes indexing / immutability |
| 57 | +bytearray mutation |
| 58 | +``` |
| 59 | + |
| 60 | +### 3. Broad concepts need maps, not sample trays |
| 61 | + |
| 62 | +Algebrica handles broad topics by organizing subtopics. It does not merely sample a few facts and hope the title carries the rest. |
| 63 | + |
| 64 | +For us, broad pages should either: |
| 65 | + |
| 66 | +1. be scoped explicitly as a first pass / surface map, with links to focused neighbors; or |
| 67 | +2. be split into narrower examples. |
| 68 | + |
| 69 | +Examples that need this discipline include `Testing`, `Modules`, `Packages`, `Type Hints`, `Operators`, `Literals`, `Bytes and Bytearray`, and the type-system cluster. |
| 70 | + |
| 71 | +### 4. Teaching artifacts should be inspectable |
| 72 | + |
| 73 | +Algebrica releases source Markdown and editable SVGs. The lesson is not that Python By Example needs more diagrams; it is that core teaching artifacts should be inspectable, reusable, and versioned. |
| 74 | + |
| 75 | +For Python By Example, the inspectable artifacts are: |
| 76 | + |
| 77 | +- Markdown examples |
| 78 | +- `:::program` complete runner source |
| 79 | +- `:::cell` teaching fragments |
| 80 | +- expected output |
| 81 | +- official docs links |
| 82 | +- generated embedded source |
| 83 | +- tests and golden parity fixtures |
| 84 | +- rubric and lessons learned docs |
| 85 | + |
| 86 | +### 5. Cross-links should express prerequisites and next depth |
| 87 | + |
| 88 | +Algebrica links to prerequisite concepts and deeper topics as part of the explanation, not as decorative tags. |
| 89 | + |
| 90 | +For us, `See also` links should keep behaving like a conceptual graph: |
| 91 | + |
| 92 | +```text |
| 93 | +operators → assignment-expressions, operator-overloading |
| 94 | +literals → strings, bytes-and-bytearray, dicts |
| 95 | +bytes-and-bytearray → strings, networking |
| 96 | + type-aliases → type-hints, newtype |
| 97 | +``` |
| 98 | + |
| 99 | +### 6. Edge cases belong near the main idea |
| 100 | + |
| 101 | +The definite-integrals page introduces positive/negative area and improper integrals after the main computation story. Edge cases are part of the concept, not trivia hidden at the end. |
| 102 | + |
| 103 | +For Python examples, this suggests adding visible boundary cells for common misunderstandings: |
| 104 | + |
| 105 | +- `json`: non-JSON Python objects or decode errors |
| 106 | +- `testing`: failing-test output or what the result object records |
| 107 | +- `bytes-and-bytearray`: indexing bytes yields integers; `bytes` is immutable |
| 108 | +- `type-hints`: hints inform tools but do not enforce runtime behavior |
| 109 | +- `operators`: precedence and parentheses |
| 110 | + |
| 111 | +### 7. Process transparency builds trust |
| 112 | + |
| 113 | +Algebrica documents editorial process, source reuse, licensing, and revision. Python By Example should continue to surface its own trust signals: |
| 114 | + |
| 115 | +- official Python docs links |
| 116 | +- deterministic expected output |
| 117 | +- verification scripts |
| 118 | +- CI |
| 119 | +- cache/versioning checks |
| 120 | +- public Markdown source |
| 121 | +- quality rubric |
| 122 | +- lessons learned |
| 123 | + |
| 124 | +## Rubric changes implied |
| 125 | + |
| 126 | +Add or strengthen these rubric checks: |
| 127 | + |
| 128 | +1. **Editorial progression** — broad examples need a visible sequence, not a grab bag. |
| 129 | +2. **Scope contract** — title, summary, and first paragraphs must match the breadth of the code. |
| 130 | +3. **Reduction without distortion** — examples may be small, but not at the cost of removing a necessary boundary, contrast, or edge case. |
| 131 | +4. **Map-or-split rule** — broad pages must either become surface maps with links to focused neighbors or be split into narrower pages. |
| 132 | +5. **Edge case placement** — common edge cases should appear in cells or concrete notes near the main idea. |
| 133 | +6. **Inspectable artifact quality** — Markdown source should remain clean enough to serve as public educational material, not merely runtime input. |
| 134 | +7. **Conceptual links as graph edges** — `See also` should mark prerequisite/neighbor/next-depth relationships. |
| 135 | + |
| 136 | +## Known improvement queue |
| 137 | + |
| 138 | +### Improve existing examples |
| 139 | + |
| 140 | +High priority: |
| 141 | + |
| 142 | +- `bytes-and-bytearray` — split one compressed cell into encode/decode/immutability-mutation cells. |
| 143 | +- `type-aliases` — replace generic prose; contrast `type` aliases, assignment-style aliases, and `NewType`. |
| 144 | +- `operators` — monitor for sample-tray drift; add precedence/parentheses if readers need it. |
| 145 | +- `literals` — keep as source-syntax map; ensure it does not pretend to teach every value type deeply. |
| 146 | + |
| 147 | +Type-system cluster: |
| 148 | + |
| 149 | +- `runtime-type-checks` |
| 150 | +- `union-and-optional-types` |
| 151 | +- `typed-dicts` |
| 152 | +- `callable-types` |
| 153 | +- `generics-and-typevar` |
| 154 | +- `casts-and-any` |
| 155 | +- `newtype` |
| 156 | + |
| 157 | +Each should gain at least one contrast cell showing static-tool meaning versus runtime behavior or misuse boundary. |
| 158 | + |
| 159 | +Medium priority: |
| 160 | + |
| 161 | +- `numbers` — link complex literal syntax to `literals`; consider future `decimal-and-fractions`. |
| 162 | +- `modules` — scope as imports/namespaces; consider entry-point/import-system follow-ups. |
| 163 | +- `packages` — optionally add an illustrative package tree as `:::unsupported` or prose. |
| 164 | +- `regular-expressions` — keep scoped as first pass; consider flags/substitution only as focused follow-ups. |
| 165 | +- `testing` — consider failing-test output or fixtures if deterministic output stays readable. |
| 166 | +- `json` — consider indentation, decode errors, or non-JSON objects as a boundary cell. |
| 167 | +- `decorators` — consider `functools.wraps` metadata preservation. |
| 168 | +- `context-managers` — consider a small `__enter__` / `__exit__` protocol cell or stronger link to data model examples. |
| 169 | +- `exceptions` — consider `else` / `finally` cleanup if reliability coverage needs it. |
| 170 | + |
| 171 | +### Create new examples |
| 172 | + |
| 173 | +Potential focused pages: |
| 174 | + |
| 175 | +- `decimal-and-fractions` |
| 176 | +- `module-entry-points` |
| 177 | +- `import-system` |
| 178 | +- `regex-substitution` |
| 179 | +- `regex-flags` |
| 180 | +- `test-fixtures` |
| 181 | +- `pytest-style-tests` |
| 182 | +- `json-errors` |
| 183 | +- `operator-precedence` |
| 184 | +- `exception-cleanup` |
| 185 | + |
| 186 | +### Journey changes to consider |
| 187 | + |
| 188 | +- **Runtime** — ensure `Literals` and `Operators` remain placed by prerequisite logic, not catalog convenience. |
| 189 | +- **Control Flow** — keep `Operators` before `Conditionals` only while the page covers comparisons and boolean expressions. |
| 190 | +- **Types** — add contrast cells before adding more type pages; avoid a long list of shallow type examples. |
| 191 | +- **Reliability** — consider whether `Testing`, `Logging`, `Exceptions`, and cleanup examples form a stronger progression if `exception-cleanup` or `test-fixtures` is added. |
| 192 | +- **Interfaces** — keep the data-model sequence coherent: `Special Methods` → focused protocol pages → `Descriptors` → `Metaclasses`. |
| 193 | + |
| 194 | +### Remove or avoid |
| 195 | + |
| 196 | +- Avoid restoring a combined `Operators and Literals` page. |
| 197 | +- Avoid broad catch-all pages that merely list syntax without a learning progression. |
| 198 | +- Avoid adding new examples to journeys unless they strengthen the story rather than lengthen the index. |
0 commit comments