Skip to content

Commit ac9c7f9

Browse files
Technologicatclaude
andcommitted
Type annotations: mathseq.py; new public API slift1/slift2
Type annotations for all 29 public exports, internal closures, and generator functions. Key decisions: - Numeric types are `Any` throughout (int/float/mpf/sympy.Expr polymorphism is fundamentally runtime-dynamic). - `TypeVar('T')` on `slift1`/`slift2` tracks op's return type through the lifted function: `Callable[..., T] -> Callable[[Iterable[T]|T], imathify|T]`. - `Literal` for `require` params and `primes(optimize=)`. - Comparison operators on `imathify` get `type: ignore[override]` — they return `imathify` (termwise), not `bool`. New public API: - `slift1(op)` / `slift2(op)`: lift scalar unary/binary operations to work termwise on iterables, returning `imathify`'d generators. These are the mechanism behind all built-in `s`-prefixed operators, now exposed for user-defined functions (e.g. `ssin = slift1(sin)`). Accept optional `*settings` for baking extra args into the operation. Other improvements: - `Iterable.register(imathify)` — virtual ABC registration, consistent with rest of unpythonic. - `hasattr(x, "__iter__")` → `isinstance(x, Iterable)` (3 sites); removes stale TODO about typing Protocol. - `spow`/`sround`: `*mod`/`*ndigits` varargs → `int | None = None`. - `primitive_*` operator aliases → `atom_*` (scalars, not stone tools). - Docstrings for internal closures `analyze`, `nofterms`, `iscyclic`. - Comments documenting the spec-parsing dispatch in `s()`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 46320c6 commit ac9c7f9

1 file changed

Lines changed: 254 additions & 163 deletions

File tree

0 commit comments

Comments
 (0)