diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d68251a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,76 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress +# +# Lint, format check, type check and the full pytest suite, with GNU Octave +# installed from the Ubuntu LTS apt package (docs/design.md section 12), so +# every rule case is executed in both languages. + +name: tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + checks: + name: ruff + mypy + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + + - name: Sync dependencies + run: uv sync --all-groups + + - name: Lint (ruff) + run: uv run ruff check . + + - name: Check formatting (ruff format) + run: uv run ruff format --check . + + - name: Type check (mypy) + run: uv run mypy dualect + + - name: Type check the rule translators (mypy) + run: uv run python tools/mypy_rules.py + + pytest: + name: pytest (Python ${{ matrix.python-version }}, Octave from apt) + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + python-version: ["3.11", "3.13"] + env: + # Fail, rather than skip, any test that needs Octave: in CI a missing + # Octave is a broken setup, not a reason to pass. + DUALECT_REQUIRE_OCTAVE: "1" + steps: + - uses: actions/checkout@v4 + + - name: Install GNU Octave (Ubuntu LTS package) + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends octave + octave --version | head -n 1 + + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + python-version: ${{ matrix.python-version }} + + - name: Sync dependencies + run: uv sync --all-groups + + - name: Run pytest + run: uv run pytest diff --git a/CLAUDE.md b/CLAUDE.md index 10c4787..a19bcab 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -14,8 +14,16 @@ architecture, the rule format and the milestones. ## Current state -Design only. No package code exists yet. Next step is milestone 1 in -docs/design.md (skeleton, rule schema, verify harness, Octave in CI). +Milestones 1-6 of docs/design.md are done. Both directions work end to end: +`.m` -> Python (dualect/lower.py, infer.py, emit.py; 30 of 35 rules mechanical) +and Python -> `.m` (dualect/pyinfer.py, lift.py, memit.py; 29 mechanical), one +rule folder per construct serving both (`from_python:` in rule.yaml, `lift()` in +translate.py, status per direction). `dualect rules check` enforces that every +status is earned; `dualect mcp` serves scan/get_rule/translate/verify; +`llms.txt` is generated (`dualect llms-txt -o llms.txt`) and must stay current. +Adversarial probes live in tests/test_adversarial.py and tests/test_reverse.py. +Next: more rules (the guided ones, `cumsum`, `filter`, printing), cell arrays +and structs. ## Core ideas to preserve @@ -23,7 +31,11 @@ docs/design.md (skeleton, rule schema, verify harness, Octave in CI). (`rule.yaml`, optional `translate.py`, `cases/*.m` + `*.py`). Keep rules small and independent so a language change touches one folder. - **Status lifecycle**: `unsupported` → `guided` → `mechanical`. Only promote a - rule to `mechanical` when its `translate.py` passes all its cases. + rule to `mechanical` when its `translate.py` passes all its cases: output equal + to the hand-written `.py` (comments ignored) *and* verified against Octave. + A translator that cannot translate a form correctly raises `Decline` (the + statement becomes a reported hole); a shape guess must go through + `ctx.assume` so the output says so. - **A behavior change in MATLAB/Octave is a new variant rule** with `since`/`until`, not an edit that breaks the old behavior. - **Never translate silently wrong.** Unknown constructs raise a named @@ -34,15 +46,19 @@ docs/design.md (skeleton, rule schema, verify harness, Octave in CI). - `rule.yaml` `why`/`pitfalls` text is written for both a human learner and an LLM; keep it precise and short. -## Tooling (planned; match first-principles-code conventions) +## Tooling (matches first-principles-code conventions) Python 3.11+ managed with **uv**; ruff, mypy, pytest. ```bash uv sync --all-groups # install uv run pytest # tests (Octave-dependent tests skip if Octave is absent) +uv run pytest -m 'not octave' # only the tests that need no Octave uv run ruff check . && uv run ruff format . uv run mypy dualect +uv run python tools/mypy_rules.py # mypy over rules/**/translate.py +uv run dualect rules check # every rule earns its status, both directions +uv run dualect llms-txt -o llms.txt # after adding or changing a rule ``` Octave is needed for execution tests (`brew install octave` on macOS). diff --git a/README.md b/README.md index 4d72a2f..a8449b9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ Translate numeric code between Octave/MATLAB-style `.m` files and Python/NumPy, in both directions, with every translation **verified by running both sides**. -> **Status: design phase.** Nothing is installable yet. See [docs/design.md](docs/design.md). +> **Status: early.** Both directions work end to end: `.m` → Python with 30 of 35 +> rules mechanical, Python → `.m` with 29 mechanical, every case verified by running +> both languages. See [docs/design.md](docs/design.md) section 11. ## Why @@ -16,14 +18,84 @@ or built-in (indexing with `end`, `*` vs `.*`, `linspace`, ...). Dependable rule a scripted translator; the rest are handed to an LLM as focused context; every result is executed and compared. -## Planned usage +## Usage ```bash -dualect scan script.m # which rules does this file need? -dualect translate script.m -o script.py # translate (scripted + LLM-guided) -dualect verify script.m script.py # run both, compare outputs +uv sync --all-groups # install (Python 3.11+, uv) +uv run pytest # rules, translators, corpus, both directions +uv run ruff check . && uv run ruff format --check . +uv run mypy dualect && uv run python tools/mypy_rules.py ``` +### `.m` → Python + +```bash +uv run dualect translate script.m -o script.py # translate, then verify by running both +uv run dualect scan script.m # which rules does it need? what has none? +uv run dualect context script.m # those rules as LLM-ready prompt context +uv run dualect verify script.m script.py # run both sides, compare every variable +``` + +`translate` handles each statement with the rules' deterministic translators. A +statement it cannot translate correctly is left as a `TODO(dualect)` hole that raises +`NotImplementedError`, and is reported; `dualect context` prints the rules an LLM +needs to fill it, and `--strict` refuses to write anything incomplete. The first line +of the output says whether it was verified against the `.m` source. Where a shape had +to be assumed the line says so (`# dualect: assumed ...`), and `# dualect: index k` +marks a variable stored 0-based because it only ever holds positions. + +The `.m` side may use Octave syntax (`#` comments, `!=`, `++`, `+=`, +`do ... until`, `endfunction`); `--dialect matlab` reports it as Octave-only. + +### Python → `.m` + +```bash +uv run dualect translate model.py -o model.m # the direction follows the suffix +uv run dualect scan model.py # rules needed, Python constructs with none +uv run dualect context model.py +``` + +The same rules translate back: a 1-D NumPy array becomes a `1xN` row, `A @ v` +becomes `(A * v.').'`, `x[i]` becomes `x(i + 1)` (variables keep their Python +values), and the output is checked by running the `.py` and the `.m`. Holes are +`% TODO(dualect)` comments followed by `error(...)`. Python behaviour with no `.m` +counterpart is declined, not imitated: writing through a NumPy view or alias, a +function writing into its array argument, a lambda that reads a variable changed +later, `max` of data that may hold NaN, and the like (design section 5.5). + +### Rules + +```bash +uv run dualect rules list [--status guided] [--direction from-python] +uv run dualect rules check [RULE_ID ...] # does each rule earn its status, both ways? +uv run dualect rules new indexing/foo # scaffold a rule folder +uv run dualect llms-txt -o llms.txt # regenerate the one-line-per-rule index +``` + +`rules check` runs every rule's translator on its cases in each direction, compares +the result with the hand-written target and runs both sides; it fails when a rule +marked `mechanical` does not qualify, or a `guided` one does (promote it). +[`llms.txt`](llms.txt) lists every rule in one line for an LLM. + +### MCP server + +```bash +uv run dualect mcp # stdio; tools: scan, get_rule, translate, verify +``` + +A client configuration (Claude Code, Claude Desktop, ...) looks like: + +```json +{"mcpServers": {"dualect": {"command": "uv", + "args": ["run", "--directory", "/path/to/dualect", "dualect", "mcp"]}}} +``` + +The server gives the client's model the rules and the checks; dualect itself never +calls an LLM API, and anything the model writes can be checked with `verify`. + +`translate`, `verify` and the execution tests need GNU Octave (`brew install octave`, +`apt install octave`). + ## License Apache-2.0. MATLAB is a registered trademark of The MathWorks, Inc. dualect is not diff --git a/corpus/beam_deflection.m b/corpus/beam_deflection.m new file mode 100644 index 0000000..5a6e913 --- /dev/null +++ b/corpus/beam_deflection.m @@ -0,0 +1,39 @@ +% Deflection of a simply supported steel beam under a uniform load and a +% point load, by superposition of the Euler-Bernoulli closed-form solutions. +L = 4.0; % span [m] +E = 200e9; % Young's modulus [Pa] +I = 8.5e-6; % second moment of area [m^4] +w = 5e3; % uniform load [N/m] +P = 12e3; % point load [N] +a = 1.5; % position of the point load from the left support [m] +b = L - a; + +n = 81; +x = linspace(0, L, n); + +% Uniform load: v(x) = w x (L^3 - 2 L x^2 + x^3) / (24 E I) +v_uniform = w * x .* (L^3 - 2*L*x.^2 + x.^3) / (24*E*I); + +% Point load at x = a: the solution is piecewise. +v_point = zeros(1, n); +for k = 1:n + if x(k) <= a + v_point(k) = P*b*x(k)*(L^2 - b^2 - x(k)^2) / (6*E*I*L); + else + v_point(k) = P*a*(L - x(k))*(2*L*x(k) - x(k)^2 - a^2) / (6*E*I*L); + end +end + +v = v_uniform + v_point; +[v_max, k_max] = max(v); +x_max = x(k_max); + +% Support reactions and the bending moment along the beam. +R_left = w*L/2 + P*b/L; +R_right = w*L + P - R_left; +M = R_left*x - w*x.^2/2; +right_of_load = x > a; +M(right_of_load) = M(right_of_load) - P*(x(right_of_load) - a); +M_max = max(M); + +fprintf('max deflection %.2f mm at x = %.2f m\n', v_max*1e3, x_max); diff --git a/corpus/ode_rk4.m b/corpus/ode_rk4.m new file mode 100644 index 0000000..2deaaee --- /dev/null +++ b/corpus/ode_rk4.m @@ -0,0 +1,27 @@ +% Damped harmonic oscillator x'' + 2 zeta w0 x' + w0^2 x = 0, integrated with +% the classic fourth-order Runge-Kutta method and compared with the exact +% solution. +w0 = 2*pi; % natural frequency [rad/s] +zeta = 0.1; % damping ratio +f = @(t, y) [y(2); -2*zeta*w0*y(2) - w0^2*y(1)]; + +t_end = 3; +h = 0.01; +t = 0:h:t_end; +n = numel(t); +y = zeros(2, n); +y(:, 1) = [1; 0]; % x(0) = 1, x'(0) = 0 + +for k = 1:n-1 + k1 = f(t(k), y(:, k)); + k2 = f(t(k) + h/2, y(:, k) + h/2*k1); + k3 = f(t(k) + h/2, y(:, k) + h/2*k2); + k4 = f(t(k) + h, y(:, k) + h*k3); + y(:, k+1) = y(:, k) + h/6*(k1 + 2*k2 + 2*k3 + k4); +end + +wd = w0*sqrt(1 - zeta^2); +x_exact = exp(-zeta*w0*t) .* (cos(wd*t) + zeta*w0/wd*sin(wd*t)); +err = max(abs(y(1, :) - x_exact)); +energy = 0.5*y(2, :).^2 + 0.5*w0^2*y(1, :).^2; +decay = energy(end) / energy(1); diff --git a/corpus/signal_filter.m b/corpus/signal_filter.m new file mode 100644 index 0000000..ee31a89 --- /dev/null +++ b/corpus/signal_filter.m @@ -0,0 +1,41 @@ +% Moving-average (FIR) and first-order low-pass (IIR) filtering of a noisy +% sine, written out as loops and checked against the built-in filter(). +fs = 200; % sample rate [Hz] +t = (0:1/fs:1-1/fs)'; % sample times, as a column +clean = sin(2*pi*5*t); +noise = 0.3*sin(2*pi*60*t) + 0.1*cos(2*pi*90*t); % deterministic "noise" +x = clean + noise; + +% Moving average over N samples. +N = 9; +b = ones(N, 1) / N; +y_fir = zeros(size(x)); +for n = 1:numel(x) + acc = 0; + for k = 1:N + if n - k + 1 >= 1 + acc = acc + b(k) * x(n - k + 1); + end + end + y_fir(n) = acc; +end + +% First-order low-pass: y(n) = alpha x(n) + (1 - alpha) y(n-1). +fc = 10; +alpha = 1 - exp(-2*pi*fc/fs); +y_iir = zeros(size(x)); +y_iir(1) = alpha * x(1); +for n = 2:numel(x) + y_iir(n) = alpha * x(n) + (1 - alpha) * y_iir(n-1); +end + +% The same filters with the built-in. +y_fir_ref = filter(b, 1, x); +y_iir_ref = filter(alpha, [1, alpha - 1], x); +fir_err = max(abs(y_fir - y_fir_ref)); +iir_err = max(abs(y_iir - y_iir_ref)); + +% Residual noise power once the moving average has filled up. +settled = t >= (N - 1) / fs; +p_fir = mean((y_fir(settled) - clean(settled)).^2); +p_iir = mean((y_iir(settled) - clean(settled)).^2); diff --git a/docs/design.md b/docs/design.md index b5eb3a0..5880ae0 100644 --- a/docs/design.md +++ b/docs/design.md @@ -1,6 +1,6 @@ # dualect — design -Status: draft, 2026-11-12. Nothing here is built yet; this document is the plan. +Status: 2026-11-13. This document is the plan; section 11 tracks what is built. ## 1. Problem @@ -76,6 +76,7 @@ id: indexing/end-in-index title: "`end` inside an index expression" status: mechanical # mechanical | guided | unsupported dialects: [octave, matlab] +match: [index:end] # construct tags this rule covers (section 5.3) since: {octave: "3.0", matlab: "R2006a"} # optional version range until: null octave: | @@ -168,6 +169,168 @@ matrix or matrix × matrix?). Strategy, in order: 2. Emit the safe form plus a `# dualect: assumed matrix multiply` comment. 3. Let verification catch the wrong guess. +Step 1 is `dualect/infer.py`: a flow-sensitive analysis over the IR that records, +for every expression, its shape class (scalar, row, column, matrix, empty, ...), +known dimensions, element type (real, complex, logical, char) and whether it is +known to be finite, non-negative or integer-valued. Branches are joined, loops +iterated to a fixed point, and each local function is analysed once for the +join of the argument facts at its call sites in the file. + +### 5.3 Parsing, construct tags and scanning (settled in milestone 3) + +- **Octave dialect.** `tree-sitter-matlab` knows only MATLAB syntax. Given + Octave's extensions it reports errors (`#` comments, `#{ #}` blocks, `!=`, + `!x`, `+=`) or, worse, misreads them silently (`do` and `until` parse as + command syntax, `n++` as `n + (+ )`). `dualect/source.py` rewrites + them, outside strings and comments, into forms the grammar reads (`#` -> `%`, + `!=` -> `~=`, `endfunction` -> `end` + spaces, `do`/`until` -> marker + `while`/assignment pairs, `x += e` and `x++` with the operator kept in a side + table) and records each use, so `--dialect matlab` can reject them. No newline + is added or removed and positions are mapped back to the original text. +- **Precedence.** The grammar nests some operator chains wrongly (`-2 ^ 2` as + `(-2) ^ 2`, `a == b & c` as `a == (b & c)`, `a.^b'` as `a.^(b')`). The + lowering flattens every operator chain and rebuilds it with the documented + precedence (`2^-2^2` is `(2^-2)^2`, checked against Octave 11). +- **Names.** `f(x)` is an index when `f` is assigned anywhere in the enclosing + function or script (or is a parameter/output), otherwise a call. +- **Construct tags.** The scanner tags each statement with what it uses: + `op:mtimes`, `index:end`, `call:linspace`, `assign:grow`, ... (the vocabulary + is `dualect/constructs.py`). Each `rule.yaml` lists the tags it covers in + `match`, so a new built-in is a new folder with `match: [call:foo]` and no + engine change. Two unversioned rules may not claim the same tag. Some tags + need inferred facts: `index:logical` (a logical subscript) and `assign:grow` + (a subscript of `end+k` or a constant beyond the known size, or a variable + that is undefined or `[]`). A subscript that is merely *unknown* is not a + grow: NumPy raises `IndexError` there, so a wrong guess is loud. +- **Gaps are named.** A tag no rule matches is reported as unsupported under + that tag (`call:strsplit`, `expr:field`, `stmt:try`); text the parser could + not read is `parse:error`; Octave-only syntax under `--dialect matlab` is + `dialect:octave-only`. +- **Context.** `dualect context` prints a two-line header (the rules, and the + constructs with no rule) followed by each needed rule's `rule.yaml` and up to + two cases (`basic` first), as Markdown. Nothing else. + +### 5.4 Translation (settled in milestone 4) + +- **Representation.** Source scalars become Python numbers; a `1xN` row and an + `Nx1` column both become 1-D arrays (the analysis remembers which one it was, + so `c + r` gets `c[:, np.newaxis]` and `u' * v` becomes `np.outer(u, v)`); + only a true matrix is 2-D; char arrays become `str`. +- **Per statement.** Every statement is planned from its construct tags: all + of its rules `mechanical` -> translated by their `translate.py`; otherwise it + becomes a *hole*, a `TODO(dualect)` comment carrying the source line and the + reason, followed by `raise NotImplementedError`, so partial output can never + run past an untranslated statement. A translator that meets a form it cannot + translate correctly raises `Decline`, which also makes a hole (reported as + `guided`). The report lists every statement with its rules, the status used + and whether the file verified. +- **Translators** (`rules///translate.py`, loaded by + `dualect/translators.py`) define `translate(node, ctx)` and optionally + `translate_store`, `translate_multi`, `position_outputs` and + `translate_positions`. They build Python `ast` nodes through the `Context` of + `dualect/emit.py`, which gives them facts (`ctx.info`), sub-expressions + (`ctx.expr`), other mechanical rules' helpers (`ctx.module`) and the + assumption channel (`ctx.assume`, emitted as `# dualect: assumed ...`). +- **Shared semantics in the engine**, not in any one rule: copy-on-write (an + assignment `y = x`, a slice or a transpose gets `.copy()` when either side is + later modified in place; a parameter the function modifies is copied on + entry), and *position variables*: a variable that only ever holds positions + (integer literals, `find`, the second output of `max`, a `for` range) and is + only read inside subscripts is stored 0-based, so `i = 2; x(i + 1)` becomes + `i = 1; x[i + 1]` and `for k = 1:n` over subscripts becomes `range(n)`. At + script level such a variable gets a `# dualect: index` directive so `verify` + compares it as 0-based. +- **Never silently wrong**, concretely: an element store into an array the + translation holds as integers (`np.array([1, 2, 3])`) is declined unless the + value is known to be an integer (NumPy would truncate); `max`/`min` of data + not known to be NaN-free use `np.nanmax`/`np.fmax`; a `continue` inside + `do ... until` is declined; indexing an array of unknown shape assumes a + vector, and a product of unknown shapes assumes `@`, each with an `assumed` + comment that verification then checks. +- **Hardening (settled after milestone 4 by adversarial probes, + `tests/test_adversarial.py`).** A local function is analysed once for the + join of its call sites, and so is a lambda: its body is annotated with the + join of every call's argument facts, never the last call's. A row at one + call and a column at another join to a vector of *unknown orientation*, and + products, element-wise operations against a row/column, `size` and + concatenation of such a vector are declined rather than assumed (each call + needs a different `@`/broadcast). Logical operands are numbers in the source + but NumPy keeps `bool + bool` as `bool`, so arithmetic on two logical + operands converts the left one (`m.astype(int) + m`). NumPy integers wrap + around where the source computes in doubles: `.^` on an integer array with + an exponent above 2 or unknown is computed in floats (`x**40.0`, `2.0**x`), + and `prod` of integers takes `dtype=float`. `mod`/`rem` by a known zero are + declined (the source returns `x`), by an unknown divisor assumed nonzero. + `for c = A` iterates `A.T.copy()` when the body writes into `c` (rows of + `A.T` are views), and a loop over a range known to be empty is declined + (the source leaves the variable as a `1x0` array). The normalizer turns + `2.^x` into `2 .^x`: the grammar read it as the number `2.` and a matrix + power. Horizontal concatenation of columns and matrices is + `np.column_stack`. +- **Output.** ruff formats the file (its default style, so the result does not + depend on the caller's configuration). The first line states the verdict: + `verified against the .m source`, or `UNVERIFIED: ` (holes, no + Octave, `--no-verify`, or differing outputs). Exit codes: 0 verified, + 1 verification failed or `--strict` stopped (nothing written), 4 written but + incomplete or unverified. Float literals keep their source spelling. +- **Layer 2 comparison** (section 7): translator output and the hand-written + case are both printed back with `ast.unparse`, which removes formatting and + comments; case comments are teaching notes, not code. + +### 5.5 Python -> `.m` (settled in milestone 5) + +- **One rule folder, two directions.** A rule covers Python constructs under + `from_python: {status, match}` in its `rule.yaml`, next to the `.m` tags in + `match`; its `translate.py` adds `lift(node, ctx)` (and `lift_store`, + `lift_multi`, `lift_assign` where needed) beside `translate`. Status is + tracked per direction: `status` is `.m` -> Python, `from_python.status` is + Python -> `.m`, and a rule may be `mechanical` one way and `guided` the + other. Python construct tags are `py:`-prefixed (`py:op:matmult`, + `py:call:np.zeros`, `py:method:sum`, `py:subscript`, `py:for`, ...; the + vocabulary is `dualect/pyconstructs.py`); a tag no rule claims is reported + as unsupported by name (`py:call:np.fft.fft`, `py:stmt:try`, + `py:import:scipy`). +- **Pipeline.** `dualect/pyinfer.py` infers facts over the Python `ast` + (1-D vs 2-D, dtype, NaN-free, non-negative, may-be-a-view), because lifting + depends on them. `dualect/lift.py` plans each statement exactly like the + other direction (every construct must be `mechanical` from Python, else a + hole: a `TODO(dualect)` comment and an `error(...)` call), and rules lift + Python nodes into the shared IR, which already has `.m` semantics (1-based + `Index`, inclusive `Range`, `mtimes`). `dualect/memit.py` only prints it: + precedence, layout, comments, `1;` before functions, commas between matrix + elements. `translate`, `scan` and `context` pick the direction from the + suffix of the source file. +- **Representation.** A 1-D NumPy array is a `1xN` row on the `.m` side. So + `A @ v` is `(A * v.').'`, `u @ v` is `u * v.'`, `np.outer(u, v)` is + `u.' * v`, `A[:, j]` is `A(:, j+1).'`, `A.sum(axis=1)` is `sum(A, 2).'`, + `for c in A.T` is `for c = A` with `c = c.'` first in the body. +- **Values stay Python's.** Indices are shifted where they are *used* + (`x[i]` is `x(i + 1)`), so every variable holds the same value on both + sides and verification needs no `index` directives; positions a function + returns stay 0-based (`i = np.argmax(v)` is `[~, i] = max(v); i = i - 1`). + The source's own `dualect:` directives are never copied; verifying a + `.py` -> `.m` translation uses only the generated file's directives. +- **Never silently wrong, from Python.** Declined (a guided hole), because + the `.m` side has no counterpart: writing through a NumPy alias or view + (`y = x; y[0] = 1`); a `def` writing into an array argument without copying + it first; a `def` reading a module-level variable; a lambda whose free + variable changes after it is created (Python binds late, a handle captures); + a variable that would hide a function the translation calls (`max = 3`); + storing fractions into an integer array or numbers into a boolean array + (NumPy truncates or converts); arithmetic on two boolean arrays (NumPy's + `bool + bool` is OR); `max`/`argmax`/`np.maximum`/`np.clip` of data that + may hold NaN (NumPy propagates it, the `.m` side skips it); `np.round` of + fractions (halves to even); `np.linspace(a, b, 1)`; `and`/`or` whose value + (an operand) is used outside a condition; `~` on integers (bitwise); + 2-D masks (row vs column order); a function that returns on some paths + only. Assumed out loud (`% dualect: assumed ...`) and left to verification: + a variable index or slice bound not known to be non-negative (it would count + from the end in Python), `sqrt`/`log`/fractional powers of data not known to + be non-negative (NaN vs complex), unknown divisors of `%`, `//`, `np.mod`. +- **Verification** runs the original `.py` and the generated `.m` and + compares them as in section 12.1; the output's first line states the + verdict (`% ... verified against the .py source` or `UNVERIFIED: ...`). + ## 6. LLM integration The repo is the LLM's memory: models do not retain anything between tasks, so the @@ -176,9 +339,28 @@ knowledge must be cheap to fetch in exactly the right slice. - `dualect scan file.m` lists the rule ids a file needs. - `dualect context file.m` prints those rules (`rule.yaml` + one or two cases), nothing else; that is the prompt context. -- `llms.txt` (generated) indexes all rules with one line each. -- An MCP server (later) exposes `scan`, `get_rule`, `translate`, `verify` as tools, - following the pattern used by first-principles-code's `fpc-mcp`. +- `llms.txt` (generated by `dualect llms-txt -o llms.txt`) indexes all rules + with one line each: id, title, status per direction, case count. A test + fails when the committed file is stale. +- An MCP server, `dualect mcp` (stdio, built on the official `mcp` Python SDK, + 2.x `MCPServer` API), exposes `scan` (the `scan --json` data, either + direction), `get_rule` (a rule's `rule.yaml` and cases as Markdown, with + its status per direction), `translate` (either direction, verified, the + output text and per-statement report; writes a file only when given + `output`) and `verify`. It never calls an LLM API. +- **Promotion check** (`dualect rules check [ids] [--direction ...] + [--no-verify]`, `dualect/promotion.py`, section 4.3): for each rule and each + direction it declares, every case is translated, compared with the + hand-written target (layer 2) and verified by execution. A direction + qualifies for `mechanical` when the translator exists, no case has a hole, + layer 2 matches (to Python) and every case verifies. The check fails when a + `mechanical` rule does not qualify and when a `guided` rule does (promote + it); `tests/test_milestone6.py` runs it over every rule in both directions. + From Python, layer 2 lowers the generated and the hand-written `.m` into + the IR and compares them structurally, but it is reported, not required: + the hand-written `.m` cases are idiomatic sources for the other direction + (1-based positions, `end` forms) that a value-preserving translation from + Python does not reproduce. LLM output is never trusted directly: it goes through step 6 (verify) like everything else, and the report marks which nodes were LLM-translated. @@ -190,7 +372,9 @@ Three layers, from cheap to realistic: 1. **Rule cases** (`rules/**/cases/`): each `.m`/`.py` pair runs in both languages and outputs are compared. A failure points at exactly one rule. 2. **Translator tests**: each `translate.py` on its own cases yields code that - matches (after formatting) the hand-written `.py`. + matches (after formatting, comments ignored) the hand-written `.py`, and + that code verifies by execution. A `guided` rule whose cases all pass this + is flagged for promotion. 3. **Combination corpus** (`corpus/`): realistic multi-construct snippets (a beam-deflection script, an ODE solve, a signal filter). Most real bugs are rule interactions (`end` + grow-on-assign + preallocation), and they show up @@ -199,17 +383,24 @@ Three layers, from cheap to realistic: Octave is required for execution tests; CI installs it. Tests that need Octave are marked so they skip cleanly on machines without it. -## 8. CLI (planned) +## 8. CLI ```bash -dualect scan script.m # which rules does this file need? +dualect scan script.m [--json] # which rules does this file need? dualect context script.m # LLM-ready context for those rules dualect translate script.m -o script.py [--strict] [--dialect matlab@R2023a] dualect verify script.m script.py # run both, compare -dualect rules list [--status guided] # coverage at a glance +dualect rules list [--status guided] # coverage at a glance, both directions +dualect rules check [ids] [--no-verify] # does each rule earn its status? (section 6) dualect rules new indexing/foo # scaffold a rule folder +dualect translate model.py -o model.m # the other direction (section 5.5) +dualect llms-txt -o llms.txt # regenerate the rule index +dualect mcp # MCP server on stdio ``` +`scan`, `context` and `translate` take `--dialect`; `scan --json` gives +machine-readable output; `translate` also takes `--no-verify`. + ## 9. Tech stack - Python 3.11+ managed with uv; ruff, mypy, pytest (same conventions as @@ -231,26 +422,96 @@ good seed for `builtins/*` rules (link, don't copy). ## 11. Milestones -1. **Skeleton**: package, CLI stub, rule schema + validator, rule scaffolder, +1. **Skeleton** (done): package, CLI stub, rule schema + validator, rule scaffolder, Octave-in-CI. Verify harness runs one hand-written pair. -2. **First 20 rules**, Octave → Python, all with cases: +2. **First 20 rules** (done: the list below is 26 rules, all `guided`, 37 case + pairs, each executed in both languages by `tests/test_rules.py`), Octave → + Python, all with cases: - syntax: comments, line continuation, command vs function syntax - indexing: one-based, ranges, `end`, logical indexing, grow-on-assign, colon `(:)` - operators: `*` vs `.*`, `'` vs `.'`, `^` vs `.^`, `~=`/`!=`, `&&`/`||` - control-flow: `for` over matrix columns, `while`, `if/elseif`, `switch` - functions: definition, multiple returns, `nargin` - builtins: `zeros/ones/eye`, `linspace`, `size/numel/length`, `sum/mean/max`, `find` -3. **Scanner + context command** (the LLM path works end to end). -4. **Deterministic translators** for the mechanical subset; combination corpus. -5. **Python → Octave** for the same subset via the shared IR. -6. **MCP server**, promotion-loop tooling, `llms.txt`. - -## 12. Open questions - -- Target style: plain NumPy only, or allow an optional small helper module for - constructs with no clean NumPy idiom (cell arrays)? Leaning: plain NumPy, helper - only as an opt-in flag. -- Which Octave version does CI pin? (Ubuntu LTS package vs a container image.) -- Tolerance policy for verify: global default plus per-rule override? -- Should rules live in this repo only, or be publishable as a data package other - tools can consume? +3. **Scanner + context command** (done: section 5.3; 35 rules after adding + `syntax/array-literals`, `types/char-strings`, `operators/arithmetic`, + `operators/division`, `operators/augmented-assignment`, + `builtins/elementwise-math`, `builtins/constants`, `builtins/isempty` and + `io/display`, which the scanner showed every real file needs). The IR, the + lowering and shape inference landed here because the scanner walks the IR. +4. **Deterministic translators** for the mechanical subset; combination corpus + (done: section 5.4). 30 of 35 rules are `mechanical`: every case of each + translates to the hand-written `.py` and verifies against Octave + (`tests/test_translate.py`). Still `guided`: `functions/multiple-returns` + (needs `nargout`-dependent bodies collapsed into one tuple return), + `functions/nargin` (the `isempty` default pattern and `np.clip` need + argument facts the analysis does not derive), `indexing/grow-on-assign` + (the idiomatic list-append and `np.pad` rewrites span statements), + `io/display` (printf formats) and `syntax/command-syntax` (its case needs + `strsplit`). Three hand-written case files changed to the equally idiomatic + form a statement-by-statement translator produces: `x = 1` (was `1.0`) in + control-flow/while, `x**-1.0` on an integer array in operators/power, and + line-by-line `z = x; z = z[~(z < 0)]` and `C = A.copy(); C[:] = ...` in + indexing/logical and indexing/colon-all. `corpus/` holds three scripts + (`tests/test_corpus.py`): `ode_rk4.m` translates completely and verifies; + `beam_deflection.m` is 29/30 (its `fprintf` is guided) and + `signal_filter.m` 29/33 (`filter` has no rule; two statements depend on it). +5. **Python → Octave** for the same subset via the shared IR (done: section + 5.5). Of the 35 rules, 29 are `mechanical` from Python (every `.py` case + translates completely and verifies against its `.py` source; this includes + `functions/multiple-returns`, still `guided` to Python), 3 are `guided` + (`functions/nargin`, `indexing/grow-on-assign`, `io/display`) and 3 claim + no Python construct (`builtins/isempty`, `syntax/line-continuation`, + `syntax/command-syntax`). The corpus runs in + reverse (`tests/test_reverse.py`): `ode_rk4` round-trips `.m` -> `.py` -> + `.m` completely and verifies; the other two carry the holes of their + forward translation. Before it, adversarial probes hardened the `.m` -> + Python direction (section 5.4). +6. **MCP server**, promotion-loop tooling, `llms.txt` (done: section 6). + The promotion check also found a runner bug: a script run from a temporary + folder that was deleted afterwards left Octave in a missing working + directory, failing every later script; the runner now changes directory + before clearing the workspace. + +## 12. Decisions + +Settled by the owner on 2026-11-12 (these were the open questions of the first draft): + +- **Target style**: plain NumPy only. No helper module, not even opt-in; a + construct with no clean NumPy idiom is `guided` or `unsupported`, not emulated. +- **Octave in CI**: the Ubuntu LTS apt package (`apt-get install octave` on + `ubuntu-24.04`), not a pinned container image. CI sets + `DUALECT_REQUIRE_OCTAVE=1` so Octave tests fail instead of skipping there. +- **Verify tolerance**: a global default (`rtol=1e-9`, `atol=1e-12`, in + `dualect/compare.py`) with a per-rule override in `rule.yaml` + (`tolerance: {rtol: ..., atol: ...}`). +- **Where rules live**: in this repository only (a built wheel carries a copy so + an installed `dualect` still finds them). No separate data package. +- **LLM calls**: dualect itself never calls an LLM API. The guided path only + *produces context* (`dualect context`, later the MCP server); whichever LLM the + user runs does the translating, and its output comes back through `verify`. + +### 12.1 Verify semantics (milestone 1) + +How `dualect verify a.m a.py` and the rule-case tests decide two scripts agree: + +- A script's outputs are the variables it leaves in its workspace. The `.m` + side runs via oct2py (`source`, in a cleared workspace); the `.py` side runs in + a fresh namespace. `ans`, `_`-prefixed names, modules, classes and `def` + functions are not outputs. +- Every `.m` output must exist in Python with an equal value. Python-only names + are allowed (idiomatic code may need temporaries) and listed in the report. A + pair that compares nothing fails. +- Values: `numpy.allclose` with NaN equal to NaN; singleton dimensions ignored + (Octave's `1xN` equals a NumPy 1-D array) but other shapes must match; two + empty arrays are equal; logical vs numeric is a mismatch; int vs float is not. + Structs compare as dicts, cells as lists (column-major order). Function + handles and lambdas only agree on *being* callable. +- Directives in comments of either file: `% dualect: index i j` (1-based in + `.m`, 0-based in Python, compared as `m - 1`) and `% dualect: ignore k` + (e.g. a loop variable whose final value legitimately differs). Unknown + directives are errors, so a typo cannot silently weaken a check. +- `.m` case scripts that define functions start with `1;` and define them before + use: Octave does not accept functions at the end of a script. +- A case file must not be named like a function it calls (`round.m`): the + harness runs it from its own folder, where it would shadow the built-in. diff --git a/dualect/__init__.py b/dualect/__init__.py new file mode 100644 index 0000000..ba46744 --- /dev/null +++ b/dualect/__init__.py @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""dualect: a tested knowledge base of rules for translating numeric code +between ``.m`` files and Python/NumPy, with every translation verified by +running both sides. See docs/design.md. +""" + +__version__ = "0.1.0" diff --git a/dualect/__main__.py b/dualect/__main__.py new file mode 100644 index 0000000..5d83806 --- /dev/null +++ b/dualect/__main__.py @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Allow ``python -m dualect`` as an alias for the ``dualect`` command.""" + +import sys + +from dualect.cli import main + +sys.exit(main()) diff --git a/dualect/cli.py b/dualect/cli.py new file mode 100644 index 0000000..f8915dd --- /dev/null +++ b/dualect/cli.py @@ -0,0 +1,296 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""The ``dualect`` command (docs/design.md section 8). + +:: + + dualect scan script.m [--json] # which rules does this file need? + dualect context script.m # LLM-ready context for those rules + dualect translate script.m -o out.py [--strict] [--dialect matlab@R2023a] + dualect translate script.py -o out.m [--strict] # the other direction + dualect verify script.m script.py # run both, compare + dualect rules list [--status guided] [--direction from-python] + dualect rules check [RULE_ID ...] [--direction from-python] [--no-verify] + dualect rules new indexing/foo + dualect llms-txt [-o llms.txt] # one line per rule, for LLMs + dualect mcp # MCP server on stdio + +Exit codes: 0 success; 1 verification or validation failed, ``--strict`` +stopped, or an error was reported; 2 bad command-line usage (argparse); +3 command not implemented yet; 4 ``translate`` wrote an incomplete or +unverified translation (its report and first line say which). +""" + +import argparse +import dataclasses +import sys +from collections.abc import Sequence +from pathlib import Path + +from dualect import __version__ +from dualect.compare import DEFAULT_ATOL, DEFAULT_RTOL, Tolerance +from dualect.context import build_context +from dualect.dialect import parse_dialect +from dualect.errors import DualectError +from dualect.llmstxt import render_llms_txt +from dualect.paths import default_rules_dir +from dualect.pipeline import StrictModeError, translate_file +from dualect.promotion import check_rules +from dualect.promotion import report as promotion_report +from dualect.rulebook import DIRECTIONS, TO_PYTHON, Status, load_rules +from dualect.scaffold import new_rule +from dualect.scan import ScanResult, scan_file +from dualect.verify import options_for_pair, verify_pair + +EXIT_OK = 0 +EXIT_FAILED = 1 +EXIT_NOT_IMPLEMENTED = 3 +EXIT_INCOMPLETE = 4 + + +def _scan_source(args: argparse.Namespace) -> ScanResult: + """Scan the file named on the command line with the chosen rules and dialect.""" + rules = load_rules(rules_dir=args.rules_dir) + return scan_file(path=args.source, rules=rules, dialect=parse_dialect(args.dialect)) + + +def _scan(args: argparse.Namespace) -> int: + """Handle ``dualect scan``.""" + result = _scan_source(args) + print(result.to_json() if args.json else result.report()) + return EXIT_OK + + +def _context(args: argparse.Namespace) -> int: + """Handle ``dualect context``.""" + print(build_context(result=_scan_source(args)), end="") + return EXIT_OK + + +def _translate(args: argparse.Namespace) -> int: + """Handle ``dualect translate``: translate, write, verify, report.""" + rules = load_rules(rules_dir=args.rules_dir) + try: + result = translate_file( + source=args.source, + output=args.output, + rules=rules, + dialect=parse_dialect(args.dialect), + strict=args.strict, + verify=not args.no_verify, + ) + except StrictModeError as exc: + print(f"dualect: {exc}", file=sys.stderr) + print("dualect: nothing was written", file=sys.stderr) + return EXIT_FAILED + print(result.report()) + print(f"wrote {args.output}") + if result.verified: + return EXIT_OK + if result.verify is not None: + return EXIT_FAILED + return EXIT_INCOMPLETE + + +def _verify(args: argparse.Namespace) -> int: + """Handle ``dualect verify``.""" + options = options_for_pair( + m_path=args.m_file, + py_path=args.py_file, + tolerance=Tolerance(rtol=args.rtol, atol=args.atol), + extra_index=args.index, + ) + if args.ignore: + options = dataclasses.replace(options, ignore=options.ignore | frozenset(args.ignore)) + result = verify_pair(m_path=args.m_file, py_path=args.py_file, options=options) + print(result.report()) + return EXIT_OK if result.ok else EXIT_FAILED + + +def _rules_list(args: argparse.Namespace) -> int: + """Handle ``dualect rules list``.""" + rules = load_rules(rules_dir=args.rules_dir) + if args.status: + wanted = Status(args.status) + rules = [rule for rule in rules if rule.status_for(args.direction) is wanted] + if not rules: + print("no rules found", file=sys.stderr) + return EXIT_OK + width = max(len(rule.id) for rule in rules) + print(f"{'rule':<{width}} {'to-python':<11} {'from-python':<11} cases title") + for rule in rules: + reverse = rule.python_status.value if rule.python_status is not None else "-" + print( + f"{rule.id:<{width}} {rule.status.value:<11} {reverse:<11} " + f"{len(rule.cases):>5} {rule.title}" + ) + return EXIT_OK + + +def _rules_check(args: argparse.Namespace) -> int: + """Handle ``dualect rules check``: does each rule earn its declared status?""" + rules = load_rules(rules_dir=args.rules_dir) + directions = DIRECTIONS if args.direction == "both" else (args.direction,) + results = check_rules( + rules=rules, + selected=args.rule_ids or None, + directions=directions, + verify=not args.no_verify, + ) + print(promotion_report(results, verified=not args.no_verify)) + return EXIT_FAILED if any(check.problem for check in results) else EXIT_OK + + +def _llms_txt(args: argparse.Namespace) -> int: + """Handle ``dualect llms-txt``: write (or print) the one-line-per-rule index.""" + text = render_llms_txt(rules=load_rules(rules_dir=args.rules_dir)) + if args.output is None: + print(text, end="") + else: + args.output.write_text(text, encoding="utf-8") + print(f"wrote {args.output}") + return EXIT_OK + + +def _mcp(args: argparse.Namespace) -> int: + """Handle ``dualect mcp``: serve the MCP tools on stdio.""" + from dualect.mcp_server import serve # deferred: the SDK is only needed here + + serve(rules_dir=args.rules_dir) + return EXIT_OK + + +def _rules_new(args: argparse.Namespace) -> int: + """Handle ``dualect rules new``.""" + rule_dir = new_rule(rules_dir=args.rules_dir, rule_id=args.rule_id) + print(f"created {rule_dir}") + print("next: fill in rule.yaml and cases/basic.m + basic.py, remove every TODO") + return EXIT_OK + + +def build_parser() -> argparse.ArgumentParser: + """Build the argument parser (exposed for tests and documentation).""" + parser = argparse.ArgumentParser( + prog="dualect", + description="Translate numeric code between .m files and Python/NumPy, verified.", + ) + parser.add_argument("--version", action="version", version=f"dualect {__version__}") + commands = parser.add_subparsers(dest="command", required=True, metavar="COMMAND") + + def add_source_options(sub: argparse.ArgumentParser) -> None: + sub.add_argument("source", type=Path, help="the .m file, or a .py file for .py -> .m") + sub.add_argument( + "--dialect", help="source dialect and version, e.g. octave or matlab@R2023a" + ) + sub.add_argument("--rules-dir", type=Path, default=None, help=argparse.SUPPRESS) + + scan = commands.add_parser("scan", help="list the rules a file needs, and what has none") + add_source_options(scan) + scan.add_argument("--json", action="store_true", help="machine-readable output") + scan.set_defaults(handler=_scan) + + context = commands.add_parser("context", help="print LLM-ready context for a file's rules") + add_source_options(context) + context.set_defaults(handler=_context) + + translate = commands.add_parser( + "translate", + help="translate a .m file to Python/NumPy (or a .py file to .m), then verify by execution", + ) + add_source_options(translate) + translate.add_argument( + "-o", "--output", type=Path, required=True, help="the file to write (.py, or .m)" + ) + translate.add_argument( + "--strict", + action="store_true", + help="stop, writing nothing, if any statement needs guided or unsupported translation", + ) + translate.add_argument( + "--no-verify", action="store_true", help="skip running both sides (output is UNVERIFIED)" + ) + translate.set_defaults(handler=_translate) + + verify = commands.add_parser("verify", help="run a .m and a .py script and compare outputs") + verify.add_argument("m_file", type=Path) + verify.add_argument("py_file", type=Path) + verify.add_argument("--rtol", type=float, default=DEFAULT_RTOL, help="relative tolerance") + verify.add_argument("--atol", type=float, default=DEFAULT_ATOL, help="absolute tolerance") + verify.add_argument( + "--index", + action="append", + default=[], + metavar="NAME", + help="variable holding indices (1-based in .m, 0-based in Python); repeatable", + ) + verify.add_argument( + "--ignore", action="append", default=[], metavar="NAME", help="skip a variable; repeatable" + ) + verify.set_defaults(handler=_verify) + + rules = commands.add_parser("rules", help="inspect or create rules") + rules.add_argument( + "--rules-dir", + type=Path, + default=None, + help="rules folder (default: the repository's rules/ or $DUALECT_RULES_DIR)", + ) + rule_commands = rules.add_subparsers(dest="rules_command", required=True, metavar="ACTION") + listing = rule_commands.add_parser("list", help="list rules with status and case count") + listing.add_argument("--status", choices=[status.value for status in Status]) + listing.add_argument( + "--direction", + choices=list(DIRECTIONS), + default=TO_PYTHON, + help="which direction --status filters on (default: to-python)", + ) + listing.set_defaults(handler=_rules_list) + check = rule_commands.add_parser( + "check", + help="run each rule's translator on its cases in each direction; " + "fail when a status is not earned (promotion loop)", + ) + check.add_argument("rule_ids", nargs="*", metavar="CATEGORY/ID", help="default: every rule") + check.add_argument("--direction", choices=["both", *DIRECTIONS], default="both") + check.add_argument( + "--no-verify", action="store_true", help="skip execution (layer-2 and completeness only)" + ) + check.set_defaults(handler=_rules_check) + create = rule_commands.add_parser("new", help="scaffold rules///") + create.add_argument("rule_id", metavar="CATEGORY/ID") + create.set_defaults(handler=_rules_new) + + llms = commands.add_parser("llms-txt", help="generate llms.txt: every rule in one line") + llms.add_argument( + "-o", "--output", type=Path, default=None, help="file to write (default: print)" + ) + llms.add_argument("--rules-dir", type=Path, default=None, help=argparse.SUPPRESS) + llms.set_defaults(handler=_llms_txt) + + mcp = commands.add_parser( + "mcp", help="serve scan/get_rule/translate/verify as MCP tools (stdio)" + ) + mcp.add_argument("--rules-dir", type=Path, default=None, help=argparse.SUPPRESS) + mcp.set_defaults(handler=_mcp) + + return parser + + +def main(argv: Sequence[str] | None = None) -> int: + """Run the command line; returns the process exit code. + + :param argv: arguments without the program name (default: ``sys.argv[1:]``). + """ + args = build_parser().parse_args(argv) + if hasattr(args, "rules_dir") and args.rules_dir is None: + args.rules_dir = default_rules_dir() + try: + return int(args.handler(args)) + except DualectError as exc: + print(f"dualect: {exc}", file=sys.stderr) + return EXIT_FAILED + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/dualect/compare.py b/dualect/compare.py new file mode 100644 index 0000000..85e2801 --- /dev/null +++ b/dualect/compare.py @@ -0,0 +1,159 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Deciding whether a ``.m`` value and a Python value are the same result. + +The comparison is deliberately about *values*, not representation: + +- Numbers are compared with :func:`numpy.allclose` (NaN equals NaN). +- Singleton dimensions are ignored: Octave has no 1-D arrays, so its ``1xN`` row + vector and an idiomatic NumPy 1-D array of length N are the same result. + Non-singleton shapes must match exactly (a 2x3 is not a 3x2). +- Two empty arrays are equal whatever their shapes (``[]`` is 0x0 in Octave, + ``np.array([])`` is shape ``(0,)``). +- Logical vs numeric *is* a difference: indexing with a logical mask and with + the numbers 0/1 do different things, so a translation that loses the type is + wrong even when the digits agree. +- Integer vs float is not: Octave computes in double by default where NumPy + idiom often yields integers. +""" + +from dataclasses import dataclass +from typing import Any + +import numpy as np + +from dualect.runners import CallableValue + +#: Default relative tolerance. Both sides use IEEE doubles and often the same +#: BLAS/LAPACK, so honest translations agree to near machine precision; the +#: margin covers different summation orders. +DEFAULT_RTOL = 1e-9 +#: Default absolute tolerance, for values that should be exactly zero. +DEFAULT_ATOL = 1e-12 + +_NUMERIC_KINDS = frozenset("biufc") + + +@dataclass(frozen=True) +class Tolerance: + """Tolerances passed to :func:`numpy.allclose`. + + :param rtol: relative tolerance [-]. + :param atol: absolute tolerance, in the units of the compared values. + """ + + rtol: float = DEFAULT_RTOL + atol: float = DEFAULT_ATOL + + +def _is_cell(value: Any) -> bool: + """Whether a pulled value is an Octave cell array (an object ndarray).""" + return isinstance(value, np.ndarray) and value.dtype == object + + +def _squeezed_shape(array: np.ndarray) -> tuple[int, ...]: + """Shape with every length-1 dimension removed.""" + return tuple(dim for dim in array.shape if dim != 1) + + +def compare_values( + *, m_value: Any, py_value: Any, tolerance: Tolerance, index: bool = False +) -> str | None: + """Compare one ``.m`` result with one Python result. + + :param m_value: value pulled from Octave. + :param py_value: value from the Python namespace. + :param tolerance: allclose tolerances. + :param index: the value holds 1-based indices on the ``.m`` side and 0-based + indices on the Python side, so ``m_value - 1`` is compared. + :returns: ``None`` if equal, otherwise a short reason. + """ + if isinstance(m_value, CallableValue) or isinstance(py_value, CallableValue): + if isinstance(m_value, CallableValue) and isinstance(py_value, CallableValue): + return None + return "callable on one side only" + + if isinstance(m_value, str) or isinstance(py_value, str): + if isinstance(m_value, str) and isinstance(py_value, str): + return None if m_value == py_value else f"strings differ: {m_value!r} vs {py_value!r}" + return f"type differs: {type(m_value).__name__} vs {type(py_value).__name__}" + + if isinstance(m_value, dict) or isinstance(py_value, dict): + return _compare_mappings(m_value=m_value, py_value=py_value, tolerance=tolerance) + + if _is_cell(m_value): + return _compare_sequences(m_value=m_value, py_value=py_value, tolerance=tolerance) + + return _compare_arrays(m_value=m_value, py_value=py_value, tolerance=tolerance, index=index) + + +def _compare_mappings(*, m_value: Any, py_value: Any, tolerance: Tolerance) -> str | None: + """Compare a struct with a dict field by field.""" + if not (isinstance(m_value, dict) and isinstance(py_value, dict)): + return f"type differs: {type(m_value).__name__} vs {type(py_value).__name__}" + if set(m_value) != set(py_value): + return f"fields differ: {sorted(m_value)} vs {sorted(py_value)}" + for key in sorted(m_value): + reason = compare_values(m_value=m_value[key], py_value=py_value[key], tolerance=tolerance) + if reason is not None: + return f"field {key!r}: {reason}" + return None + + +def _compare_sequences(*, m_value: np.ndarray, py_value: Any, tolerance: Tolerance) -> str | None: + """Compare a cell array with a list/tuple element by element. + + Elements are taken in column-major order, the order Octave stores them. + """ + if not isinstance(py_value, list | tuple | np.ndarray): + return f"cell array vs {type(py_value).__name__}" + m_items = list(m_value.ravel(order="F")) + if isinstance(py_value, list | tuple): + py_items = list(py_value) + else: + py_items = list(np.asarray(py_value, dtype=object).ravel()) + if len(m_items) != len(py_items): + return f"length differs: {len(m_items)} vs {len(py_items)}" + for position, (m_item, py_item) in enumerate(zip(m_items, py_items, strict=True)): + reason = compare_values(m_value=m_item, py_value=py_item, tolerance=tolerance) + if reason is not None: + return f"element {position}: {reason}" + return None + + +def _compare_arrays( + *, m_value: Any, py_value: Any, tolerance: Tolerance, index: bool +) -> str | None: + """Compare numeric/logical scalars and arrays.""" + m_array = np.asarray(m_value) + py_array = np.asarray(py_value) + if m_array.dtype.kind not in _NUMERIC_KINDS or py_array.dtype.kind not in _NUMERIC_KINDS: + return f"cannot compare {m_array.dtype} with {py_array.dtype}" + + if index: + if m_array.dtype.kind == "b" or py_array.dtype.kind == "b": + return "declared as indices but holds logical values" + m_array = m_array - 1 + elif (m_array.dtype.kind == "b") != (py_array.dtype.kind == "b"): + return f"logical vs numeric: {m_array.dtype} vs {py_array.dtype}" + + if m_array.size == 0 and py_array.size == 0: + return None + if _squeezed_shape(m_array) != _squeezed_shape(py_array): + return f"shape differs: {m_array.shape} vs {py_array.shape}" + + m_float = m_array.astype(complex if m_array.dtype.kind == "c" else float).reshape( + _squeezed_shape(m_array) + ) + py_float = py_array.astype(complex if py_array.dtype.kind == "c" else float).reshape( + _squeezed_shape(py_array) + ) + if np.allclose(m_float, py_float, rtol=tolerance.rtol, atol=tolerance.atol, equal_nan=True): + return None + with np.errstate(invalid="ignore"): + difference = np.abs(m_float - py_float) + finite = difference[np.isfinite(difference)] + if finite.size and float(finite.max()) > 0: + return f"values differ (max abs difference {float(finite.max()):.3g})" + return "values differ (NaN or Inf in different positions)" diff --git a/dualect/constructs.py b/dualect/constructs.py new file mode 100644 index 0000000..2e7eacf --- /dev/null +++ b/dualect/constructs.py @@ -0,0 +1,351 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Construct tags: the names the scanner gives to what a file uses. + +Every statement is tagged with the constructs it uses (``op:mtimes``, +``index:end``, ``call:linspace``, ...). Each rule declares in its +``rule.yaml`` ``match`` list which tags it covers, so adding a rule for a new +built-in is a new folder with ``match: [call:foo]`` and no engine change. A tag +that no rule matches is reported as unsupported *by its tag*, which is the +"named unsupported error" of the design. + +Core constructs that mean the same in both languages (numbers, variables, +plain assignment, expression statements) carry no tag and need no rule. +""" + +from dataclasses import dataclass + +from dualect import ir +from dualect.infer import Analysis, Kind, index_may_grow + +#: Every tag the scanner can emit (besides ``call:``), with a description. +#: ``dualect.validate`` rejects rule ``match`` entries outside this vocabulary. +VOCABULARY: dict[str, str] = { + "syntax:comment": "a % or # comment", + "syntax:hash-comment": "a # comment (Octave only)", + "syntax:block-comment": "a %{ ... %} block comment", + "syntax:continuation": "a ... line continuation", + "syntax:command": "command syntax: name word1 word2", + "syntax:display": "a statement without ; that prints its result", + "syntax:script-marker": "a leading `1;` that marks a script defining functions", + "literal:matrix": "a bracket literal [1 2; 3 4]", + "literal:empty": "the empty matrix []", + "literal:string": "a single-quoted char array 'abc'", + "literal:dq-string": 'a double-quoted string "abc"', + "literal:cell": "a cell array literal {a, b}", + "expr:concat": "bracket concatenation of arrays [a, b] / [a; b]", + "expr:string-concat": "bracket concatenation of strings ['ab', s]", + "expr:range": "a colon range a:b or a:step:b", + "expr:field": "struct field access s.f", + "expr:cell-index": "cell indexing c{k}", + "index:paren": "indexing with parentheses x(i), A(i, j)", + "index:colon": "a : subscript selecting a whole dimension, A(:, j)", + "index:colon-all": "A(:), all elements as one column", + "index:end": "end inside a subscript", + "index:logical": "indexing with a logical mask", + "index:delete": "deleting elements: x(idx) = []", + "assign:grow": "assignment past the end of an array, which grows it", + "assign:multi": "multiple outputs: [a, b] = f(x)", + "assign:ignore-output": "a discarded output: [~, i] = f(x)", + "op:augassign": "x += e, x++ and friends (Octave only)", + "stmt:if": "if / elseif / else", + "stmt:for": "a for loop", + "stmt:while": "a while loop", + "stmt:do-until": "do ... until (Octave only)", + "stmt:switch": "switch / case / otherwise", + "stmt:break": "break", + "stmt:continue": "continue", + "stmt:return": "return", + "stmt:try": "try / catch", + "stmt:global": "global variables", + "stmt:persistent": "persistent variables", + "stmt:classdef": "a classdef block", + "stmt:parfor": "a parfor loop", + "stmt:spmd": "an spmd block", + "func:definition": "a function definition", + "func:multi-output": "a function with several outputs", + "func:varargin": "variable inputs (varargin)", + "func:varargout": "variable outputs (varargout)", + "func:arguments-block": "an arguments validation block", + "func:nargin": "nargin", + "func:nargout": "nargout", + "func:handle": "an anonymous function @(x) ...", + "func:named-handle": "a handle to a named function @sin", + "func:handle-expression": "a handle to an expression", + "func:call-local": "a call to a function defined in the same file", + "func:call-handle": "a call through a function handle variable", + "parse:error": "text the parser could not read", + "literal:number-format": "a numeric literal in an unsupported format", + "expr:end-outside-index": "end used outside a subscript", + "expr:call-expression": "calling the result of an expression", +} +for _op in sorted(ir.BINARY_OPS | {"uminus", "uplus", "not", "ctranspose", "transpose"}): + VOCABULARY[f"op:{_op}"] = f"the {_op} operator" + +#: Names tagged as something other than ``call:``. +_SPECIAL_CALLS = {"nargin": "func:nargin", "nargout": "func:nargout"} + + +def is_known_tag(tag: str) -> bool: + """Whether a tag is in the vocabulary (``call:`` is always known).""" + return tag in VOCABULARY or (tag.startswith("call:") and len(tag) > len("call:")) + + +@dataclass(frozen=True) +class Use: + """One use of a construct. + + :param tag: the construct tag. + :param loc: where it is. + """ + + tag: str + loc: ir.Loc + + +def statement_uses(stmt: ir.Stmt, analysis: Analysis) -> list[Use]: + """Tag a statement's own constructs (not those of nested statements). + + :param stmt: the statement. + :param analysis: inference results, used where the construct depends on + facts (a logical mask, an assignment that grows an array). + """ + uses = [Use(tag, stmt.loc) for tag in stmt.syntax] + add = uses.append + match stmt: + case ir.Assign(targets=targets, value=value): + # Several outputs of a built-in (`[m, i] = max(v)`) are that + # built-in's business; of a user function, the multiple-returns rule's. + builtin = isinstance(value, ir.Call) and not (value.local or value.handle) + if len(targets) > 1 and not builtin: + add(Use("assign:multi", stmt.loc)) + if any(isinstance(t, ir.Ignore) for t in targets) and not builtin: + add(Use("assign:ignore-output", stmt.loc)) + deleting = isinstance(value, ir.Matrix) and not value.rows + for target in targets: + if isinstance(target, ir.Index): + uses.extend(_index_target_uses(stmt, target, analysis, deleting=deleting)) + elif not isinstance(target, ir.Name | ir.Ignore): + uses.extend(expression_uses(target, analysis)) + if deleting and isinstance(targets[0], ir.Index): + add(Use("index:delete", stmt.loc)) + else: + uses.extend(expression_uses(value, analysis)) + case ir.AugAssign(target=target, value=value): + add(Use("op:augassign", stmt.loc)) + uses.extend(expression_uses(target, analysis)) + uses.extend(expression_uses(value, analysis)) + case ir.ExprStmt(value=value): + uses.extend(expression_uses(value, analysis)) + case ir.If(branches=branches): + add(Use("stmt:if", stmt.loc)) + for cond, _body in branches: + uses.extend(expression_uses(cond, analysis)) + case ir.For(iterable=iterable): + add(Use("stmt:for", stmt.loc)) + uses.extend(expression_uses(iterable, analysis)) + case ir.While(cond=cond): + add(Use("stmt:while", stmt.loc)) + uses.extend(expression_uses(cond, analysis)) + case ir.DoUntil(cond=cond): + add(Use("stmt:do-until", stmt.loc)) + uses.extend(expression_uses(cond, analysis)) + case ir.Switch(subject=subject, cases=cases): + add(Use("stmt:switch", stmt.loc)) + uses.extend(expression_uses(subject, analysis)) + for values, _body in cases: + for value in values: + uses.extend(expression_uses(value, analysis)) + case ir.Break(): + add(Use("stmt:break", stmt.loc)) + case ir.Continue(): + add(Use("stmt:continue", stmt.loc)) + case ir.Return(): + add(Use("stmt:return", stmt.loc)) + case ir.Command(): + add(Use("syntax:command", stmt.loc)) + case ir.FunctionDef(params=params, outputs=outputs): + add(Use("func:definition", stmt.loc)) + if len(outputs) > 1: + add(Use("func:multi-output", stmt.loc)) + if "varargin" in params: + add(Use("func:varargin", stmt.loc)) + if "varargout" in outputs: + add(Use("func:varargout", stmt.loc)) + case ir.OpaqueStmt(construct=construct): + add(Use(construct, stmt.loc)) + return _dedupe(uses) + + +def _index_target_uses( + stmt: ir.Assign, target: ir.Index, analysis: Analysis, *, deleting: bool +) -> list[Use]: + uses = [Use("index:paren", target.loc)] + for arg in target.args: + uses.extend(_subscript_uses(arg, target, analysis)) + if deleting: + return uses + name = target.target.id if isinstance(target.target, ir.Name) else None + before = analysis.env_before.get(id(stmt), {}).get(name) if name else None + if ( + before is None + or before.maybe_undefined + or before.kind is Kind.EMPTY + or index_may_grow(target, before, analysis) + ): + uses.append(Use("assign:grow", target.loc)) + return uses + + +def _subscript_uses(arg: ir.Expr, index: ir.Index, analysis: Analysis) -> list[Use]: + uses: list[Use] = [] + if isinstance(arg, ir.Colon): + uses.append(Use("index:colon-all" if len(index.args) == 1 else "index:colon", arg.loc)) + return uses + info = analysis.info(arg) + if info.is_logical and not info.is_scalar: + uses.append(Use("index:logical", arg.loc)) + uses.extend(expression_uses(arg, analysis)) + return uses + + +def expression_uses(node: ir.Expr, analysis: Analysis) -> list[Use]: + """Tag the constructs inside one expression tree. + + :param node: the expression. + :param analysis: inference results. + """ + uses: list[Use] = [] + add = uses.append + match node: + case ir.Str(quote=quote): + add(Use("literal:dq-string" if quote == '"' else "literal:string", node.loc)) + case ir.Matrix(rows=rows): + if not rows: + add(Use("literal:empty", node.loc)) + else: + infos = [analysis.info(item) for row in rows for item in row] + if all(info.kind is Kind.STRING for info in infos): + add(Use("expr:string-concat", node.loc)) + else: + add(Use("literal:matrix", node.loc)) + if any(not info.is_scalar for info in infos): + add(Use("expr:concat", node.loc)) + case ir.CellLit(): + add(Use("literal:cell", node.loc)) + case ir.Range(): + add(Use("expr:range", node.loc)) + case ir.BinOp(op=op): + add(Use(f"op:{op}", node.loc)) + case ir.UnOp(op=op): + add(Use(f"op:{op}", node.loc)) + case ir.Transpose(conjugate=conjugate): + add(Use("op:ctranspose" if conjugate else "op:transpose", node.loc)) + case ir.Index(args=args): + add(Use("index:paren", node.loc)) + for arg in args: + uses.extend(_subscript_uses(arg, node, analysis)) + return _dedupe(uses) + case ir.End(): + add(Use("index:end", node.loc)) + case ir.Call(func=func, local=local, handle=handle): + if local: + add(Use("func:call-local", node.loc)) + elif handle: + add(Use("func:call-handle", node.loc)) + else: + add(Use(_SPECIAL_CALLS.get(func, f"call:{func}"), node.loc)) + case ir.Lambda(): + add(Use("func:handle", node.loc)) + case ir.FuncRef(): + add(Use("func:named-handle", node.loc)) + case ir.Opaque(construct=construct): + add(Use(construct, node.loc)) + for child in ir.child_exprs(node): + uses.extend(expression_uses(child, analysis)) + return _dedupe(uses) + + +def primary_tag(node: ir.Expr | ir.Stmt, analysis: Analysis) -> str | None: + """The tag whose rule translates ``node`` itself (``None`` for core nodes). + + Numbers, variables and plain assignment are core: they mean the same in + both languages and need no rule. + + :param node: an expression or statement. + :param analysis: inference results (a bracket literal of arrays is a + concatenation, of strings a string concatenation). + """ + match node: + case ir.Str(quote=quote): + return "literal:dq-string" if quote == '"' else "literal:string" + case ir.Matrix(rows=rows): + if not rows: + return "literal:empty" + infos = [analysis.info(item) for row in rows for item in row] + if all(info.kind is Kind.STRING for info in infos): + return "expr:string-concat" + if any(not info.is_scalar for info in infos): + return "expr:concat" + return "literal:matrix" + case ir.CellLit(): + return "literal:cell" + case ir.Range(): + return "expr:range" + case ir.BinOp(op=op) | ir.UnOp(op=op): + return f"op:{op}" + case ir.Transpose(conjugate=conjugate): + return "op:ctranspose" if conjugate else "op:transpose" + case ir.Index(): + return "index:paren" + case ir.End(): + return "index:end" + case ir.Call(func=func, local=local, handle=handle): + if local: + return "func:call-local" + if handle: + return "func:call-handle" + return _SPECIAL_CALLS.get(func, f"call:{func}") + case ir.Lambda(): + return "func:handle" + case ir.FuncRef(): + return "func:named-handle" + case ir.Opaque(construct=construct) | ir.OpaqueStmt(construct=construct): + return construct + case ir.AugAssign(): + return "op:augassign" + case ir.If(): + return "stmt:if" + case ir.For(): + return "stmt:for" + case ir.While(): + return "stmt:while" + case ir.DoUntil(): + return "stmt:do-until" + case ir.Switch(): + return "stmt:switch" + case ir.Break(): + return "stmt:break" + case ir.Continue(): + return "stmt:continue" + case ir.Return(): + return "stmt:return" + case ir.Command(): + return "syntax:command" + case ir.FunctionDef(): + return "func:definition" + case ir.Comment(block=block): + return "syntax:block-comment" if block else "syntax:comment" + return None + + +def _dedupe(uses: list[Use]) -> list[Use]: + seen: set[tuple[str, ir.Loc]] = set() + unique = [] + for use in uses: + key = (use.tag, use.loc) + if key not in seen: + seen.add(key) + unique.append(use) + return unique diff --git a/dualect/context.py b/dualect/context.py new file mode 100644 index 0000000..41905db --- /dev/null +++ b/dualect/context.py @@ -0,0 +1,81 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""``dualect context``: the rules a file needs, as LLM-ready prompt context. + +The repository is the LLM's memory (docs/design.md section 6): instead of +re-deriving the translation rules, a model is handed exactly the rules one file +needs, each as its ``rule.yaml`` plus one or two paired cases. dualect never +calls a model itself; whatever model the user runs reads this text, and its +translation comes back through ``dualect verify``. +""" + +from dualect.rulebook import TO_PYTHON, CasePair, Rule, Status +from dualect.scan import ScanResult + +#: Cases shown per rule: enough to show the pattern, small enough to stay focused. +MAX_CASES = 2 + + +def pick_cases(rule: Rule, *, limit: int = MAX_CASES) -> list[CasePair]: + """Choose the cases to show for a rule: ``basic`` first, then by name. + + :param rule: the rule. + :param limit: how many at most. + """ + ordered = sorted(rule.cases, key=lambda case: (case.name != "basic", case.name)) + return ordered[:limit] + + +def render_rule(rule: Rule, *, limit: int = MAX_CASES, direction: str = TO_PYTHON) -> str: + """One rule as a Markdown section: its ``rule.yaml`` and its chosen cases. + + :param rule: the rule. + :param limit: how many cases to include. + :param direction: which status to show in the heading. + """ + status = rule.status_for(direction) or Status.UNSUPPORTED + parts = [ + f"## {rule.id} ({status.value} {direction})", + "", + "```yaml", + (rule.path / "rule.yaml").read_text(encoding="utf-8").rstrip(), + "```", + ] + for case in pick_cases(rule, limit=limit): + parts += [ + "", + f"Case `{case.name}`, .m and its verified Python twin:", + "", + "```octave", + case.m_path.read_text(encoding="utf-8").rstrip(), + "```", + "", + "```python", + case.py_path.read_text(encoding="utf-8").rstrip(), + "```", + ] + return "\n".join(parts) + + +def build_context(*, result: ScanResult, limit: int = MAX_CASES) -> str: + """The prompt context for one scanned file. + + A two-line header names the file, the rules and the constructs that have no + rule; then each needed rule follows. Nothing else is included. + + :param result: the scan of the file. + :param limit: cases per rule. + """ + rules = result.needed_rules() + header = [ + f"# dualect rules for {result.source_name}", + "", + f"Rules this file needs: {', '.join(rule.id for rule in rules) or 'none'}.", + ] + gaps = result.unsupported() + if gaps: + named = ", ".join(f"{gap.tag} at {gap.loc}" for gap in gaps) + header.append(f"Constructs with no rule (translate with care and say so): {named}.") + sections = [render_rule(rule, limit=limit, direction=result.direction) for rule in rules] + return "\n\n".join(["\n".join(header), *sections]) + "\n" diff --git a/dualect/dialect.py b/dualect/dialect.py new file mode 100644 index 0000000..f341010 --- /dev/null +++ b/dualect/dialect.py @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Source dialects and versions (docs/design.md section 4.4). + +A dialect spec is ``octave`` or ``matlab``, optionally with a version: +``octave@8.4``, ``matlab@R2023a``. Rules are filtered by their ``dialects`` +list and their ``since`` (inclusive) / ``until`` (exclusive) bounds, so a +behavior change can live in a new variant rule without editing the old one. +""" + +import re +from dataclasses import dataclass +from typing import Any + +from dualect.errors import DualectError + +DIALECTS = ("octave", "matlab") +DEFAULT_DIALECT = "octave" + +_OCTAVE_VERSION = re.compile(r"^[0-9]+(\.[0-9]+)*$") +_MATLAB_VERSION = re.compile(r"^R([0-9]{4})([ab])$") + + +class DialectError(DualectError): + """A ``--dialect`` value could not be understood.""" + + +@dataclass(frozen=True) +class Dialect: + """A source dialect, optionally pinned to a version. + + :param name: ``"octave"`` or ``"matlab"``. + :param version: ``"8.4"`` / ``"R2023a"``, or ``None`` for "any version". + """ + + name: str = DEFAULT_DIALECT + version: str | None = None + + def __str__(self) -> str: + """Render as ``name`` or ``name@version``.""" + return self.name if self.version is None else f"{self.name}@{self.version}" + + def allows(self, data: dict[str, Any]) -> bool: + """Whether a rule (its parsed ``rule.yaml``) applies to this dialect/version. + + :param data: the rule's mapping. + """ + if self.name not in (data.get("dialects") or []): + return False + if self.version is None: + return True + key = _version_key(self.name, self.version) + since = (data.get("since") or {}).get(self.name) + until = (data.get("until") or {}).get(self.name) + if since is not None and key < _version_key(self.name, str(since)): + return False + return not (until is not None and key >= _version_key(self.name, str(until))) + + +def _version_key(name: str, version: str) -> tuple[int, ...]: + if name == "matlab": + match = _MATLAB_VERSION.match(version) + if match is None: + raise DialectError(f"bad matlab version {version!r}; expected e.g. R2023a") + return (int(match.group(1)), 0 if match.group(2) == "a" else 1) + if not _OCTAVE_VERSION.match(version): + raise DialectError(f"bad octave version {version!r}; expected e.g. 8.4") + return tuple(int(part) for part in version.split(".")) + + +def parse_dialect(spec: str | None) -> Dialect: + """Parse a ``--dialect`` value such as ``matlab@R2023a``. + + :param spec: the value, or ``None`` for the default (``octave``, any version). + :raises DialectError: for an unknown dialect or a malformed version. + """ + if not spec: + return Dialect() + name, _, version = spec.partition("@") + name = name.strip().lower() + if name not in DIALECTS: + raise DialectError(f"unknown dialect {name!r}; expected one of {', '.join(DIALECTS)}") + if version: + _version_key(name, version) + return Dialect(name=name, version=version) + return Dialect(name=name) diff --git a/dualect/emit.py b/dualect/emit.py new file mode 100644 index 0000000..0f51308 --- /dev/null +++ b/dualect/emit.py @@ -0,0 +1,822 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Emitting Python/NumPy from the IR (docs/design.md section 5, steps 3-5). + +The emitter walks the IR statement by statement. For each statement it first +*plans*: every construct tag the statement uses must map to a ``mechanical`` +rule. If one does not, the statement becomes a **hole**: a ``TODO(dualect)`` +comment carrying the original source and a ``raise NotImplementedError``, so +the output can never run past a part that was not translated. Otherwise the +statement is translated, with each construct handed to its rule's +``translate.py`` (loaded by :mod:`dualect.translators`). A translator that +meets a form it cannot translate correctly raises :class:`Decline`, which also +turns the statement into a hole, reported as ``guided``. + +What lives here, rather than in a rule, is what every rule shares: the +dispatch, Python's statement layout, copy-on-write semantics (a NumPy +assignment ``y = x`` aliases, an ``.m`` assignment copies), and the analysis of +which variables only ever hold positions and can therefore be stored 0-based. + +Python code is built as :mod:`ast` nodes and printed with :func:`ast.unparse`, +which inserts the parentheses precedence needs; :mod:`dualect.pyformat` then +formats the file with ruff. +""" + +from __future__ import annotations + +import ast +import re +from collections.abc import Callable, Iterator +from contextlib import contextmanager +from dataclasses import dataclass, field +from types import ModuleType +from typing import NoReturn + +from dualect import ir +from dualect.constructs import primary_tag +from dualect.infer import Analysis, Info, Kind +from dualect.rulebook import Rule, Status +from dualect.scan import Finding, ScanResult + +#: Indentation unit of the emitted code (ruff reformats anyway). +INDENT = " " + +#: A float literal that Python spells the same way. +_PY_FLOAT = re.compile(r"(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?") + + +class Decline(Exception): + """A translator cannot translate this form correctly; the statement is guided. + + :param reason: what is missing, for the report. + """ + + def __init__(self, reason: str) -> None: + self.reason = reason + super().__init__(reason) + + +class _Unsupported(Exception): + """A construct with no mechanical rule was reached during emission.""" + + def __init__(self, tag: str, rule: Rule | None) -> None: + self.tag = tag + self.rule = rule + super().__init__(tag) + + +@dataclass(frozen=True) +class Line: + """One emitted line of Python. + + :param indent: nesting depth. + :param text: the code or comment, without indentation. + """ + + indent: int + text: str + + def render(self) -> str: + """The line with its indentation.""" + return f"{INDENT * self.indent}{self.text}" if self.text else "" + + +@dataclass +class StmtReport: + """How one statement was handled. + + :param loc: where the statement is. + :param kind: the statement kind (``Assign``, ``For``, ...). + :param rules: ids of the rules its constructs needed. + :param status: ``mechanical`` (translated by rules), ``guided`` (left for an + LLM: a guided rule, or a translator declined) or ``unsupported`` (a + construct with no rule, or an ``unsupported`` rule). + :param reason: why it was not mechanical. + """ + + loc: ir.Loc + kind: str + rules: list[str] + status: Status + reason: str = "" + + +@dataclass +class ScopeFacts: + """Per-function (or script) facts the emitter needs. + + :param index_vars: variables stored 0-based because they only hold positions. + :param mutated: variables modified in place (indexed assignment). + :param variables: every variable of the scope. + :param outputs: the function's output names (empty for the script). + :param is_script: ``True`` for the script's top level, whose variables are + the compared outputs. + """ + + index_vars: set[str] = field(default_factory=set) + mutated: set[str] = field(default_factory=set) + variables: set[str] = field(default_factory=set) + outputs: list[str] = field(default_factory=list) + is_script: bool = False + + +class Context: + """What a rule translator works with while translating one statement. + + Translators call back into the context to translate sub-expressions + (:meth:`expr`), read inferred facts (:meth:`info`), refer to NumPy + (:meth:`np`), record assumptions (:meth:`assume`) and decline + (:meth:`decline`). + """ + + def __init__( + self, + *, + scan: ScanResult, + translator_for: Callable[[str], ModuleType | None], + rule_for: Callable[[str], Rule | None], + rule_by_id: Callable[[str], Rule | None], + ) -> None: + self.scan = scan + self.analysis: Analysis = scan.analysis + self._translator_for = translator_for + self._rule_for = rule_for + self._rule_by_id = rule_by_id + self.imports: set[str] = set() + self.assumptions: list[str] = [] + self.scope = ScopeFacts() + self.functions: dict[str, ir.FunctionDef] = { + s.name: s for s in scan.program.body if isinstance(s, ir.FunctionDef) + } + self.loop_stack: list[ir.Stmt] = [] + self.indent = 0 + self.reports: list[StmtReport] = [] + self.directives: set[str] = set() + self.source_lines = scan.program_text.splitlines() if scan.program_text else [] + + # --- facts ------------------------------------------------------------- + + def info(self, node: ir.Expr) -> Info: + """Inferred facts about an expression.""" + return self.analysis.info(node) + + def index_directive(self, name: str) -> list[Line]: + """A ``# dualect: index`` line the first time a script variable is stored 0-based. + + Script variables are the outputs verification compares; the directive + tells it to compare this one as a 0-based position. + """ + if not self.scope.is_script or name in self.directives: + return [] + self.directives.add(name) + return [self.line(f"# dualect: index {name}")] + + def is_index_var(self, name: str) -> bool: + """Whether ``name`` is stored 0-based in the output (see :func:`index_variables`).""" + return name in self.scope.index_vars + + # --- building Python ----------------------------------------------------- + + def np(self, attr: str) -> ast.expr: + """``np.``, recording the import.""" + self.imports.add("import numpy as np") + node: ast.expr = ast.Name(id="np") + for part in attr.split("."): + node = ast.Attribute(value=node, attr=part) + return node + + @staticmethod + def call(func: ast.expr, *args: ast.expr, **keywords: ast.expr) -> ast.expr: + """A call node.""" + return ast.Call( + func=func, + args=list(args), + keywords=[ast.keyword(arg=key, value=value) for key, value in keywords.items()], + ) + + @staticmethod + def method(obj: ast.expr, name: str, *args: ast.expr, **keywords: ast.expr) -> ast.expr: + """``obj.name(args)``.""" + return Context.call(ast.Attribute(value=obj, attr=name), *args, **keywords) + + @staticmethod + def const(value: int | float | complex | str | bool | None) -> ast.expr: + """A literal; negative numbers become a unary minus, as Python parses them.""" + if isinstance(value, int | float) and not isinstance(value, bool) and value < 0: + return ast.UnaryOp(op=ast.USub(), operand=ast.Constant(value=-value)) + return ast.Constant(value=value) + + def assume(self, text: str) -> None: + """Record an assumption (docs/design.md section 5.2) for the current statement.""" + if text not in self.assumptions: + self.assumptions.append(text) + + @staticmethod + def decline(reason: str) -> NoReturn: + """Give up on this statement; it becomes a guided hole.""" + raise Decline(reason) + + def has_mechanical(self, rule_id: str) -> bool: + """Whether a rule applies to this dialect, is ``mechanical`` and has a translator.""" + rule = self._rule_by_id(rule_id) + return ( + rule is not None + and rule.status is Status.MECHANICAL + and self._translator_for(rule_id) is not None + ) + + def module(self, rule_id: str) -> ModuleType: + """Another rule's translator, for its helpers; only a ``mechanical`` rule's. + + :raises _Unsupported: when that rule is not mechanical, so the statement + becomes a hole reported against that rule. + """ + rule = self._rule_by_id(rule_id) + module = self._translator_for(rule_id) + if rule is None or rule.status is not Status.MECHANICAL or module is None: + raise _Unsupported(rule.match[0] if rule is not None and rule.match else rule_id, rule) + return module + + def position_outputs(self, call: ir.Call, nargout: int) -> set[int]: + """Outputs of a built-in call that hold 1-based positions (from its rule).""" + rule = self._rule_for(f"call:{call.func}") + if rule is None or rule.status is not Status.MECHANICAL: + return set() + module = self._translator_for(rule.id) + hook = getattr(module, "position_outputs", None) + return set(hook(call, nargout)) if hook is not None else set() + + def enter_script(self) -> None: + """Compute the script-level scope facts.""" + body = [s for s in self.scan.program.body if not isinstance(s, ir.FunctionDef)] + self.scope = scope_facts( + body=body, + params=[], + outputs=[], + position_outputs=self.position_outputs, + analysis=self.analysis, + ) + self.scope.is_script = True + + @contextmanager + def function_scope(self, fdef: ir.FunctionDef) -> Iterator[ScopeFacts]: + """Translate inside a function: its own variables, copies and index variables.""" + saved = self.scope + self.scope = scope_facts( + body=fdef.body, + params=fdef.params, + outputs=fdef.outputs, + position_outputs=self.position_outputs, + analysis=self.analysis, + ) + try: + yield self.scope + finally: + self.scope = saved + + # --- dispatch ------------------------------------------------------------ + + def expr(self, node: ir.Expr) -> ast.expr: + """Translate an expression (in value context).""" + match node: + case ir.Num(value=value, text=text): + if isinstance(value, float) and _PY_FLOAT.fullmatch(text): + # Keep the source spelling (200e9, not 200000000000.0); the + # printer writes a Name's id verbatim. + return ast.Name(id=text) + return self.const(value) + case ir.Name(id=name): + if self.is_index_var(name): + # Stored 0-based; its source value is one more. + return ast.BinOp(left=ast.Name(id=name), op=ast.Add(), right=ast.Constant(1)) + return ast.Name(id=name) + case ir.Colon(): + return ast.Slice() + tag = primary_tag(node, self.analysis) + if tag is None: + raise Decline(f"no translation for {type(node).__name__}") + translator = self._mechanical(tag) + result = translator.translate(node, self) + if not isinstance(result, ast.expr): + raise Decline(f"{tag} did not give an expression") + return result + + def arg(self, node: ir.Expr) -> ast.expr: + """An argument to a NumPy function: a vector literal stays a plain list.""" + if ( + isinstance(node, ir.Matrix) + and len(node.rows) == 1 + and len(node.rows[0]) > 1 + and all(self.info(item).is_scalar for item in node.rows[0]) + ): + return ast.List(elts=[self.expr(item) for item in node.rows[0]]) + return self.expr(node) + + def _mechanical(self, tag: str) -> ModuleType: + rule = self._rule_for(tag) + if rule is None or rule.status is not Status.MECHANICAL: + raise _Unsupported(tag, rule) + module = self._translator_for(rule.id) + if module is None: + raise _Unsupported(tag, rule) + return module + + def stmt_translator(self, tag: str) -> ModuleType: + """The translator for a statement-level construct.""" + return self._mechanical(tag) + + # --- statements ---------------------------------------------------------- + + def block(self, body: list[ir.Stmt]) -> list[Line]: + """Translate a nested body one level deeper; never empty.""" + self.indent += 1 + try: + lines = self.statements(body) + finally: + self.indent -= 1 + if not any(line.text and not line.text.startswith("#") for line in lines): + lines.append(Line(self.indent + 1, "pass")) + return lines + + @contextmanager + def loop(self, stmt: ir.Stmt) -> Iterator[None]: + """Track the enclosing loop (``continue`` in ``do ... until`` needs to know).""" + self.loop_stack.append(stmt) + try: + yield + finally: + self.loop_stack.pop() + + def statements(self, body: list[ir.Stmt]) -> list[Line]: + """Translate statements at the current indentation.""" + lines: list[Line] = [] + previous_end: int | None = None + for stmt in body: + if previous_end is not None and stmt.loc.line > previous_end + 1 and lines: + lines.append(Line(self.indent, "")) # keep the source's paragraphs + lines.extend(self.statement(stmt)) + previous_end = stmt.loc.end_line + return lines + + def statement(self, stmt: ir.Stmt) -> list[Line]: + """Translate one statement, or emit a hole for it.""" + findings = self.scan.uses_by_stmt.get(id(stmt), []) + rules = sorted({f.rule.id for f in findings if f.rule is not None}) + report = StmtReport( + loc=stmt.loc, kind=type(stmt).__name__, rules=rules, status=Status.MECHANICAL + ) + self.reports.append(report) + blocking = [f for f in findings if f.rule is None or f.rule.status is not Status.MECHANICAL] + if blocking: + worst = _worst(blocking) + report.status = worst.status + report.reason = _describe(blocking) + return self.hole(stmt, report) + saved_imports = set(self.imports) + saved_directives = set(self.directives) + # Nested statements record their own assumptions; a compound statement's + # note must only carry what was assumed for its own header. + outer_assumptions = self.assumptions + self.assumptions = [] + try: + return self._translate_planned(stmt, report, saved_imports, saved_directives) + finally: + self.assumptions = outer_assumptions + + def _translate_planned( + self, + stmt: ir.Stmt, + report: StmtReport, + saved_imports: set[str], + saved_directives: set[str], + ) -> list[Line]: + """Translate a statement whose plan allows it; a decline turns it into a hole.""" + mark = len(self.reports) + try: + lines = self.translate_statement(stmt) + except Decline as exc: + self.imports = saved_imports + self.directives = saved_directives + del self.reports[mark:] + report.status = Status.GUIDED + report.reason = f"translator declined: {exc.reason}" + return self.hole(stmt, report) + except _Unsupported as exc: + self.imports = saved_imports + self.directives = saved_directives + del self.reports[mark:] + report.status = Status.UNSUPPORTED if exc.rule is None else exc.rule.status + label = exc.rule.id if exc.rule is not None else "no rule" + report.reason = f"{exc.tag} ({label})" + return self.hole(stmt, report) + notes = [*self.assumptions] + if stmt.comment: + notes.insert(0, stmt.comment) + if notes and lines: + # Compound statements carry the note on their header line. + compound = isinstance(stmt, ir.If | ir.For | ir.While | ir.Switch | ir.DoUntil) + code = [k for k, line in enumerate(lines) if not line.text.startswith("#")] + if code: + index = code[0] if compound or isinstance(stmt, ir.FunctionDef) else code[-1] + parts = [stmt.comment] if stmt.comment else [] + if self.assumptions: + parts.append(f"dualect: assumed {'; '.join(self.assumptions)}") + line = lines[index] + lines[index] = Line(line.indent, f"{line.text} # {'; '.join(parts)}") + return lines + + def translate_statement(self, stmt: ir.Stmt) -> list[Line]: + """Translate a statement whose constructs are all mechanical.""" + match stmt: + case ir.Assign(): + return self.assignment(stmt) + case ir.ExprStmt(value=value): + if "syntax:script-marker" in stmt.syntax: + return [] + return [Line(self.indent, ast.unparse(self.expr(value)))] + primary = primary_tag(stmt, self.analysis) + if primary is None: + raise Decline(f"no translation for {type(stmt).__name__}") + return self._lines(self.stmt_translator(primary).translate(stmt, self)) + + def _lines(self, result: object) -> list[Line]: + if not isinstance(result, list): + raise Decline("translator did not give statements") + return result + + def line(self, text: str, *, extra: int = 0) -> Line: + """A line at the current indentation (plus ``extra`` levels).""" + return Line(self.indent + extra, text) + + def assignment(self, stmt: ir.Assign) -> list[Line]: + """Plain and indexed assignment; multi-output calls go to their rule.""" + targets = stmt.targets + value = stmt.value + if len(targets) > 1 or isinstance(targets[0], ir.Ignore): + if isinstance(value, ir.Call) and not value.local and not value.handle: + module = self.stmt_translator(f"call:{value.func}") + multi = getattr(module, "translate_multi", None) + if multi is None: + raise Decline(f"{value.func} with several outputs") + return self._lines(multi(stmt, self)) + return self._lines(self.stmt_translator("assign:multi").translate(stmt, self)) + target = targets[0] + if isinstance(target, ir.Index): + module = self.stmt_translator("index:paren") + return self._lines(module.translate_store(stmt, self)) + if not isinstance(target, ir.Name): + raise _Unsupported(primary_tag(target, self.analysis) or "parse:error", None) + name = target.id + lines: list[Line] = [] + if self.is_index_var(name): + lines.extend(self.index_directive(name)) + rhs = self.position_value(value) + lines.append(self.line(f"{name} = {ast.unparse(rhs)}")) + return lines + rhs = self.expr(value) + augmented = self._augmented(name, value) + if augmented is not None: + return [self.line(augmented)] + if self._needs_copy(name, value, rhs): + rhs = self.method(rhs, "copy") + lines.append(self.line(f"{name} = {ast.unparse(rhs)}")) + return lines + + def position_value(self, value: ir.Expr) -> ast.expr: + """The 0-based form of a value assigned to an index variable.""" + if isinstance(value, ir.Num) and isinstance(value.value, int): + return self.const(value.value - 1) + if isinstance(value, ir.Matrix): + items = [item for row in value.rows for item in row] + if all(isinstance(i, ir.Num) and isinstance(i.value, int) for i in items): + shifted = [ast.Constant(i.value - 1) for i in items if isinstance(i, ir.Num)] + return self.call(self.np("array"), ast.List(elts=list(shifted))) + if isinstance(value, ir.Call): + module = self.stmt_translator(f"call:{value.func}") + positions = getattr(module, "translate_positions", None) + if positions is not None: + result = positions(value, self) + if isinstance(result, ast.expr): + return result + raise Decline("cannot store this value 0-based") + + def _augmented(self, name: str, value: ir.Expr) -> str | None: + """``x = x + e`` on a known scalar reads best as ``x += e``.""" + if not ( + isinstance(value, ir.BinOp) + and value.op in ("plus", "minus") + and isinstance(value.left, ir.Name) + and value.left.id == name + ): + return None + before = self.info(value.left) + if not (before.is_scalar and before.elem.value in ("real", "logical")): + return None + # Only simple steps read better augmented (`count += 1`, `s += k`). + if not isinstance(value.right, ir.Num | ir.Name): + return None + op = "+=" if value.op == "plus" else "-=" + return f"{name} {op} {ast.unparse(self.expr(value.right))}" + + def _needs_copy(self, name: str, value: ir.Expr, rhs: ast.expr) -> bool: + """Whether ``name = value`` must copy to keep ``.m`` copy semantics. + + NumPy assignment binds the same array, and slices and transposes are + views; the ``.m`` side always has a private copy. A copy is needed when + either side is later modified in place and the right-hand side may share + memory (a variable, an index or slice, a transpose). + """ + info = self.info(value) + if not (info.is_array or info.kind is Kind.UNKNOWN): + return False + shares = isinstance(rhs, ast.Name | ast.Subscript | ast.Attribute) + if not shares: + return False + source = value.id if isinstance(value, ir.Name) else None + return name in self.scope.mutated or (source is not None and source in self.scope.mutated) + + # --- holes --------------------------------------------------------------- + + def hole(self, stmt: ir.Stmt, report: StmtReport) -> list[Line]: + """Placeholder for a statement that was not translated.""" + lines = [ + self.line(f"# TODO(dualect): {report.status.value}, {report.reason}"), + self.line(f"# line {stmt.loc.line} of the source:"), + ] + for text in self.source_text(stmt.loc): + lines.append(self.line(f"# {text}")) + message = f"dualect: line {stmt.loc.line} was not translated ({report.status.value})" + lines.append(self.line(f"raise NotImplementedError({message!r})")) + # Nested statements of an untranslated compound are not reported again. + return lines + + def source_text(self, loc: ir.Loc) -> list[str]: + """The original source lines of a span.""" + if not self.source_lines: + return [] + first = max(loc.line, 1) + last = min(max(loc.end_line, first), len(self.source_lines)) + return [self.source_lines[n - 1].rstrip() for n in range(first, last + 1)] + + +def _worst(findings: list[Finding]) -> Finding: + for finding in findings: + if finding.status is Status.UNSUPPORTED: + return finding + return findings[0] + + +def _describe(findings: list[Finding]) -> str: + parts = [] + for finding in findings: + label = finding.rule.id if finding.rule is not None else "no rule" + text = f"{finding.tag} ({label})" + if text not in parts: + parts.append(text) + return "needs " + ", ".join(parts) + + +# --- scope analyses -------------------------------------------------------------- + + +def scope_facts( + *, + body: list[ir.Stmt], + params: list[str], + outputs: list[str], + position_outputs: Callable[[ir.Call, int], set[int]], + analysis: Analysis, +) -> ScopeFacts: + """Compute :class:`ScopeFacts` for one function body (or the script). + + :param body: the statements of the scope (nested functions excluded). + :param params: parameter names (empty for the script). + :param outputs: output names (empty for the script). + :param position_outputs: for a built-in call and an output count, the + output positions that hold 1-based positions (``find``, ``max``'s second). + :param analysis: inference results. + """ + facts = ScopeFacts(outputs=list(outputs), variables={*params, *outputs}) + stmts = _scope_statements(body) + for stmt in stmts: + if isinstance(stmt, ir.Assign): + # Deleting elements (`x(m) = []`) rebinds the name; it does not + # modify the array in place. + deleting = isinstance(stmt.value, ir.Matrix) and not stmt.value.rows + for target in stmt.targets: + if isinstance(target, ir.Name): + facts.variables.add(target.id) + elif isinstance(target, ir.Index) and isinstance(target.target, ir.Name): + facts.variables.add(target.target.id) + if not deleting: + facts.mutated.add(target.target.id) + elif isinstance(stmt, ir.AugAssign): + if isinstance(stmt.target, ir.Index) and isinstance(stmt.target.target, ir.Name): + facts.mutated.add(stmt.target.target.id) + elif isinstance(stmt, ir.For): + facts.variables.add(stmt.var.id) + facts.index_vars = index_variables( + stmts=stmts, + excluded={*params, *outputs}, + position_outputs=position_outputs, + analysis=analysis, + ) + return facts + + +def _scope_statements(body: list[ir.Stmt]) -> list[ir.Stmt]: + """Every statement of a scope, without descending into nested functions.""" + found: list[ir.Stmt] = [] + for stmt in body: + if isinstance(stmt, ir.FunctionDef): + continue + found.append(stmt) + for inner in ir.stmt_bodies(stmt): + found.extend(_scope_statements(inner)) + return found + + +def index_variables( + *, + stmts: list[ir.Stmt], + excluded: set[str], + position_outputs: Callable[[ir.Call, int], set[int]], + analysis: Analysis, +) -> set[str]: + """Variables that can be stored 0-based: they only ever hold positions. + + A variable qualifies when every assignment to it produces positions (an + integer literal, the position output of a built-in such as ``find``, or a + ``for`` loop over an integer range) and every read of it is inside a + subscript, where a 1-based position would be shifted anyway. Storing it + 0-based then removes every ``- 1`` at its uses: ``i = 2; x(i + 1)`` becomes + ``i = 1; x[i + 1]``. A variable from ``find`` qualifies even when unused, + since NumPy users expect positions to be 0-based. Function parameters and + outputs never qualify: their values cross the function boundary. + + :param stmts: every statement of the scope (flattened). + :param excluded: names that never qualify. + :param position_outputs: see :func:`scope_facts`. + :param analysis: inference results. + """ + sources: dict[str, set[str]] = {} + for stmt in stmts: + if isinstance(stmt, ir.Assign): + names = [t.id if isinstance(t, ir.Name) else None for t in stmt.targets] + value = stmt.value + positions: set[int] = set() + if isinstance(value, ir.Call) and not value.local and not value.handle: + positions = position_outputs(value, len(stmt.targets)) + for k, name in enumerate(names): + if name is None: + continue + if k in positions: + kind = "position" + elif len(names) == 1 and _is_position_literal(value): + kind = "literal" + else: + kind = "other" + sources.setdefault(name, set()).add(kind) + elif isinstance(stmt, ir.AugAssign) and isinstance(stmt.target, ir.Name): + sources.setdefault(stmt.target.id, set()).add("other") + elif isinstance(stmt, ir.For): + kind = "loop" if _is_position_range(stmt.iterable, analysis) else "other" + sources.setdefault(stmt.var.id, set()).add(kind) + + reads: dict[str, list[bool]] = {} + for stmt in stmts: + for root in _read_roots(stmt): + _collect_reads(root, reads, in_subscript=False) + + chosen: set[str] = set() + for name, kinds in sources.items(): + if name in excluded or "other" in kinds: + continue + uses = reads.get(name, []) + if not all(uses): + continue + if kinds == {"position"} or uses: + chosen.add(name) + return chosen + + +def _is_position_literal(value: ir.Expr) -> bool: + """An integer literal >= 1, or a vector literal of them.""" + if isinstance(value, ir.Num): + return isinstance(value.value, int) and value.value >= 1 + if isinstance(value, ir.Matrix) and value.rows: + items = [item for row in value.rows for item in row] + is_vector = len(value.rows) == 1 or all(len(row) == 1 for row in value.rows) + return is_vector and all(_is_position_literal(item) for item in items) + return False + + +def _is_position_range(iterable: ir.Expr, analysis: Analysis) -> bool: + """A ``for`` range of integer positions with step 1: ``1:n``, ``k:m``.""" + if not isinstance(iterable, ir.Range) or iterable.step is not None: + return False + start = analysis.info(iterable.start).value + return isinstance(start, int | float) and float(start).is_integer() and start >= 1 + + +def _read_roots(stmt: ir.Stmt) -> list[ir.Expr]: + """Expressions a statement reads (assignment targets' subscripts included).""" + roots: list[ir.Expr] = [] + for expr in ir.stmt_exprs(stmt): + if isinstance(stmt, ir.Assign | ir.AugAssign) and isinstance(expr, ir.Name): + if isinstance(stmt, ir.AugAssign) and expr is stmt.target: + roots.append(expr) + elif isinstance(stmt, ir.Assign) and expr in stmt.targets: + continue + else: + roots.append(expr) + continue + if isinstance(stmt, ir.For) and expr is stmt.var: + continue + roots.append(expr) + return roots + + +def _collect_reads(node: ir.Expr, reads: dict[str, list[bool]], *, in_subscript: bool) -> None: + """Record, for each name read, whether the read is position-only.""" + match node: + case ir.Name(id=name): + reads.setdefault(name, []).append(in_subscript) + case ir.Index(target=target, args=args): + if isinstance(target, ir.Name): + # Indexing a position array keeps its elements positions only when + # the result is itself used as a subscript. + reads.setdefault(target.id, []).append(in_subscript) + else: + _collect_reads(target, reads, in_subscript=False) + for arg in args: + _collect_subscript(arg, reads) + case ir.Lambda(body=body): + _collect_reads(body, reads, in_subscript=False) + case _: + for child in ir.child_exprs(node): + _collect_reads(child, reads, in_subscript=False) + + +def _collect_subscript(node: ir.Expr, reads: dict[str, list[bool]]) -> None: + """Reads inside a subscript: linear uses (``i``, ``i + 1``, ``a:i``) are positions.""" + match node: + case ir.Name() | ir.Index(): + _collect_reads(node, reads, in_subscript=True) + case ir.BinOp(op="plus", left=left, right=right): + _collect_subscript(left, reads) + _collect_subscript(right, reads) + case ir.BinOp(op="minus", left=left, right=right): + _collect_subscript(left, reads) + _collect_reads(right, reads, in_subscript=False) + case ir.Range(start=start, stop=stop, step=step): + _collect_subscript(start, reads) + _collect_subscript(stop, reads) + if step is not None: + _collect_reads(step, reads, in_subscript=False) + case _: + _collect_reads(node, reads, in_subscript=False) + + +# --- helpers for translators --------------------------------------------------- + + +def int_constant(node: ast.expr) -> int | None: + """The value of an integer literal (including ``-k``), else ``None``.""" + if isinstance(node, ast.Constant) and type(node.value) is int: + return node.value + if ( + isinstance(node, ast.UnaryOp) + and isinstance(node.op, ast.USub) + and isinstance(node.operand, ast.Constant) + and type(node.operand.value) is int + ): + return -node.operand.value + return None + + +def offset(node: ast.expr, delta: int) -> ast.expr: + """``node + delta`` with integer constants folded: ``(i + 1) - 1`` is ``i``. + + :param node: a Python expression. + :param delta: the integer to add. + """ + if delta == 0: + return node + value = int_constant(node) + if value is not None: + return Context.const(value + delta) + if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Add | ast.Sub): + right = int_constant(node.right) + if right is not None: + carried = right if isinstance(node.op, ast.Add) else -right + return offset(node.left, carried + delta) + if delta > 0: + return ast.BinOp(left=node, op=ast.Add(), right=ast.Constant(delta)) + return ast.BinOp(left=node, op=ast.Sub(), right=ast.Constant(-delta)) + + +def render(lines: list[Line]) -> str: + """Join emitted lines into source text.""" + return "\n".join(line.render() for line in lines) + "\n" diff --git a/dualect/errors.py b/dualect/errors.py new file mode 100644 index 0000000..b95ec7a --- /dev/null +++ b/dualect/errors.py @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Named exceptions raised by dualect. + +Every failure dualect knows how to describe gets its own class, so callers (the +CLI, tests, a future MCP server) can react to the *kind* of problem rather than +parsing messages. This is also how "never translate silently wrong" is enforced: +an unknown construct is an exception with a rule id, not a best guess. +""" + +from pathlib import Path + + +class DualectError(Exception): + """Base class for every error dualect raises on purpose.""" + + +class RuleError(DualectError): + """A rule folder or ``rule.yaml`` is missing, malformed or inconsistent.""" + + +class RuntimeMissingError(DualectError): + """The program needed to execute ``.m`` code (GNU Octave) is not available.""" + + +class ExecutionError(DualectError): + """Running one side of a translation pair failed. + + :param side: ``"m"`` or ``"py"``, which side failed. + :param path: the script that was being executed. + :param message: the interpreter's error text. + """ + + def __init__(self, *, side: str, path: Path, message: str) -> None: + self.side = side + self.path = path + self.message = message + super().__init__(f"{side} side failed ({path}): {message}") + + +class DirectiveError(DualectError): + """A ``dualect:`` comment directive in a case file could not be understood.""" + + +class UnsupportedConstructError(DualectError): + """A source construct has no supported translation. + + Raised by the translator (milestone 4 onward) instead of emitting a guess. + + :param rule_id: the ``unsupported`` rule that documents the construct, or + ``None`` when no rule names it yet. + :param detail: where and what the construct is, for the report. + """ + + def __init__(self, *, rule_id: str | None, detail: str) -> None: + self.rule_id = rule_id + self.detail = detail + label = rule_id if rule_id is not None else "no rule yet" + super().__init__(f"unsupported construct ({label}): {detail}") diff --git a/dualect/infer.py b/dualect/infer.py new file mode 100644 index 0000000..7c79101 --- /dev/null +++ b/dualect/infer.py @@ -0,0 +1,1113 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Shape and type inference over the IR (docs/design.md section 5.2, step 1). + +Several translations depend on facts the source does not state: is ``a * b`` a +scalar product or a matrix product, is ``x`` a row or a column, can ``max(x)`` +meet a NaN? This module infers what it can from literals, known built-in +return shapes and data flow, and records an :class:`Info` for every expression. +When a fact is unknown it stays unknown: translators then emit the safe form +with a ``# dualect: assumed ...`` comment, or decline, and verification checks +the result. + +The analysis is flow-sensitive within a body, joins branches, iterates loops to +a fixed point, and specializes each local function once, for the join of the +argument facts at all of its call sites in the file. + +All facts describe the *source* (``.m``) semantics: shapes are ``rows x cols``. +How a fact maps to NumPy (a ``1xN`` row is a 1-D array) is the emitter's +business. +""" + +from __future__ import annotations + +import math +from dataclasses import dataclass, field, replace +from enum import StrEnum +from typing import TypedDict + +from dualect import ir + + +class Kind(StrEnum): + """Coarse shape class of a value.""" + + SCALAR = "scalar" + ROW = "row" # 1xN, N != 1 + COL = "col" # Nx1, N != 1 + VECTOR = "vector" # a row or a column, orientation unknown + MATRIX = "matrix" # MxN, neither dimension known to be 1 + EMPTY = "empty" # 0x0, written [] + ARRAY = "array" # some numeric array, shape unknown + STRING = "string" # a char row vector (or double-quoted string) + FUNC = "func" # a function handle + CELL = "cell" + UNKNOWN = "unknown" + + +class Elem(StrEnum): + """Element type.""" + + REAL = "real" + COMPLEX = "complex" + LOGICAL = "logical" + CHAR = "char" + UNKNOWN = "unknown" + + +_ARRAY_KINDS = frozenset({Kind.ROW, Kind.COL, Kind.VECTOR, Kind.MATRIX, Kind.EMPTY, Kind.ARRAY}) +_VECTOR_KINDS = frozenset({Kind.ROW, Kind.COL, Kind.VECTOR}) + + +@dataclass(frozen=True) +class Info: + """What is known about one value. + + :param kind: shape class. + :param rows: number of rows, if known. + :param cols: number of columns, if known. + :param elem: element type. + :param finite: known to contain no NaN or Inf. + :param nonneg: known to contain no negative value. + :param integer: known to hold integer values only. + :param value: the exact value of a scalar, when known (constant folding). + :param int_dtype: the *NumPy translation* may hold an integer dtype. Source + numbers are doubles, but idiomatic NumPy writes ``np.array([1, 2])``; + storing a fraction into such an array would truncate silently, so + translators check this before an element assignment. + :param maybe_undefined: on some path the variable was never assigned. + :param func: for a function handle, the lambda it holds (if known). + :param env: for a lambda, the variables it captured. + """ + + kind: Kind = Kind.UNKNOWN + rows: int | None = None + cols: int | None = None + elem: Elem = Elem.UNKNOWN + finite: bool = False + nonneg: bool = False + integer: bool = False + value: float | complex | None = None + int_dtype: bool = False + maybe_undefined: bool = False + func: ir.Lambda | None = field(default=None, compare=False) + env: dict[str, Info] | None = field(default=None, compare=False, repr=False) + + @property + def is_scalar(self) -> bool: + """A single number (or logical).""" + return self.kind is Kind.SCALAR + + @property + def is_array(self) -> bool: + """A numeric or logical array that is not known to be a scalar.""" + return self.kind in _ARRAY_KINDS + + @property + def is_vector(self) -> bool: + """A row or column (1-D in NumPy), possibly of unknown orientation.""" + return self.kind in _VECTOR_KINDS or self.kind is Kind.EMPTY + + @property + def is_matrix(self) -> bool: + """Known to be two-dimensional with neither dimension 1 (2-D in NumPy).""" + return self.kind is Kind.MATRIX + + @property + def is_logical(self) -> bool: + """Known logical elements.""" + return self.elem is Elem.LOGICAL + + @property + def is_real(self) -> bool: + """Known real (or logical) elements; complex values need conjugation.""" + return self.elem in (Elem.REAL, Elem.LOGICAL) + + @property + def numel(self) -> int | None: + """Element count, if known.""" + if self.kind is Kind.SCALAR: + return 1 + if self.rows is not None and self.cols is not None: + return self.rows * self.cols + return None + + +UNKNOWN = Info() + + +class _Facts(TypedDict, total=False): + """Element facts shared by a value and the values derived from it.""" + + elem: Elem + finite: bool + nonneg: bool + integer: bool + + +def scalar( + *, + elem: Elem = Elem.REAL, + finite: bool = True, + nonneg: bool = False, + integer: bool = False, + value: float | complex | None = None, +) -> Info: + """Info for a scalar.""" + return Info( + kind=Kind.SCALAR, + rows=1, + cols=1, + elem=elem, + finite=finite, + nonneg=nonneg, + integer=integer, + value=value, + ) + + +def array( + rows: int | None, + cols: int | None, + *, + elem: Elem = Elem.REAL, + finite: bool = False, + nonneg: bool = False, + integer: bool = False, + kind: Kind | None = None, +) -> Info: + """Info for an array of the given dimensions (``None`` = unknown).""" + if kind is None: + kind = _kind_of(rows, cols) + return Info( + kind=kind, + rows=rows, + cols=cols, + elem=elem, + finite=finite, + nonneg=nonneg, + integer=integer, + ) + + +def _kind_of(rows: int | None, cols: int | None) -> Kind: + if rows == 1 and cols == 1: + return Kind.SCALAR + if rows == 0 and cols == 0: + return Kind.EMPTY + if rows == 1: + return Kind.ROW + if cols == 1: + return Kind.COL + if rows is not None and cols is not None: + return Kind.MATRIX + return Kind.ARRAY + + +def join(a: Info, b: Info) -> Info: + """The facts that hold for a value that may be either ``a`` or ``b``.""" + if a == b and a.func is b.func: + return a + kind = a.kind if a.kind is b.kind else Kind.UNKNOWN + if kind is Kind.UNKNOWN: + pair = {a.kind, b.kind} + if pair <= {Kind.ROW, Kind.EMPTY}: + kind = Kind.ROW + elif pair <= {Kind.COL, Kind.EMPTY}: + kind = Kind.COL + elif pair <= _VECTOR_KINDS | {Kind.EMPTY}: + kind = Kind.VECTOR + elif pair <= _ARRAY_KINDS: + kind = Kind.ARRAY + rows = a.rows if a.rows == b.rows else None + cols = a.cols if a.cols == b.cols else None + if kind is Kind.ROW: + rows = 1 + if kind is Kind.COL: + cols = 1 + return Info( + kind=kind, + rows=rows, + cols=cols, + elem=a.elem if a.elem is b.elem else Elem.UNKNOWN, + finite=a.finite and b.finite, + nonneg=a.nonneg and b.nonneg, + integer=a.integer and b.integer, + value=a.value if a.value == b.value else None, + int_dtype=a.int_dtype or b.int_dtype, + maybe_undefined=a.maybe_undefined or b.maybe_undefined, + func=a.func if a.func is b.func else None, + env=a.env if a.func is b.func else None, + ) + + +Env = dict[str, Info] + + +def join_envs(a: Env, b: Env) -> Env: + """Join two variable environments; a name missing on one side may be undefined.""" + missing = Info(maybe_undefined=True) + return {name: join(a.get(name, missing), b.get(name, missing)) for name in a.keys() | b.keys()} + + +# --- built-in return facts ------------------------------------------------- + +#: Element-wise functions: same shape as the (first) argument. +ELEMENTWISE = frozenset( + {"abs", "sqrt", "exp", "log", "log2", "log10", "sin", "cos", "tan", "asin", "acos", + "atan", "sinh", "cosh", "tanh", "floor", "ceil", "round", "fix", "sign", "real", + "imag", "conj", "isnan", "isinf", "isfinite", "mod", "rem", "atan2", "hypot"} +) # fmt: skip +_LOGICAL_RESULT = frozenset({"isnan", "isinf", "isfinite"}) +_INTEGER_RESULT = frozenset({"floor", "ceil", "round", "fix", "sign"}) +_NONNEG_RESULT = frozenset({"abs", "sqrt", "exp", "hypot"}) +_REDUCTIONS = frozenset({"sum", "mean", "max", "min", "prod"}) +CONSTANTS: dict[str, Info] = { + "pi": scalar(nonneg=True, value=math.pi), + "e": scalar(nonneg=True, value=math.e), + "eps": scalar(nonneg=True, value=2.220446049250313e-16), + "Inf": scalar(finite=False, nonneg=True, value=math.inf), + "inf": scalar(finite=False, nonneg=True, value=math.inf), + "NaN": scalar(finite=False), + "nan": scalar(finite=False), + "true": scalar(elem=Elem.LOGICAL, nonneg=True, integer=True, value=1), + "false": scalar(elem=Elem.LOGICAL, nonneg=True, integer=True, value=0), + "i": scalar(elem=Elem.COMPLEX, value=1j), + "j": scalar(elem=Elem.COMPLEX, value=1j), +} + + +def broadcast(a: Info, b: Info) -> Info: + """Shape of an element-wise operation on ``a`` and ``b`` (implicit expansion).""" + if a.is_scalar: + return replace(b, value=None, func=None) if b.kind is not Kind.UNKNOWN else UNKNOWN + if b.is_scalar: + return replace(a, value=None, func=None) if a.kind is not Kind.UNKNOWN else UNKNOWN + if a.kind is Kind.UNKNOWN or b.kind is Kind.UNKNOWN: + return UNKNOWN + if {a.kind, b.kind} == {Kind.ROW, Kind.COL}: + row, col = (a, b) if a.kind is Kind.ROW else (b, a) + return array(col.rows, row.cols, kind=Kind.MATRIX) + if a.kind is b.kind: + return array( + a.rows if a.rows == b.rows else a.rows or b.rows, + a.cols if a.cols == b.cols else a.cols or b.cols, + kind=a.kind, + ) + if Kind.MATRIX in (a.kind, b.kind) and {a.kind, b.kind} <= {Kind.MATRIX, Kind.ROW, Kind.COL}: + matrix = a if a.kind is Kind.MATRIX else b + return array(matrix.rows, matrix.cols, kind=Kind.MATRIX) + return array(None, None, kind=Kind.ARRAY) + + +def _numeric_elem(a: Info, b: Info) -> Elem: + if Elem.COMPLEX in (a.elem, b.elem): + return Elem.COMPLEX + if a.elem in (Elem.REAL, Elem.LOGICAL, Elem.CHAR) and b.elem in ( + Elem.REAL, + Elem.LOGICAL, + Elem.CHAR, + ): + return Elem.REAL + return Elem.UNKNOWN + + +def _fold(op: str, a: Info, b: Info) -> float | complex | None: + """Constant-fold a scalar binary operation when both values are known.""" + x, y = a.value, b.value + if x is None or y is None: + return None + try: + if op == "plus": + return x + y + if op == "minus": + return x - y + if op in ("mtimes", "times"): + return x * y + if op in ("mrdivide", "rdivide"): + return x / y + except (ZeroDivisionError, OverflowError): + return None + return None + + +@dataclass +class FunctionFacts: + """What the analysis learned about one local function. + + :param params: joined argument facts over all call sites. + :param outputs: facts about each output at the end of the function. + :param call_counts: numbers of arguments the call sites passed. + :param nargouts: numbers of outputs the call sites requested. + """ + + params: list[Info] + outputs: list[Info] + call_counts: set[int] = field(default_factory=set) + nargouts: set[int] = field(default_factory=set) + + +@dataclass +class Analysis: + """Inference results for one program. + + :param infos: ``id(expr)`` -> facts about that expression's value. + :param functions: local function name -> facts. + :param env_after: ``id(stmt)`` -> environment after the statement ran. + :param env_before: ``id(stmt)`` -> environment before the statement ran. + """ + + infos: dict[int, Info] = field(default_factory=dict) + functions: dict[str, FunctionFacts] = field(default_factory=dict) + env_after: dict[int, Env] = field(default_factory=dict) + env_before: dict[int, Env] = field(default_factory=dict) + + def info(self, expr: ir.Expr) -> Info: + """Facts about an expression (unknown if it was never analysed).""" + return self.infos.get(id(expr), UNKNOWN) + + +class _Inferrer: + def __init__(self, program: ir.Program) -> None: + self.program = program + self.analysis = Analysis() + self.defs: dict[str, ir.FunctionDef] = { + s.name: s for s in program.body if isinstance(s, ir.FunctionDef) + } + self.call_sites: dict[str, list[list[Info]]] = {} + # id(lambda) -> its parameters' facts joined over every call so far in + # this round (see :meth:`call`). + self.lambda_params: dict[int, list[Info]] = {} + self.current_function: ir.FunctionDef | None = None + + # --- driver -------------------------------------------------------------- + + def run(self) -> Analysis: + for name, fdef in self.defs.items(): + self.analysis.functions[name] = FunctionFacts( + params=[UNKNOWN] * len(fdef.params), outputs=[UNKNOWN] * len(fdef.outputs) + ) + # Script first (records call sites), then each function with the joined + # facts of its callers; repeat so facts flow through call chains. + for _round in range(3): + self.call_sites = {} + self.lambda_params = {} + self.body(self.program.body, {}) + for name, fdef in self.defs.items(): + self.function(name, fdef) + return self.analysis + + def function(self, name: str, fdef: ir.FunctionDef) -> None: + facts = self.analysis.functions[name] + sites = self.call_sites.get(name, []) + params: list[Info] = [] + for index, _param in enumerate(fdef.params): + passed = [site[index] for site in sites if index < len(site)] + if not passed: + params.append(UNKNOWN) + continue + joined = passed[0] + for info in passed[1:]: + joined = join(joined, info) + params.append(joined) + facts.params = params + env: Env = { + param: info for param, info in zip(fdef.params, params, strict=True) if param != "~" + } + outer = self.current_function + self.current_function = fdef + try: + env = self.body(fdef.body, env) + finally: + self.current_function = outer + facts.outputs = [env.get(out, UNKNOWN) for out in fdef.outputs] + + # --- statements ------------------------------------------------------------ + + def body(self, stmts: list[ir.Stmt], env: Env) -> Env: + for stmt in stmts: + self.analysis.env_before[id(stmt)] = dict(env) + env = self.stmt(stmt, env) + self.analysis.env_after[id(stmt)] = dict(env) + return env + + def stmt(self, stmt: ir.Stmt, env: Env) -> Env: + match stmt: + case ir.Assign(): + return self.assign(stmt, env) + case ir.AugAssign(target=target, op=op, value=value): + current = self.expr(target, env) + rhs = self.expr(value, env) + result = self.binop(op, current, rhs) + if isinstance(target, ir.Name): + env = {**env, target.id: result} + return env + case ir.ExprStmt(value=value): + self.expr(value, env) + return env + case ir.If(branches=branches, orelse=orelse): + results = [] + for cond, body in branches: + self.expr(cond, env) + results.append(self.body(body, dict(env))) + results.append(self.body(orelse, dict(env)) if orelse is not None else env) + merged = results[0] + for other in results[1:]: + merged = join_envs(merged, other) + return merged + case ir.Switch(subject=subject, cases=cases, otherwise=otherwise): + self.expr(subject, env) + results = [] + for values, body in cases: + for value in values: + self.expr(value, env) + results.append(self.body(body, dict(env))) + results.append(self.body(otherwise, dict(env)) if otherwise is not None else env) + merged = results[0] + for other in results[1:]: + merged = join_envs(merged, other) + return merged + case ir.For(var=var, iterable=iterable, body=body): + iter_info = self.expr(iterable, env) + element = self.loop_element(iterable, iter_info) + return self.loop(body, env, bind={var.id: element}, cond=None) + case ir.While(cond=cond, body=body): + return self.loop(body, env, bind={}, cond=cond) + case ir.DoUntil(body=body, cond=cond): + return self.loop(body, env, bind={}, cond=cond, cond_after=True) + case ir.FunctionDef(): + return env + return env + + def loop( + self, + body: list[ir.Stmt], + env: Env, + *, + bind: Env, + cond: ir.Expr | None, + cond_after: bool = False, + ) -> Env: + """Iterate a loop body to a fixed point of the environment.""" + state = dict(env) + for _ in range(6): + entry = {**state, **bind} + if cond is not None and not cond_after: + self.expr(cond, entry) + out = self.body(body, dict(entry)) + if cond is not None and cond_after: + self.expr(cond, out) + merged = join_envs(state, out) + if merged == state: + break + state = merged + else: + # No fixed point (a value keeps growing): forget what changed. + state = {k: v if env.get(k) == v else UNKNOWN for k, v in state.items()} + # One last pass so the annotations describe the loop-invariant facts. + entry = {**state, **bind} + if cond is not None and not cond_after: + self.expr(cond, entry) + out = self.body(body, dict(entry)) + if cond is not None and cond_after: + self.expr(cond, out) + return join_envs(state, out) + + @staticmethod + def loop_element(iterable: ir.Expr, info: Info) -> Info: + """Facts about the loop variable: one *column* of the iterable per pass.""" + base: _Facts = { + "elem": info.elem, + "finite": info.finite, + "nonneg": info.nonneg, + "integer": info.integer, + } + if info.kind in (Kind.ROW, Kind.SCALAR): + return replace(scalar(**base), int_dtype=info.int_dtype) + if info.kind in (Kind.COL, Kind.MATRIX): + return replace(array(info.rows, 1, **base), int_dtype=info.int_dtype) + return UNKNOWN + + def assign(self, stmt: ir.Assign, env: Env) -> Env: + value = stmt.value + targets = stmt.targets + if len(targets) > 1: + outputs = self.multi_outputs(value, env, len(targets)) + env = dict(env) + for target, info in zip(targets, outputs, strict=True): + if isinstance(target, ir.Name): + env[target.id] = info + else: + self.expr(target, env) + return env + rhs = self.expr(value, env) + target = targets[0] + if isinstance(target, ir.Name): + return {**env, target.id: rhs} + if isinstance(target, ir.Index) and isinstance(target.target, ir.Name): + name = target.target.id + before = env.get(name) + for arg in target.args: + self.expr(arg, env) + self.analysis.infos[id(target.target)] = before or UNKNOWN + self.analysis.infos[id(target)] = UNKNOWN + if ( + before is None + or before.kind in (Kind.UNKNOWN, Kind.EMPTY) + or index_may_grow(target, before, self.analysis) + ): + grown = array(None, None, elem=_numeric_elem(before or UNKNOWN, rhs)) + if ( + before is not None + and before.kind in (Kind.ROW, Kind.EMPTY) + and len(target.args) == 1 + ): + grown = array(1, None, elem=grown.elem) + elif before is not None and before.kind is Kind.COL and len(target.args) == 1: + grown = array(None, 1, elem=grown.elem) + return {**env, name: grown} + elem = before.elem + if rhs.elem is Elem.COMPLEX: + elem = Elem.COMPLEX + elif before.elem is Elem.LOGICAL and rhs.elem is not Elem.LOGICAL: + elem = Elem.UNKNOWN + updated = replace( + before, + elem=elem, + finite=before.finite and rhs.finite, + nonneg=before.nonneg and rhs.nonneg, + integer=before.integer and rhs.integer, + value=None, + ) + return {**env, name: updated} + self.expr(target, env) + return env + + def multi_outputs(self, value: ir.Expr, env: Env, count: int) -> list[Info]: + first = self.expr(value, env, nargout=count) + if isinstance(value, ir.Call): + arg_infos = [self.analysis.info(arg) for arg in value.args] + if value.local and value.func in self.analysis.functions: + outputs = self.analysis.functions[value.func].outputs + return [outputs[k] if k < len(outputs) else UNKNOWN for k in range(count)] + if value.func in ("max", "min") and arg_infos: + position = replace(first, elem=Elem.REAL, finite=True, nonneg=True, integer=True) + return [first, position] + [UNKNOWN] * (count - 2) + if value.func == "size": + dim = scalar(nonneg=True, integer=True) + return [dim] * count + if value.func == "find" and arg_infos: + return [first] * count + return [first] + [UNKNOWN] * (count - 1) + + # --- expressions ------------------------------------------------------------- + + def expr(self, node: ir.Expr, env: Env, *, nargout: int = 1) -> Info: + info = self._expr(node, env, nargout=nargout) + self.analysis.infos[id(node)] = info + return info + + def _expr(self, node: ir.Expr, env: Env, *, nargout: int) -> Info: + match node: + case ir.Num(value=value): + if isinstance(value, complex): + return scalar(elem=Elem.COMPLEX, value=value) + literal = scalar(nonneg=value >= 0, integer=float(value).is_integer(), value=value) + return replace(literal, int_dtype=isinstance(value, int)) + case ir.Str(value=value): + return Info(kind=Kind.STRING, rows=1, cols=len(value), elem=Elem.CHAR) + case ir.Name(id=name): + return env.get(name, UNKNOWN) + case ir.Colon() | ir.End() | ir.Ignore(): + return scalar(nonneg=True, integer=True) + case ir.Range(): + return self.range(node, env) + case ir.Matrix(rows=rows): + return self.matrix(rows, env) + case ir.CellLit(items=items): + for item in items: + self.expr(item, env) + return Info(kind=Kind.CELL) + case ir.BinOp(op=op, left=left, right=right): + return self.binop(op, self.expr(left, env), self.expr(right, env)) + case ir.UnOp(op=op, operand=operand): + inner = self.expr(operand, env) + if op == "not": + return replace( + inner, elem=Elem.LOGICAL, finite=True, nonneg=True, integer=True, value=None + ) + if op == "uminus": + negated = -inner.value if inner.value is not None else None + return replace(inner, nonneg=negated == 0, value=negated, func=None) + return inner + case ir.Transpose(operand=operand): + inner = self.expr(operand, env) + kind = {Kind.ROW: Kind.COL, Kind.COL: Kind.ROW}.get(inner.kind, inner.kind) + return replace(inner, kind=kind, rows=inner.cols, cols=inner.rows) + case ir.Index(): + result = self.index(node, env) + target = self.analysis.info(node.target) + return replace(result, int_dtype=target.int_dtype) + case ir.Call(): + result = self.call(node, env, nargout=nargout) + return replace(result, int_dtype=self.int_result(node, result)) + case ir.Lambda(): + return Info(kind=Kind.FUNC, func=node, env=dict(env)) + case ir.FuncRef(): + return Info(kind=Kind.FUNC) + return UNKNOWN + + def range(self, node: ir.Range, env: Env) -> Info: + start = self.expr(node.start, env) + stop = self.expr(node.stop, env) + step = self.expr(node.step, env) if node.step is not None else scalar(integer=True, value=1) + count = range_count(start.value, step.value, stop.value) + finite = start.finite and stop.finite and step.finite + info = array( + 1, + count, + finite=finite, + nonneg=start.nonneg and step.nonneg, + integer=start.integer and step.integer, + kind=Kind.ROW if count != 1 else Kind.SCALAR, + ) + # An integer range translates to np.arange / range(), which hold ints. + return replace(info, int_dtype=start.integer and step.integer) + + def matrix(self, rows: list[list[ir.Expr]], env: Env) -> Info: + if not rows: + return array(0, 0, finite=True, nonneg=True, integer=True) + infos = [[self.expr(item, env) for item in row] for row in rows] + flat = [info for row in infos for info in row] + if all(info.kind is Kind.STRING for info in flat) and len(rows) == 1: + cols = sum(info.cols or 0 for info in flat) if all(i.cols for i in flat) else None + return Info(kind=Kind.STRING, rows=1, cols=cols, elem=Elem.CHAR) + elem = Elem.LOGICAL if all(i.elem is Elem.LOGICAL for i in flat) else Elem.REAL + if any(i.elem is Elem.COMPLEX for i in flat): + elem = Elem.COMPLEX + if any(i.elem in (Elem.UNKNOWN, Elem.CHAR) for i in flat): + elem = Elem.UNKNOWN + facts: _Facts = { + "elem": elem, + "finite": all(i.finite for i in flat), + "nonneg": all(i.nonneg for i in flat), + "integer": all(i.integer for i in flat), + } + # Each row: horizontal concatenation; then the rows stack vertically. + row_shapes: list[tuple[int | None, int | None]] = [] + for row in infos: + heights = {i.rows for i in row} + if any(i.kind in (Kind.UNKNOWN, Kind.ARRAY, Kind.VECTOR, Kind.CELL) for i in row): + return array(None, None, **facts) + nonempty = [i for i in row if i.kind is not Kind.EMPTY] + if not nonempty: + row_shapes.append((0, 0)) + continue + heights = {i.rows for i in nonempty} + height = heights.pop() if len(heights) == 1 else None + widths = [i.cols for i in nonempty] + width = sum(w for w in widths if w is not None) if None not in widths else None + row_shapes.append((height, width)) + shapes = [s for s in row_shapes if s != (0, 0)] + if not shapes: + return array(0, 0, **facts) + widths_set = {w for _h, w in shapes} + width = widths_set.pop() if len(widths_set) == 1 else None + heights_list = [h for h, _w in shapes] + height = sum(h for h in heights_list if h is not None) if None not in heights_list else None + info = array(height, width, **facts) + if info.kind is Kind.SCALAR and len(flat) == 1: + return replace(flat[0], func=None) + return replace(info, int_dtype=all(i.int_dtype for i in flat)) + + def binop(self, op: str, a: Info, b: Info) -> Info: + if op in ir.COMPARISONS or op in ("and", "or"): + shape = broadcast(a, b) + return replace( + shape, elem=Elem.LOGICAL, finite=True, nonneg=True, integer=True, value=None + ) + if op in ("andand", "oror"): + return scalar(elem=Elem.LOGICAL, nonneg=True, integer=True) + elem = _numeric_elem(a, b) + if op == "mtimes" and not (a.is_scalar or b.is_scalar): + shape = matrix_product(a, b) + elif op == "mrdivide" and not b.is_scalar: + shape = array(a.rows, b.rows) if a.is_array and b.is_array else UNKNOWN + elif op == "mldivide" and not a.is_scalar: + shape = array(a.cols, b.cols) if a.is_array and b.is_array else UNKNOWN + elif op == "mpower" and not (a.is_scalar and b.is_scalar): + shape = a if a.is_matrix else UNKNOWN + else: + shape = broadcast(a, b) + if shape.kind is Kind.UNKNOWN: + return Info(elem=elem) + finite = a.finite and b.finite and op in ("plus", "minus", "times", "mtimes") + nonneg = False + integer = False + if op in ("plus", "times", "mtimes"): + nonneg = a.nonneg and b.nonneg + integer = a.integer and b.integer + elif op == "minus": + integer = a.integer and b.integer + elif op in ("rdivide", "mrdivide"): + nonneg = a.nonneg and b.nonneg + elif op in ("power", "mpower"): + even = b.value is not None and isinstance(b.value, int | float) and b.value % 2 == 0 + nonneg = a.nonneg or (even and a.is_real) + integer = a.integer and b.integer and b.nonneg + finite = a.finite and b.finite and b.nonneg and b.integer + value = _fold(op, a, b) if a.is_scalar and b.is_scalar else None + keeps_ints = op in ("plus", "minus", "times", "mtimes") or ( + op in ("power", "mpower") and b.integer and b.nonneg + ) + return replace( + shape, + elem=elem, + finite=finite, + nonneg=nonneg, + integer=integer, + value=value, + int_dtype=keeps_ints and a.int_dtype and b.int_dtype, + func=None, + ) + + def index(self, node: ir.Index, env: Env) -> Info: + target = self.expr(node.target, env) + subs = [self.expr(arg, env) for arg in node.args] + facts: _Facts = { + "elem": target.elem, + "finite": target.finite, + "nonneg": target.nonneg, + "integer": target.integer, + } + if target.kind is Kind.STRING: + if len(subs) == 1 and subs[0].is_scalar and not isinstance(node.args[0], ir.Colon): + return Info(kind=Kind.STRING, rows=1, cols=1, elem=Elem.CHAR) + return Info(kind=Kind.STRING, rows=1, elem=Elem.CHAR) + if len(node.args) == 1: + arg, sub = node.args[0], subs[0] + if isinstance(arg, ir.Colon): + return array(target.numel, 1, **facts) + if sub.is_scalar and not sub.is_logical: + return scalar(**facts) + if sub.is_logical: + if target.kind is Kind.ROW: + return array(1, None, kind=Kind.ROW, **facts) + if target.is_vector or target.is_matrix: + return array(None, 1, kind=Kind.COL, **facts) + return array(None, None, **facts) + count = sub.numel + if target.kind is Kind.COL: + return array(count, 1, kind=Kind.COL if count != 1 else None, **facts) + if target.kind is Kind.ROW: + return array(1, count, kind=Kind.ROW if count != 1 else None, **facts) + if target.is_matrix and sub.kind in (Kind.ROW, Kind.COL): + return array(sub.rows, sub.cols, **facts) + return array(None, None, **facts) + if len(node.args) == 2: + dims: list[int | None] = [] + for axis, (arg, sub) in enumerate(zip(node.args, subs, strict=True)): + extent = target.rows if axis == 0 else target.cols + if isinstance(arg, ir.Colon): + dims.append(extent) + elif sub.is_scalar and not sub.is_logical: + dims.append(1) + else: + dims.append(sub.numel if not sub.is_logical else None) + if target.kind is Kind.UNKNOWN: + if dims == [1, 1]: + return scalar(**facts) + return array(None, None, **facts) + kind = None + if dims[0] == 1 and dims[1] != 1: + kind = Kind.ROW + elif dims[1] == 1 and dims[0] != 1: + kind = Kind.COL + return array(dims[0], dims[1], kind=kind, **facts) + return array(None, None, **facts) + + def call(self, node: ir.Call, env: Env, *, nargout: int) -> Info: + args = [self.expr(arg, env) for arg in node.args] + name = node.func + if node.local: + self.call_sites.setdefault(name, []).append(args) + known = self.analysis.functions.get(name) + if known is not None: + known.call_counts.add(len(args)) + known.nargouts.add(nargout) + return known.outputs[0] if known.outputs else UNKNOWN + return UNKNOWN + if node.handle: + handle = env.get(name, UNKNOWN) + lam = handle.func + if lam is not None and len(lam.params) == len(args): + captured = handle.env or {} + # This call's result follows this call's arguments... + result = self.expr( + lam.body, {**captured, **dict(zip(lam.params, args, strict=True))} + ) + # ...but the lambda is translated once, so its body is annotated + # with the facts that hold for *every* call: a lambda called + # with a column and with a row has a vector of unknown + # orientation, and its translators must decline or assume out + # loud rather than follow whichever call came last. + seen = self.lambda_params.get(id(lam)) + joined = ( + args if seen is None else [join(a, b) for a, b in zip(seen, args, strict=True)] + ) + self.lambda_params[id(lam)] = joined + self.expr(lam.body, {**captured, **dict(zip(lam.params, joined, strict=True))}) + return result + return UNKNOWN + if not node.args and name in CONSTANTS: + return CONSTANTS[name] + if name in ("nargin", "nargout"): + return scalar(nonneg=True, integer=True) + first = args[0] if args else UNKNOWN + if name in ("zeros", "ones", "eye", "rand", "randn"): + return self.constructor(name, node.args, args) + if name == "linspace": + points: int | None = 100 + if len(args) >= 3: + points = int(args[2].value) if isinstance(args[2].value, int | float) else None + finite = all(a.finite for a in args[:2]) + if points == 1: + return scalar(finite=finite) + return array(1, points, finite=finite, kind=Kind.ROW) + if name in ("numel", "length", "ndims", "columns", "rows"): + count: int | None = None + if name == "numel": + count = first.numel + elif name == "length" and first.rows is not None and first.cols is not None: + count = max(first.rows, first.cols) if first.numel else 0 + return scalar(nonneg=True, integer=True, value=count) + if name == "size": + if len(args) >= 2: + axis = args[1].value + extent = first.rows if axis == 1 else first.cols if axis == 2 else None + return scalar(nonneg=True, integer=True, value=extent) + return array(1, 2, finite=True, nonneg=True, integer=True) + if name in ("isempty", "strcmp", "strcmpi", "isscalar", "isvector", "any", "all"): + if name in ("any", "all") and first.is_matrix: + return array(1, first.cols, elem=Elem.LOGICAL, finite=True, nonneg=True) + return scalar(elem=Elem.LOGICAL, nonneg=True, integer=True) + if name in ELEMENTWISE: + shape = broadcast(first, args[1]) if len(args) == 2 else first + if shape.kind is Kind.UNKNOWN: + return UNKNOWN + elem = Elem.LOGICAL if name in _LOGICAL_RESULT else Elem.REAL + if name in ("sqrt", "log", "log2", "log10", "asin", "acos") and not first.nonneg: + elem = Elem.UNKNOWN # may be complex + if first.elem is Elem.COMPLEX and name not in ("abs", "real", "imag", "isnan"): + elem = Elem.COMPLEX + value = None + if name == "abs" and isinstance(first.value, int | float): + value = abs(first.value) + return replace( + shape, + elem=elem, + finite=first.finite + and name not in ("exp", "log", "log2", "log10") + or name in _LOGICAL_RESULT, + nonneg=name in _NONNEG_RESULT or name in _LOGICAL_RESULT or first.nonneg, + integer=name in _INTEGER_RESULT or name in _LOGICAL_RESULT or first.integer, + value=value, + func=None, + ) + if name in _REDUCTIONS: + return self.reduction(name, node.args, args) + if name == "find": + limit = len(args) >= 2 + positions: _Facts = {"finite": True, "nonneg": True, "integer": True} + if first.kind is Kind.ROW: + return array(1, None, kind=Kind.ROW, **positions) + if first.is_array: + return array(None, 1, kind=Kind.COL if not limit else None, **positions) + return array(None, None, **positions) + if name == "xor": + return replace( + broadcast(first, args[1] if len(args) > 1 else UNKNOWN), elem=Elem.LOGICAL + ) + if name in ("num2str", "sprintf", "strcat", "upper", "lower", "strtrim"): + return Info(kind=Kind.STRING, rows=1, elem=Elem.CHAR) + if name in ("cumsum", "cumprod", "sort", "flip", "fliplr", "flipud", "diff"): + return replace(first, value=None, func=None) + return UNKNOWN + + def int_result(self, node: ir.Call, result: Info) -> bool: + """Whether the NumPy translation of a call may hold integers.""" + if node.local or node.handle: + return result.int_dtype + if node.func in ("find", "size", "numel", "length", "ndims", "nargin", "nargout"): + return True + if node.func in ("sum", "max", "min", "prod", "abs", "sign", "cumsum", "sort"): + return any(self.analysis.info(arg).int_dtype for arg in node.args[:2]) + return False + + def constructor(self, name: str, nodes: list[ir.Expr], args: list[Info]) -> Info: + dims: list[int | None] = [] + if len(args) == 1 and args[0].kind is Kind.ROW and args[0].cols == 2: + # zeros(size(A)): the dimensions of A, when the argument is size(A). + inner = nodes[0] + if isinstance(inner, ir.Call) and inner.func == "size" and len(inner.args) == 1: + source = self.analysis.info(inner.args[0]) + dims = [source.rows, source.cols] + else: + dims = [None, None] + else: + for arg in args: + if arg.kind is Kind.STRING: + continue + dims.append(int(arg.value) if isinstance(arg.value, int | float) else None) + if len(dims) == 1: + dims = [dims[0], dims[0]] + if not dims: + dims = [1, 1] + facts: _Facts = {"finite": True, "nonneg": name != "randn", "integer": name != "rand"} + if name in ("rand", "randn"): + facts["integer"] = False + rows, cols = dims[0], dims[1] if len(dims) > 1 else None + if rows != 1 and cols != 1 and not (len(args) == 1 and dims == [None, None]): + # zeros(m, n) with neither size known to be 1 is written as a 2-D + # array, so it is a matrix from here on. + return array(rows, cols, kind=Kind.MATRIX, **facts) + return array(rows, cols, **facts) + + def reduction(self, name: str, nodes: list[ir.Expr], args: list[Info]) -> Info: + if not args: + return UNKNOWN + first = args[0] + if name in ("max", "min") and len(args) == 2: + shape = broadcast(first, args[1]) + return replace( + shape, + elem=_numeric_elem(first, args[1]), + finite=first.finite and args[1].finite, + nonneg=first.nonneg or args[1].nonneg, + integer=first.integer and args[1].integer, + value=None, + ) + dim: int | None = None + dim_arg = 2 if name in ("max", "min") else 1 + if len(args) > dim_arg: + value = args[dim_arg].value + dim = int(value) if isinstance(value, int | float) else None + if dim is None: + return UNKNOWN + facts: _Facts = { + "elem": Elem.REAL if first.elem in (Elem.LOGICAL, Elem.CHAR) else first.elem, + "finite": first.finite and name != "prod", + "nonneg": first.nonneg, + "integer": first.integer and name != "mean", + } + if first.is_scalar: + return scalar(**facts) + if dim is None: + if first.is_vector: + return scalar(**facts) + if first.is_matrix: + return array(1, first.cols, kind=Kind.ROW, **facts) + return UNKNOWN + if first.is_matrix: + if dim == 1: + return array(1, first.cols, kind=Kind.ROW, **facts) + if dim == 2: + return array(first.rows, 1, kind=Kind.COL, **facts) + if first.kind is Kind.ROW: + return scalar(**facts) if dim == 2 else replace(first, value=None) + if first.kind is Kind.COL: + return scalar(**facts) if dim == 1 else replace(first, value=None) + return UNKNOWN + + +def matrix_product(a: Info, b: Info) -> Info: + """Shape of ``a * b`` for two non-scalars.""" + if not (a.is_array and b.is_array): + return UNKNOWN + if a.kind is Kind.ROW and b.kind is Kind.COL: + return scalar(finite=False) + rows = a.rows if a.kind is not Kind.VECTOR else None + cols = b.cols if b.kind is not Kind.VECTOR else None + if a.kind is Kind.COL: + rows = a.rows + if b.kind is Kind.ROW: + cols = b.cols + kind = _kind_of(rows, cols) + if kind is Kind.ARRAY: + if a.kind is Kind.COL and b.kind is Kind.ROW: + kind = Kind.MATRIX + elif a.is_matrix and b.kind is Kind.COL: + kind = Kind.COL + elif a.kind is Kind.ROW and b.is_matrix: + kind = Kind.ROW + elif a.is_matrix and b.is_matrix: + kind = Kind.MATRIX + return array(rows, cols, kind=kind) + + +def range_count( + start: float | complex | None, step: float | complex | None, stop: float | complex | None +) -> int | None: + """Number of elements of ``start:step:stop`` when all three are known reals. + + Uses a relative tolerance like the interpreter does, so ``0:0.1:1`` has 11 + elements even though ``(1 - 0) / 0.1`` is not exactly 10 in floating point. + """ + if not all(isinstance(v, int | float) for v in (start, step, stop)): + return None + assert isinstance(start, int | float) and isinstance(step, int | float) + assert isinstance(stop, int | float) + if step == 0 or (stop - start) / step < 0: + return 0 + span = (stop - start) / step + nearest = round(span) + if abs(span - nearest) <= 3 * 2.220446049250313e-16 * max(abs(span), 1): + return int(nearest) + 1 + return math.floor(span) + 1 + + +def index_may_grow(node: ir.Index, before: Info, analysis: Analysis) -> bool: + """Whether assigning through ``node`` may grow the array (needs a guided rule). + + True for a subscript that is ``end + k`` (k > 0), or a known number beyond + the known size of that dimension. A subscript that *might* be out of range + is not flagged: NumPy raises ``IndexError`` there, so a wrong guess fails + loudly instead of translating silently wrong. + + :param node: the indexed assignment target. + :param before: facts about the array before the assignment. + :param analysis: inference results (for constant subscripts). + """ + for dim, arg in enumerate(node.args): + if _is_end_plus(arg): + return True + value = analysis.info(arg).value + if not isinstance(value, int | float): + continue + if len(node.args) == 1: + limit = before.numel + else: + limit = before.rows if dim == 0 else before.cols if dim == 1 else 1 + if limit is not None and value > limit: + return True + return False + + +def _is_end_plus(arg: ir.Expr) -> bool: + """``end + k`` with positive ``k`` (either operand order).""" + if isinstance(arg, ir.BinOp) and arg.op == "plus": + pair = (arg.left, arg.right) + return any(isinstance(side, ir.End) for side in pair) and any( + isinstance(side, ir.Num) and isinstance(side.value, int | float) and side.value > 0 + for side in pair + ) + return False + + +def analyze(program: ir.Program) -> Analysis: + """Infer facts about every expression of ``program``. + + :param program: lowered source. + """ + return _Inferrer(program).run() diff --git a/dualect/ir.py b/dualect/ir.py new file mode 100644 index 0000000..e925b32 --- /dev/null +++ b/dualect/ir.py @@ -0,0 +1,586 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""The shared intermediate representation (docs/design.md section 5.1). + +The IR is deliberately small and **direction-neutral**: node kinds name what a +construct *means*, not how one language spells it, and every place where the two +languages disagree is an explicit field rather than an implicit convention: + +* :class:`Index` carries its ``base`` (1 for ``.m`` code, 0 for Python) and its + linear ``order`` (``"F"``, column-major, for ``.m`` code; ``"C"`` for NumPy). +* :class:`Range` carries ``inclusive`` (the ``.m`` colon includes its stop; + ``range``/``np.arange`` do not). +* Operators use the semantic names of the ``.m`` operator functions + (``mtimes`` is the matrix product, ``times`` is element-wise), so a Python + lowering maps ``@`` to ``mtimes`` and ``*`` to ``times``. +* :class:`End` is "the last index of the dimension being indexed", which a + Python lowering produces from ``-1`` and an ``.m`` emitter prints as ``end``. + +Milestone 4 lowers ``.m`` source into this IR (:mod:`dualect.lower`) and emits +Python from it (:mod:`dualect.emit`); milestone 5 adds a Python ``ast`` lowering +and an ``.m`` emitter over the same node kinds. + +Anything the IR cannot express is kept as an :class:`Opaque` expression or +:class:`OpaqueStmt` carrying a construct tag (see :mod:`dualect.constructs`), +so the scanner can name it and the translator refuses it instead of guessing. + +Nodes compare by identity (``eq=False``): analyses key their results on +``id(node)``, and two structurally equal expressions at different places are +different nodes. +""" + +from __future__ import annotations + +from dataclasses import dataclass, field + + +@dataclass(frozen=True) +class Loc: + """A source span: 1-based lines and columns, end exclusive. + + :param line: first line. + :param col: first column. + :param end_line: last line. + :param end_col: column just past the end. + """ + + line: int + col: int + end_line: int + end_col: int + + def __str__(self) -> str: + """Render as ``line:col``.""" + return f"{self.line}:{self.col}" + + +NO_LOC = Loc(0, 0, 0, 0) + + +@dataclass(eq=False) +class Node: + """Base of every IR node. + + :param loc: where the node came from in the source. + """ + + loc: Loc + + +# --- expressions ----------------------------------------------------------- + + +@dataclass(eq=False) +class Expr(Node): + """Base of expression nodes.""" + + +@dataclass(eq=False) +class Num(Expr): + """A numeric literal. + + :param text: the literal as written (``"1e-3"``, ``"2i"``). + :param value: its value; ``int`` when written without a fraction or + exponent, ``complex`` for an imaginary literal. + """ + + text: str + value: int | float | complex + + +@dataclass(eq=False) +class Str(Expr): + """A string literal (escapes already resolved). + + :param value: the characters. + :param quote: ``"'"`` (char array) or ``'"'`` (double-quoted). + """ + + value: str + quote: str = "'" + + +@dataclass(eq=False) +class Name(Expr): + """A bare identifier: a variable, or a function called without arguments. + + :param id: the identifier. + """ + + id: str + + +@dataclass(eq=False) +class Colon(Expr): + """A bare ``:`` subscript: every index along that dimension.""" + + +@dataclass(eq=False) +class End(Expr): + """``end`` inside a subscript: the last index of the dimension being indexed. + + :param target: the expression being indexed (``end`` binds to the innermost). + :param dim: 0-based position of the subscript this ``end`` appears in. + :param ndims: how many subscripts that index expression has (one means + linear indexing, where ``end`` is the element count). + """ + + target: Expr + dim: int + ndims: int + + +@dataclass(eq=False) +class Range(Expr): + """``start:stop`` or ``start:step:stop``. + + :param start: first value. + :param stop: the bound. + :param step: increment, or ``None`` for 1. + :param inclusive: whether ``stop`` itself is included when reached + (``True`` for ``.m`` ranges). + """ + + start: Expr + stop: Expr + step: Expr | None = None + inclusive: bool = True + + +@dataclass(eq=False) +class Matrix(Expr): + """A bracket literal ``[a b; c d]``: rows of elements, concatenated. + + :param rows: elements of each row; an empty list is ``[]``. + """ + + rows: list[list[Expr]] + + +@dataclass(eq=False) +class CellLit(Expr): + """A brace literal ``{a, b}`` (only lowered where it lists ``case`` values). + + :param items: the elements, row-major. + """ + + items: list[Expr] + + +@dataclass(eq=False) +class BinOp(Expr): + """A binary operator, by semantic name. + + :param op: one of :data:`BINARY_OPS`. + :param left: left operand. + :param right: right operand. + """ + + op: str + left: Expr + right: Expr + + +@dataclass(eq=False) +class UnOp(Expr): + """A prefix operator: ``uminus``, ``uplus`` or ``not``. + + :param op: the operator name. + :param operand: the operand. + """ + + op: str + operand: Expr + + +@dataclass(eq=False) +class Transpose(Expr): + """A transpose. + + :param operand: the transposed expression. + :param conjugate: ``True`` for the conjugate transpose (``'``). + """ + + operand: Expr + conjugate: bool + + +@dataclass(eq=False) +class Index(Expr): + """Indexing a variable with parentheses: ``x(i)``, ``A(i, j)``. + + :param target: the indexed expression (a :class:`Name` for ``.m`` code). + :param args: one subscript per dimension, or one for linear indexing. + :param base: the index base of the subscripts' values. + :param order: memory order of linear indexing (``"F"``: column-major). + """ + + target: Expr + args: list[Expr] + base: int = 1 + order: str = "F" + + +@dataclass(eq=False) +class Call(Expr): + """A function call. + + :param func: the function name as written in the source language. + :param args: the arguments. + :param local: ``True`` when the function is defined in the same file. + :param handle: ``True`` when ``func`` is a variable holding a function handle. + """ + + func: str + args: list[Expr] + local: bool = False + handle: bool = False + + +@dataclass(eq=False) +class Lambda(Expr): + """An anonymous function ``@(params) body``. + + :param params: parameter names. + :param body: the single expression it returns. + """ + + params: list[str] + body: Expr + + +@dataclass(eq=False) +class FuncRef(Expr): + """A handle to a named function, ``@sin``. + + :param name: the function name. + """ + + name: str + + +@dataclass(eq=False) +class Ignore(Expr): + """The ``~`` placeholder for a discarded output in ``[~, i] = f(x)``.""" + + +@dataclass(eq=False) +class Opaque(Expr): + """An expression the IR does not model (a cell index, a struct field, ...). + + :param construct: construct tag naming it, e.g. ``"expr:field"``. + :param text: the source text, for reports and LLM context. + """ + + construct: str + text: str + + +# --- statements ------------------------------------------------------------ + + +@dataclass(eq=False) +class Stmt(Node): + """Base of statement nodes. + + :param comment: a comment on the same line as the statement (without the + comment marker), or ``None``. + :param syntax: construct tags for surface syntax the statement used that + leaves no other trace in the IR (``"syntax:continuation"``, ...). + """ + + comment: str | None = field(default=None, kw_only=True) + syntax: list[str] = field(default_factory=list, kw_only=True) + + +@dataclass(eq=False) +class Assign(Stmt): + """``target = value`` or ``[t1, t2] = value``. + + :param targets: :class:`Name`, :class:`Index` or :class:`Ignore` nodes. + :param value: the right-hand side. + :param display: ``True`` when the statement is not terminated by ``;``, + so the ``.m`` side prints the result. + """ + + targets: list[Expr] + value: Expr + display: bool = False + + +@dataclass(eq=False) +class AugAssign(Stmt): + """``x += e`` and friends (``x++`` is ``x += 1``); ``.m`` code: Octave only. + + :param target: the updated variable or element. + :param op: binary operator name (``plus``, ``minus``, ``mtimes``, ...). + :param value: the right-hand side. + """ + + target: Expr + op: str + value: Expr + + +@dataclass(eq=False) +class ExprStmt(Stmt): + """An expression evaluated for its effect or its display. + + :param value: the expression. + :param display: ``True`` when not terminated by ``;``. + """ + + value: Expr + display: bool = False + + +@dataclass(eq=False) +class If(Stmt): + """``if`` / ``elseif`` / ``else``. + + :param branches: ``(condition, body)`` pairs in order. + :param orelse: the ``else`` body, or ``None``. + """ + + branches: list[tuple[Expr, list[Stmt]]] + orelse: list[Stmt] | None = None + + +@dataclass(eq=False) +class For(Stmt): + """``for var = iterable``: iterates over the *columns* of ``iterable``. + + :param var: the loop variable. + :param iterable: what it loops over. + :param body: the loop body. + """ + + var: Name + iterable: Expr + body: list[Stmt] + + +@dataclass(eq=False) +class While(Stmt): + """``while cond ... end``. + + :param cond: the condition, tested before each iteration. + :param body: the loop body. + """ + + cond: Expr + body: list[Stmt] + + +@dataclass(eq=False) +class DoUntil(Stmt): + """``do ... until cond`` (Octave only): the body runs at least once. + + :param body: the loop body. + :param cond: the exit condition, tested after each iteration. + """ + + body: list[Stmt] + cond: Expr + + +@dataclass(eq=False) +class Switch(Stmt): + """``switch`` / ``case`` / ``otherwise``. + + :param subject: the value being matched. + :param cases: ``(values, body)``: a case matches when any value matches. + :param otherwise: the ``otherwise`` body, or ``None``. + """ + + subject: Expr + cases: list[tuple[list[Expr], list[Stmt]]] + otherwise: list[Stmt] | None = None + + +@dataclass(eq=False) +class Break(Stmt): + """``break``.""" + + +@dataclass(eq=False) +class Continue(Stmt): + """``continue``.""" + + +@dataclass(eq=False) +class Return(Stmt): + """``return`` (leave the function; its outputs are returned as they stand).""" + + +@dataclass(eq=False) +class Command(Stmt): + """Command syntax, ``name word1 word2``: every word is a string argument. + + :param name: the command. + :param words: its arguments, as text. + """ + + name: str + words: list[str] + + +@dataclass(eq=False) +class Comment(Stmt): + """A comment on its own line(s). + + :param text: the comment text without markers; several lines for a block. + :param block: ``True`` for a ``%{ ... %}`` block. + """ + + text: str + block: bool = False + + +@dataclass(eq=False) +class FunctionDef(Stmt): + """``function [outs] = name(params) ... end``. + + :param name: the function name. + :param params: parameter names (``varargin`` included as written). + :param outputs: output variable names (``varargout`` included as written). + :param body: the statements. + """ + + name: str + params: list[str] + outputs: list[str] + body: list[Stmt] + + +@dataclass(eq=False) +class OpaqueStmt(Stmt): + """A statement the IR does not model, or a region the parser could not read. + + :param construct: construct tag naming it (``"parse:error"`` for unparsed text). + :param text: the source text. + """ + + construct: str + text: str + + +@dataclass(eq=False) +class Program(Node): + """A whole source file. + + :param body: top-level statements, including function definitions. + :param source_name: file name, for reports. + """ + + body: list[Stmt] + source_name: str = "" + + +#: Binary operator names (the ``.m`` operator-function names, which are also +#: the construct tags ``op:``). +BINARY_OPS = frozenset( + { + "plus", "minus", "mtimes", "times", "mrdivide", "rdivide", "mldivide", "ldivide", + "mpower", "power", "eq", "ne", "lt", "le", "gt", "ge", "and", "or", "andand", "oror", + } +) # fmt: skip + +COMPARISONS = frozenset({"eq", "ne", "lt", "le", "gt", "ge"}) + + +def child_exprs(node: Expr) -> list[Expr]: + """Return the direct sub-expressions of an expression, in source order. + + :param node: any expression. + """ + match node: + case End(): + # Its target is a back-reference for analysis, not a child: walking + # into it would visit the indexed expression twice. + return [] + case Range(start=start, stop=stop, step=step): + return [start, step, stop] if step is not None else [start, stop] + case Matrix(rows=rows): + return [item for row in rows for item in row] + case CellLit(items=items): + return list(items) + case BinOp(left=left, right=right): + return [left, right] + case UnOp(operand=operand) | Transpose(operand=operand): + return [operand] + case Index(target=target, args=args): + return [target, *args] + case Call(args=args): + return list(args) + case Lambda(body=body): + return [body] + return [] + + +def walk_expr(node: Expr) -> list[Expr]: + """Return ``node`` and every expression below it, pre-order. + + :param node: the root expression. + """ + found = [node] + for child in child_exprs(node): + found.extend(walk_expr(child)) + return found + + +def stmt_exprs(stmt: Stmt) -> list[Expr]: + """Return the expressions that belong to a statement itself (not its body). + + For compound statements this is the header: the ``if``/``while`` + conditions, the ``for`` iterable, the ``switch`` subject and case values. + + :param stmt: any statement. + """ + match stmt: + case Assign(targets=targets, value=value): + return [*targets, value] + case AugAssign(target=target, value=value): + return [target, value] + case ExprStmt(value=value): + return [value] + case If(branches=branches): + return [cond for cond, _body in branches] + case For(var=var, iterable=iterable): + return [var, iterable] + case While(cond=cond) | DoUntil(cond=cond): + return [cond] + case Switch(subject=subject, cases=cases): + return [subject, *(value for values, _body in cases for value in values)] + return [] + + +def stmt_bodies(stmt: Stmt) -> list[list[Stmt]]: + """Return the nested statement lists of a compound statement. + + :param stmt: any statement. + """ + match stmt: + case If(branches=branches, orelse=orelse): + bodies = [body for _cond, body in branches] + return bodies + ([orelse] if orelse is not None else []) + case For(body=body) | While(body=body) | DoUntil(body=body) | FunctionDef(body=body): + return [body] + case Switch(cases=cases, otherwise=otherwise): + bodies = [body for _values, body in cases] + return bodies + ([otherwise] if otherwise is not None else []) + return [] + + +def walk_stmts(body: list[Stmt]) -> list[Stmt]: + """Return every statement in ``body`` and below, pre-order. + + :param body: a statement list. + """ + found: list[Stmt] = [] + for stmt in body: + found.append(stmt) + for inner in stmt_bodies(stmt): + found.extend(walk_stmts(inner)) + return found diff --git a/dualect/lift.py b/dualect/lift.py new file mode 100644 index 0000000..656ef76 --- /dev/null +++ b/dualect/lift.py @@ -0,0 +1,719 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Lifting Python source into the IR (the Python -> ``.m`` direction). + +This is the mirror of :mod:`dualect.lower` plus :mod:`dualect.emit`: it parses +Python with the stdlib :mod:`ast`, infers facts (:mod:`dualect.pyinfer`), tags +every statement's constructs (:mod:`dualect.pyconstructs`), plans each +statement and lifts it into the shared IR with ``.m`` semantics, which +:mod:`dualect.memit` prints. + +The rule knowledge is the same rule folders as the other direction. A rule +covers Python constructs through ``from_python: {status, match}`` in its +``rule.yaml``, and its ``translate.py`` defines ``lift(node, ctx)`` (and +optionally ``lift_store``, ``lift_multi``) that turns a Python node into IR +through the :class:`LiftContext`. Planning is per statement, as in the other +direction: every construct must map to a rule that is ``mechanical`` *from +Python*, else the statement becomes a hole (a ``TODO(dualect)`` comment and an +``error(...)`` call, so the ``.m`` output can never run past it); a lift that +meets a form it cannot translate correctly raises :class:`~dualect.emit.Decline`. + +What lives here rather than in a rule is what every rule shares: names, +numbers and plain assignment, comments, and NumPy's *aliasing*: ``y = x``, +a slice and ``.T`` share memory in NumPy, so writing into one changes the +other, while the ``.m`` side always copies. A statement whose meaning depends +on that sharing is declined, never translated as if it did not exist. +""" + +from __future__ import annotations + +import ast +import io +import tokenize +from collections.abc import Callable, Iterator +from contextlib import contextmanager +from dataclasses import dataclass, field +from types import ModuleType +from typing import NoReturn + +from dualect import ir +from dualect.emit import Decline, StmtReport +from dualect.errors import DualectError, RuleError +from dualect.memit import HOLE +from dualect.pyconstructs import PyUse, Tagger, loc_of +from dualect.pyinfer import PyAnalysis, PyInfo, PyKind, analyze_python +from dualect.rulebook import FROM_PYTHON, Rule, Status +from dualect.scan import Finding + +#: Comment directives the verify harness reads; they are never copied over, +#: because their meaning (a 0-based position) belongs to the source pairing. +_DIRECTIVE_PREFIX = "dualect:" + + +class PyRuleIndex: + """Maps ``py:`` construct tags to the rule covering them (``from_python.match``).""" + + def __init__(self, *, rules: list[Rule]) -> None: + """Index the rules' Python tags. + + :param rules: all loaded rules. + :raises RuleError: when two rules claim the same Python tag. + """ + self.by_tag: dict[str, Rule] = {} + self.by_id: dict[str, Rule] = {rule.id: rule for rule in rules} + for rule in rules: + for tag in rule.python_match: + other = self.by_tag.get(tag) + if other is not None: + raise RuleError(f"{rule.id} and {other.id} both match {tag!r} from Python") + self.by_tag[tag] = rule + + def rule_for(self, tag: str) -> Rule | None: + """The rule covering ``tag``, or ``None``.""" + return self.by_tag.get(tag) + + +@dataclass +class ScopeInfo: + """Names of one Python scope (the module, or a ``def``). + + :param variables: names assigned in the scope (parameters included). + :param mutated: names written into in place (``x[i] = v``, ``x += v`` on + an array, in-place methods). + :param params: the parameters of a ``def``. + """ + + variables: set[str] = field(default_factory=set) + mutated: set[str] = field(default_factory=set) + params: list[str] = field(default_factory=list) + + +class LiftContext: + """What a rule's ``lift`` works with while lifting one statement.""" + + def __init__( + self, + *, + module: ast.Module, + text: str, + analysis: PyAnalysis, + index: PyRuleIndex, + translator_for: Callable[[str], ModuleType | None], + ) -> None: + self.module = module + self.analysis = analysis + self.index = index + self._translator_for = translator_for + self.functions: dict[str, ast.FunctionDef] = { + s.name: s for s in module.body if isinstance(s, ast.FunctionDef) + } + self.tagger = Tagger(analysis=analysis, functions=set(self.functions)) + self.source_lines = text.splitlines() + self.comments, self.standalone = _comments(text) + self.reports: list[StmtReport] = [] + self.findings: list[Finding] = [] + self.uses_by_stmt: dict[int, list[Finding]] = {} + self.assumptions: list[str] = [] + self.scope = scope_info(module.body, params=[]) + self.module_scope = self.scope + self.in_condition = False + self.function: ast.FunctionDef | None = None + self.outputs: list[str] = [] + self.loop_depth = 0 + self._used_comments: set[int] = set() + self._plan(module.body) + + # --- planning ----------------------------------------------------------- + + def _plan(self, body: list[ast.stmt]) -> None: + for stmt in body: + uses = self.tagger.statement_uses(stmt) + if stmt.lineno in self.comments and not _is_directive(self.comments[stmt.lineno]): + uses.append(PyUse("py:comment", loc_of(stmt))) + found = [ + Finding( + tag=use.tag, + loc=use.loc, + rule=self.index.rule_for(use.tag), + text=self.excerpt(use.loc) if self.index.rule_for(use.tag) is None else "", + direction=FROM_PYTHON, + ) + for use in _dedupe(uses) + ] + self.uses_by_stmt[id(stmt)] = found + self.findings.extend(found) + for inner in _bodies(stmt): + self._plan(inner) + + def excerpt(self, loc: ir.Loc) -> str: + """The first source line of a span, trimmed, for reports.""" + if not 1 <= loc.line <= len(self.source_lines): + return "" + line = self.source_lines[loc.line - 1] + end = loc.end_col - 1 if loc.end_line == loc.line else len(line) + snippet = line[max(loc.col - 1, 0) : end].strip() or line.strip() + return snippet if len(snippet) <= 48 else snippet[:45] + "..." + + # --- facts and helpers for rules ---------------------------------------- + + def info(self, node: ast.AST) -> PyInfo: + """Inferred facts about a Python expression.""" + return self.analysis.info(node) + + @staticmethod + def loc(node: ast.AST) -> ir.Loc: + """The IR location of a Python node.""" + return loc_of(node) + + def assume(self, text: str) -> None: + """Record an assumption; it is printed as ``% dualect: assumed ...``.""" + if text not in self.assumptions: + self.assumptions.append(text) + + @staticmethod + def decline(reason: str) -> NoReturn: + """Give up on this statement; it becomes a guided hole.""" + raise Decline(reason) + + def module_for(self, rule_id: str) -> ModuleType: + """Another rule's translator, for its helpers; only when it is mechanical from Python.""" + rule = self.index.by_id.get(rule_id) + module = self._translator_for(rule_id) + if rule is None or rule.python_status is not Status.MECHANICAL or module is None: + tag = rule.python_match[0] if rule is not None and rule.python_match else rule_id + raise _Unsupported(tag, rule) + return module + + def tag(self, node: ast.AST) -> str | None: + """The primary construct tag of a Python expression.""" + return self.tagger.primary(node) + + @property + def numpy(self) -> str | None: + """The name numpy is imported as.""" + return self.analysis.numpy_alias + + # --- IR constructors ------------------------------------------------------- + + @staticmethod + def num(value: int | float, *, loc: ir.Loc = ir.NO_LOC) -> ir.Expr: + """A numeric literal (a negative one as a unary minus).""" + if value < 0: + return ir.UnOp(loc=loc, op="uminus", operand=LiftContext.num(-value, loc=loc)) + text = str(value) if isinstance(value, int) else repr(value) + return ir.Num(loc=loc, text=text, value=value) + + def call(self, func: str, *args: ir.Expr, loc: ir.Loc = ir.NO_LOC) -> ir.Call: + """A call of a built-in. + + A variable of the same name would shadow the function on the ``.m`` + side (``max = 3; max(x)`` indexes the variable), so that is declined. + """ + if func in self.scope.variables or func in self.module_scope.variables: + self.decline(f"a variable named {func} would hide the function {func}()") + return ir.Call(loc=loc, func=func, args=list(args)) + + def condition(self, node: ast.expr) -> ir.Expr: + """Lift an ``if``/``while`` test: only its truth matters there. + + ``a and b`` is a value in Python (one of the operands); in a condition + only its truth is used, which is what ``&&`` gives. + """ + saved = self.in_condition + self.in_condition = True + try: + return self.expr(node) + finally: + self.in_condition = saved + + @staticmethod + def binop(op: str, left: ir.Expr, right: ir.Expr, *, loc: ir.Loc = ir.NO_LOC) -> ir.Expr: + """A binary operation.""" + return ir.BinOp(loc=loc, op=op, left=left, right=right) + + @staticmethod + def transpose(node: ir.Expr) -> ir.Expr: + """``x.'``; a transpose of a transpose cancels.""" + if isinstance(node, ir.Transpose) and not node.conjugate: + return node.operand + return ir.Transpose(loc=node.loc, operand=node, conjugate=False) + + @staticmethod + def shift(node: ir.Expr, delta: int) -> ir.Expr: + """``node + delta`` with integer literals folded (``(k - 1) + 1`` is ``k``).""" + if delta == 0: + return node + if isinstance(node, ir.Num) and isinstance(node.value, int): + return LiftContext.num(node.value + delta, loc=node.loc) + if ( + isinstance(node, ir.UnOp) + and node.op == "uminus" + and isinstance(node.operand, ir.Num) + and isinstance(node.operand.value, int) + ): + return LiftContext.num(-node.operand.value + delta, loc=node.loc) + if ( + isinstance(node, ir.BinOp) + and node.op in ("plus", "minus") + and isinstance(node.right, ir.Num) + and isinstance(node.right.value, int) + ): + carried = node.right.value if node.op == "plus" else -node.right.value + return LiftContext.shift(node.left, carried + delta) + op = "plus" if delta > 0 else "minus" + return ir.BinOp(loc=node.loc, op=op, left=node, right=LiftContext.num(abs(delta))) + + # --- dispatch ---------------------------------------------------------------- + + def expr(self, node: ast.expr) -> ir.Expr: + """Lift a Python expression into the IR.""" + saved = self.in_condition + # Only `and`/`or`/`not` pass the condition context on to their operands. + boolean = isinstance(node, ast.BoolOp) or ( + isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.Not) + ) + self.in_condition = saved and boolean + try: + return self._expr(node) + finally: + self.in_condition = saved + + def _expr(self, node: ast.expr) -> ir.Expr: + loc = loc_of(node) + match node: + case ast.Constant(value=value) if isinstance(value, bool): + return ir.Call(loc=loc, func="true" if value else "false", args=[]) + case ast.Constant(value=value) if isinstance(value, int | float): + return self.num(value, loc=loc) + case ast.Name(id=name): + if name in self.functions and name not in self.scope.variables: + return ir.FuncRef(loc=loc, name=name) + return ir.Name(loc=loc, id=name) + case ast.Call(func=ast.Attribute(attr="copy", value=inner)) if not node.args: + # Every .m value is a private copy already. + return self.expr(inner) + tag = self.tag(node) + if tag is None: + self.decline(f"no translation for {type(node).__name__}") + result = self._lifter(tag).lift(node, self) + if not isinstance(result, ir.Expr): + self.decline(f"{tag} did not give an expression") + return result + + def _lifter(self, tag: str) -> ModuleType: + rule = self.index.rule_for(tag) + if rule is None or rule.python_status is not Status.MECHANICAL: + raise _Unsupported(tag, rule) + module = self._translator_for(rule.id) + if module is None or not callable(getattr(module, "lift", None)): + raise _Unsupported(tag, rule) + return module + + # --- statements ---------------------------------------------------------------- + + def block(self, body: list[ast.stmt]) -> list[ir.Stmt]: + """Lift a statement list, with the comments that sit between its statements.""" + lifted: list[ir.Stmt] = [] + for stmt in body: + lifted.extend(self.comments_before(stmt.lineno)) + lifted.extend(self.statement(stmt)) + return lifted + + def comments_before(self, line: int) -> list[ir.Stmt]: + """Own-line comments above ``line`` that were not placed yet.""" + found: list[ir.Stmt] = [] + for number in sorted(self.standalone): + if number >= line: + break + if number in self._used_comments: + continue + self._used_comments.add(number) + text = self.standalone[number] + if _is_directive(text): + continue + comment = ir.Comment(loc=ir.Loc(number, 1, number, 1), text=text) + comment.syntax.append("syntax:comment") + found.append(comment) + return found + + def statement(self, stmt: ast.stmt) -> list[ir.Stmt]: + """Lift one statement, or a hole for it.""" + findings = self.uses_by_stmt.get(id(stmt), []) + rules = sorted({f.rule.id for f in findings if f.rule is not None}) + report = StmtReport( + loc=loc_of(stmt), kind=type(stmt).__name__, rules=rules, status=Status.MECHANICAL + ) + self.reports.append(report) + blocking = [f for f in findings if f.status is not Status.MECHANICAL] + if blocking: + worst = next((f for f in blocking if f.unsupported), blocking[0]) + report.status = worst.status + report.reason = "needs " + ", ".join( + dict.fromkeys( + f"{f.tag} ({f.rule.id if f.rule is not None else 'no rule'})" for f in blocking + ) + ) + return self.hole(stmt, report) + outer = self.assumptions + self.assumptions = [] + mark = len(self.reports) + used = set(self._used_comments) + try: + lifted = self.translate_statement(stmt) + except Decline as exc: + del self.reports[mark:] + self._used_comments = used + report.status = Status.GUIDED + report.reason = f"translator declined: {exc.reason}" + return self.hole(stmt, report) + except _Unsupported as exc: + del self.reports[mark:] + self._used_comments = used + status = Status.UNSUPPORTED + if exc.rule is not None and exc.rule.python_status is not None: + status = exc.rule.python_status + report.status = status + label = exc.rule.id if exc.rule is not None else "no rule" + report.reason = f"{exc.tag} ({label})" + return self.hole(stmt, report) + finally: + mine = self.assumptions + self.assumptions = outer + notes = [] + comment = self.comments.get(getattr(stmt, "end_lineno", None) or stmt.lineno) + if comment is None: + comment = self.comments.get(stmt.lineno) + if comment is not None and not _is_directive(comment): + notes.append(comment) + if mine: + notes.append(f"dualect: assumed {'; '.join(mine)}") + if notes: + target = next((s for s in lifted if not isinstance(s, ir.Comment)), None) + if target is not None: + if isinstance(stmt, ast.FunctionDef | ast.For | ast.While | ast.If | ast.Match): + target.comment = "; ".join(notes) + else: + last = [s for s in lifted if not isinstance(s, ir.Comment)][-1] + last.comment = "; ".join(notes) + return lifted + + def translate_statement(self, stmt: ast.stmt) -> list[ir.Stmt]: + """Lift a statement whose constructs are all mechanical from Python.""" + loc = loc_of(stmt) + match stmt: + case ast.Assign(targets=[target], value=value): + return self.assignment(stmt, target, value) + case ast.Expr(value=ast.Constant(value=str() as text)): + return [ir.Comment(loc=loc, text=line.strip()) for line in text.strip().split("\n")] + case ast.Expr(value=value): + return [ir.ExprStmt(loc=loc, value=self.expr(value))] + case ast.Import() | ast.Pass(): + return [] + tag = _statement_tag(stmt) + if tag is None: + self.decline(f"no translation for {type(stmt).__name__}") + result = self._lifter(tag).lift(stmt, self) + if not isinstance(result, list): + self.decline(f"{tag} did not give statements") + return result + + def assignment(self, stmt: ast.Assign, target: ast.expr, value: ast.expr) -> list[ir.Stmt]: + """Plain assignment; stores and unpacking go to their rules.""" + loc = loc_of(stmt) + if isinstance(target, ast.Subscript): + return self._lifter("py:assign-store").lift_store(stmt, self) + if isinstance(target, ast.Tuple | ast.List): + return self._lifter("py:assign-multi").lift_multi(stmt, self) + if not isinstance(target, ast.Name): + self.decline("assignment to this target") + self.check_alias(target.id, value) + if self.info(value).kind is PyKind.LIST: + self.decline("a Python list (lists grow and nest; .m arrays do not)") + if isinstance(value, ast.Call): + tag = self.tag(value) + rule = self.index.rule_for(tag) if tag is not None else None + module = self._translator_for(rule.id) if rule is not None else None + mechanical = rule is not None and rule.python_status is Status.MECHANICAL + hook = getattr(module, "lift_assign", None) if mechanical else None + if hook is not None: + lifted = hook(stmt, self) + if lifted is not None: + return list(lifted) + rhs = self.expr(value) + if isinstance(rhs, ir.Name) and rhs.id == target.id: + return [] # `x = x.copy()`: the .m side copies anyway + return [ir.Assign(loc=loc, targets=[ir.Name(loc=loc_of(target), id=target.id)], value=rhs)] + + def check_alias(self, name: str, value: ast.expr) -> None: + """Decline ``name = value`` when NumPy would share memory that is later written. + + ``y = x``, ``y = x[1:3]`` and ``y = x.T`` bind views of ``x``: writing + into ``y`` changes ``x`` and vice versa, which the ``.m`` copy cannot do. + """ + info = self.info(value) + # A bare name of an array binds the same array; a slice or .T is a view. + if not ( + info.view + or ( + isinstance(value, ast.Name) + and info.kind is not PyKind.SCALAR + and info.kind is not PyKind.STRING + and info.kind is not PyKind.FUNC + ) + ): + return + root = view_root(value) + written = self.scope.mutated + if name in written or (root is not None and root in written): + self.decline(f"{name} shares memory with {root or 'another array'}, which is written") + + # --- holes ------------------------------------------------------------------------ + + def hole(self, stmt: ast.stmt, report: StmtReport) -> list[ir.Stmt]: + """A placeholder that names the gap and stops the ``.m`` script there.""" + loc = loc_of(stmt) + lines = [ + f"% TODO(dualect): {report.status.value}, {report.reason}", + f"% line {loc.line} of the source:", + ] + last = min(max(loc.end_line, loc.line), len(self.source_lines)) + for number in range(loc.line, last + 1): + lines.append(f"% {self.source_lines[number - 1].rstrip()}") + self._used_comments.add(number) + message = f"dualect: line {loc.line} was not translated ({report.status.value})" + lines.append(f"error({message!r});".replace('"', "'")) + return [ir.OpaqueStmt(loc=loc, construct=HOLE, text="\n".join(lines))] + + # --- scopes ------------------------------------------------------------------------- + + @contextmanager + def function_scope(self, fdef: ast.FunctionDef, outputs: list[str]) -> Iterator[ScopeInfo]: + """Lift inside a ``def``: its own names and output variables.""" + saved = (self.scope, self.function, self.outputs) + self.scope = scope_info(fdef.body, params=[a.arg for a in fdef.args.args]) + self.function = fdef + self.outputs = outputs + try: + yield self.scope + finally: + self.scope, self.function, self.outputs = saved + + @contextmanager + def loop(self) -> Iterator[None]: + """Track loop nesting.""" + self.loop_depth += 1 + try: + yield + finally: + self.loop_depth -= 1 + + +class _Unsupported(Exception): + """A construct with no mechanical (from Python) rule was reached while lifting.""" + + def __init__(self, tag: str, rule: Rule | None) -> None: + self.tag = tag + self.rule = rule + super().__init__(tag) + + +_STATEMENT_TAGS: dict[type, str] = { + ast.For: "py:for", + ast.While: "py:while", + ast.If: "py:if", + ast.Match: "py:match", + ast.Break: "py:break", + ast.Continue: "py:continue", + ast.FunctionDef: "py:def", + ast.Return: "py:return", + ast.AugAssign: "py:augassign", +} + + +def _statement_tag(stmt: ast.stmt) -> str | None: + return _STATEMENT_TAGS.get(type(stmt)) + + +def _bodies(stmt: ast.stmt) -> list[list[ast.stmt]]: + match stmt: + case ast.For(body=body, orelse=orelse) | ast.While(body=body, orelse=orelse): + return [body, orelse] + case ast.If(body=body, orelse=orelse): + return [body, orelse] + case ast.FunctionDef(body=body): + return [body] + case ast.Match(cases=cases): + return [case.body for case in cases] + case ast.With(body=body): + return [body] + case ast.Try(body=body, orelse=orelse, finalbody=final, handlers=handlers): + return [body, orelse, final, *(h.body for h in handlers)] + return [] + + +def _dedupe(uses: list[PyUse]) -> list[PyUse]: + return list(dict.fromkeys(uses)) + + +def _is_directive(text: str) -> bool: + return text.strip().startswith(_DIRECTIVE_PREFIX) + + +def _comments(text: str) -> tuple[dict[int, str], dict[int, str]]: + """Trailing comments by line, and own-line comments by line.""" + trailing: dict[int, str] = {} + standalone: dict[int, str] = {} + lines = text.splitlines() + try: + tokens = list(tokenize.generate_tokens(io.StringIO(text).readline)) + except (tokenize.TokenError, SyntaxError): + return trailing, standalone + for token in tokens: + if token.type != tokenize.COMMENT: + continue + line, col = token.start + body = token.string[1:] + body = body[1:] if body.startswith(" ") else body + if lines[line - 1][:col].strip(): + trailing[line] = body + elif not (line == 1 and body.startswith("!")): + standalone[line] = body + return trailing, standalone + + +def view_root(node: ast.expr) -> str | None: + """The variable a view expression shares memory with (``x`` of ``x[1:3].T``).""" + while True: + match node: + case ast.Name(id=name): + return name + case ast.Subscript(value=inner) | ast.Attribute(value=inner): + node = inner + case ast.Call(func=ast.Attribute(attr="ravel" | "reshape" | "conj", value=inner)): + node = inner + case _: + return None + + +_IN_PLACE_METHODS = frozenset({"sort", "fill", "resize", "itemset", "put", "append", "extend"}) + + +def scope_info(body: list[ast.stmt], *, params: list[str]) -> ScopeInfo: + """Names assigned and written in place in one scope (nested ``def`` bodies excluded).""" + info = ScopeInfo(variables=set(params), params=list(params)) + for stmt in _scope_statements(body): + if isinstance(stmt, ast.Assign): + for target in stmt.targets: + for name_node in ast.walk(target): + if isinstance(name_node, ast.Name) and isinstance(target, ast.Name | ast.Tuple): + info.variables.add(name_node.id) + if isinstance(target, ast.Subscript): + root = view_root(target.value) + if root is not None: + info.mutated.add(root) + elif isinstance(stmt, ast.AugAssign): + if isinstance(stmt.target, ast.Subscript): + root = view_root(stmt.target.value) + if root is not None: + info.mutated.add(root) + elif isinstance(stmt.target, ast.Name): + info.variables.add(stmt.target.id) + info.mutated.add(stmt.target.id) # in place when it is an array + elif isinstance(stmt, ast.For): + for name_node in ast.walk(stmt.target): + if isinstance(name_node, ast.Name): + info.variables.add(name_node.id) + for node in ast.walk(stmt) if not isinstance(stmt, ast.FunctionDef) else []: + if ( + isinstance(node, ast.Call) + and isinstance(node.func, ast.Attribute) + and node.func.attr in _IN_PLACE_METHODS + ): + root = view_root(node.func.value) + if root is not None: + info.mutated.add(root) + return info + + +def _scope_statements(body: list[ast.stmt]) -> list[ast.stmt]: + found: list[ast.stmt] = [] + for stmt in body: + if isinstance(stmt, ast.FunctionDef): + continue + found.append(stmt) + for inner in _bodies(stmt): + found.extend(_scope_statements(inner)) + return found + + +@dataclass +class Lifted: + """The result of lifting one Python file. + + :param body: the IR statements (holes included). + :param reports: one report per statement. + :param findings: every construct use. + :param context: the context the lift ran in. + """ + + body: list[ir.Stmt] + reports: list[StmtReport] + findings: list[Finding] + context: LiftContext + + +def lift_python( + *, text: str, name: str, rules: list[Rule], translator_for: Callable[[str], ModuleType | None] +) -> Lifted: + """Parse, analyse, plan and lift Python source. + + :param text: the source. + :param name: its file name, for reports. + :param rules: all loaded rules. + :param translator_for: rule id -> its translator module. + :raises PythonSyntaxError: when the text is not valid Python. + """ + module = parse_python(text=text, name=name) + analysis = analyze_python(module) + ctx = LiftContext( + module=module, + text=text, + analysis=analysis, + index=PyRuleIndex(rules=rules), + translator_for=translator_for, + ) + body = ctx.block(module.body) + body.extend(ctx.comments_before(len(ctx.source_lines) + 1)) + return Lifted(body=body, reports=ctx.reports, findings=ctx.findings, context=ctx) + + +def plan_python(*, text: str, name: str, rules: list[Rule]) -> list[Finding]: + """The construct uses of Python source, resolved to rules (no lifting). + + :param text: the source. + :param name: file name for reports. + :param rules: all loaded rules. + :raises DualectError: when the text is not valid Python. + """ + module = parse_python(text=text, name=name) + ctx = LiftContext( + module=module, + text=text, + analysis=analyze_python(module), + index=PyRuleIndex(rules=rules), + translator_for=lambda _rule_id: None, + ) + return ctx.findings + + +def parse_python(*, text: str, name: str) -> ast.Module: + """Parse Python source, reporting a syntax error as a :class:`PythonSyntaxError`.""" + try: + return ast.parse(text, filename=name) + except SyntaxError as exc: + raise PythonSyntaxError(f"{name}:{exc.lineno}: {exc.msg}") from exc + + +class PythonSyntaxError(DualectError): + """The Python source could not be parsed.""" diff --git a/dualect/llmstxt.py b/dualect/llmstxt.py new file mode 100644 index 0000000..eef40ab --- /dev/null +++ b/dualect/llmstxt.py @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Generating ``llms.txt``: every rule in one line (docs/design.md section 6). + +``llms.txt`` is the index an LLM reads first: it names each rule, says what it +covers and how far it is automated in each direction, and points at the +folder with the full knowledge (``rule.yaml``) and the verified cases. It is +generated from the rule folders (``dualect llms-txt -o llms.txt``) and a test +fails when the committed file is stale. +""" + +from dualect.rulebook import Rule + +HEADER = """\ +# dualect + +> Translates numeric code between .m files (Octave/MATLAB style) and Python/NumPy +> in both directions, one tested rule per construct, and verifies every +> translation by running both sides. + +Each rule lives in `rules///`: `rule.yaml` explains the +difference between the languages (`why`, `pitfalls`) for a human or an LLM, +`translate.py` holds the deterministic translators, and `cases/` holds `.m` / +`.py` pairs that run in both languages. A rule's status is given per direction: +`mechanical` (translated by its `translate.py`, every case verified), `guided` +(an LLM applies the rule; the result is verified) or `unsupported`. Use +`dualect scan FILE` for the rules a file needs and `dualect context FILE` for +them as prompt context; the MCP server (`dualect mcp`) offers the same as tools. +Generated by `dualect llms-txt`; do not edit by hand. + +## Rules + +""" + + +def rule_line(rule: Rule) -> str: + """One rule as a single Markdown list item.""" + reverse = rule.python_status.value if rule.python_status is not None else "n/a" + title = " ".join(rule.title.split()) + return ( + f"- [{rule.id}](rules/{rule.id}/rule.yaml): {title} " + f"(.m to Python: {rule.status.value}; Python to .m: {reverse}; " + f"{len(rule.cases)} case{'s' if len(rule.cases) != 1 else ''})" + ) + + +def render_llms_txt(*, rules: list[Rule]) -> str: + """The whole file for the given rules (sorted by id). + + :param rules: all loaded rules. + """ + lines = [rule_line(rule) for rule in sorted(rules, key=lambda r: r.id)] + return HEADER + "\n".join(lines) + "\n" diff --git a/dualect/lower.py b/dualect/lower.py new file mode 100644 index 0000000..21ed195 --- /dev/null +++ b/dualect/lower.py @@ -0,0 +1,828 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Lowering a tree-sitter ``.m`` syntax tree into the IR (:mod:`dualect.ir`). + +Three things happen here that the grammar alone does not do: + +* **Name resolution.** ``f(x)`` is an index when ``f`` is a variable and a call + otherwise. A name counts as a variable in a scope when that scope assigns it + anywhere (or it is a parameter or output); this is how ``.m`` code is + written in practice, and it is checked by verification like everything else. +* **Operator precedence.** The grammar nests some operator chains wrongly: + ``-2 ^ 2`` as ``(-2) ^ 2`` and ``a == b & c`` as ``a == (b & c)``. Every chain + of prefix, binary and postfix operators is therefore flattened and rebuilt + here with the documented precedence (see :data:`_BINDING`). +* **Honest gaps.** Constructs the IR does not model become :class:`~ir.Opaque` + or :class:`~ir.OpaqueStmt` nodes with a construct tag, and text the grammar + could not parse becomes ``parse:error``. Nothing is silently dropped. +""" + +import re +from dataclasses import dataclass, field + +from tree_sitter import Node as TSNode + +from dualect import ir +from dualect.parse import ParsedSource, parse_m +from dualect.source import DO_MARKER, UNTIL_MARKER + +_BINARY = { + "+": "plus", "-": "minus", "*": "mtimes", ".*": "times", "/": "mrdivide", + "./": "rdivide", "\\": "mldivide", ".\\": "ldivide", "^": "mpower", ".^": "power", + "==": "eq", "~=": "ne", "!=": "ne", "<": "lt", "<=": "le", ">": "gt", ">=": "ge", + "&": "and", "|": "or", "&&": "andand", "||": "oror", +} # fmt: skip +_PREFIX = {"-": "uminus", "+": "uplus", "~": "not", "!": "not"} + +#: Binding power of binary operators, loosest first, from the language +#: reference (Octave and MATLAB agree): || < && < | < & < comparisons < : < +#: + - < * / \ < unary prefix < ^ .^ and postfix transposes. +_BINDING = { + "oror": 1, "andand": 2, "or": 3, "and": 4, + "eq": 5, "ne": 5, "lt": 5, "le": 5, "gt": 5, "ge": 5, + "plus": 7, "minus": 7, + "mtimes": 8, "times": 8, "mrdivide": 8, "rdivide": 8, "mldivide": 8, "ldivide": 8, + "mpower": 10, "power": 10, +} # fmt: skip +_PREFIX_BINDING = 9 +_POWER_BINDING = 10 + +_CHAIN_NODES = frozenset( + {"binary_operator", "comparison_operator", "boolean_operator", "unary_operator", + "not_operator", "postfix_operator"} +) # fmt: skip + +#: Statement node types whose meaning the IR does not model, with their tags. +_OPAQUE_STATEMENTS = { + "try_statement": "stmt:try", + "global_operator": "stmt:global", + "persistent_operator": "stmt:persistent", + "class_definition": "stmt:classdef", + "spmd_statement": "stmt:spmd", + "arguments_statement": "func:arguments-block", +} + +_INT_LITERAL = re.compile(r"^[0-9]+$") +_ESCAPES = {"n": "\n", "t": "\t", "r": "\r", "\\": "\\", '"': '"', "'": "'", "a": "\a", "0": "\0"} + + +@dataclass +class _Scope: + """Names visible as variables while lowering one function or script body. + + :param variables: names that are variables in this scope. + :param handles: variables that only ever hold function handles. + """ + + variables: set[str] + handles: set[str] = field(default_factory=set) + + +@dataclass +class _IndexContext: + """The innermost index expression whose subscripts are being lowered.""" + + target: ir.Expr + dim: int + ndims: int + + +class _Lowerer: + """Walks one parsed file; see :func:`lower_source` for the entry point.""" + + def __init__(self, *, parsed: ParsedSource, interpret_escapes: bool) -> None: + self.parsed = parsed + self.interpret_escapes = interpret_escapes + self.functions: set[str] = set() + self.scope = _Scope(variables=set()) + self.index_stack: list[_IndexContext] = [] + self.pending_syntax: list[str] = [] + self.pending_comments: list[str] = [] + + # --- helpers ----------------------------------------------------------- + + def loc(self, node: TSNode) -> ir.Loc: + return self.parsed.loc(node) + + def text(self, node: TSNode) -> str: + return self.parsed.text(node) + + def offset(self, node: TSNode) -> int: + return self.parsed.char_offset(node.start_byte) + + @staticmethod + def named(node: TSNode) -> list[TSNode]: + """Named children, skipping comments and continuations (handled separately).""" + return [c for c in node.named_children if c.type not in ("comment", "line_continuation")] + + def collect_continuations(self, node: TSNode) -> None: + """Record ``...`` continuations inside a statement and keep their comments.""" + for child in node.children: + if child.type == "line_continuation": + self.pending_syntax.append("syntax:continuation") + remark = self.text(child)[3:].strip() + if remark: + self.pending_comments.append(remark) + elif child.type == "comment" and child.parent is not None: + self.pending_comments.append(_comment_text(self.text(child))) + elif child.child_count and child.type not in ("function_definition",): + self.collect_continuations(child) + + # --- scopes ------------------------------------------------------------ + + def scan_assigned(self, node: TSNode, scope: _Scope) -> None: + """Collect names assigned anywhere under ``node`` (not in nested functions).""" + for child in node.named_children: + if child.type == "function_definition": + continue + if child.type == "assignment": + left = child.child_by_field_name("left") + right = child.child_by_field_name("right") + for name in self.target_names(left): + scope.variables.add(name) + if right is not None and right.type in ("lambda", "handle_operator"): + scope.handles.add(name) + elif name in scope.handles: + scope.handles.discard(name) + elif child.type == "iterator": + first = child.named_children[0] if child.named_children else None + if first is not None and first.type == "identifier": + scope.variables.add(self.text(first)) + elif child.type in ("global_operator", "persistent_operator"): + for ident in child.named_children: + if ident.type == "identifier": + scope.variables.add(self.text(ident)) + self.scan_assigned(child, scope) + + def target_names(self, left: TSNode | None) -> list[str]: + if left is None: + return [] + if left.type == "identifier": + return [self.text(left)] + if left.type == "function_call": + name = left.child_by_field_name("name") + return [self.text(name)] if name is not None else [] + if left.type == "multioutput_variable": + names: list[str] = [] + for child in left.named_children: + names.extend(self.target_names(child)) + return names + return [] + + # --- program and statements -------------------------------------------- + + def program(self, root: TSNode, name: str) -> ir.Program: + for child in root.named_children: + if child.type == "function_definition": + fname = child.child_by_field_name("name") + if fname is not None: + self.functions.add(self.text(fname)) + script_scope = _Scope(variables=set()) + self.scan_assigned(root, script_scope) + self.scope = script_scope + body = self.block(root) + _reject_stray_until(body) + return ir.Program(loc=self.loc(root), body=body, source_name=name) + + def block(self, node: TSNode) -> list[ir.Stmt]: + """Lower the statements among ``node``'s children, attaching comments.""" + body: list[ir.Stmt] = [] + children = node.children + last_line = -1 + for index, child in enumerate(children): + if child.type in ("comment", "line_continuation"): + if child.type == "line_continuation": + continue + loc = self.loc(child) + # The grammar merges consecutive comment lines (and a following + # %{ ... %} block) into one node; split it back into pieces. + for first, piece in enumerate(_comment_pieces(self.text(child))): + line_offset, is_block, text, span = piece + line = loc.line + line_offset + tags = ["syntax:hash-comment"] if self._is_hash_line(line) else [] + if ( + first == 0 + and body + and line == last_line + and not isinstance(body[-1], ir.Comment) + and not is_block + ): + previous = body[-1] + previous.comment = ( + text if previous.comment is None else f"{previous.comment}; {text}" + ) + previous.syntax.extend(["syntax:comment", *tags]) + continue + piece_loc = ir.Loc(line, 1 if line_offset else loc.col, line + span - 1, 1) + comment = ir.Comment(loc=piece_loc, text=text, block=is_block) + comment.syntax.extend( + ["syntax:block-comment" if is_block else "syntax:comment", *tags] + ) + body.append(comment) + last_line = line + span - 1 + continue + if not child.is_named: + continue + following = children[index + 1] if index + 1 < len(children) else None + display = following is None or following.type != ";" + stmts = self.statement(child, display=display) + body.extend(stmts) + if stmts: + last_line = self.loc(child).end_line + return body + + def _is_hash_line(self, line: int) -> bool: + """Whether a comment on this original line starts with ``#``.""" + lines = self.parsed.source.original.splitlines() + if not 1 <= line <= len(lines): + return False + text = lines[line - 1] + stripped = text.lstrip() + if stripped.startswith("#"): + return True + return "#" in text and "%" not in text + + def statement(self, node: TSNode, *, display: bool) -> list[ir.Stmt]: + """Lower one statement node; may return several (or none).""" + kind = node.type + loc = self.loc(node) + if kind == "block": + return self.block(node) + if kind in _OPAQUE_STATEMENTS: + return [ + ir.OpaqueStmt(loc=loc, construct=_OPAQUE_STATEMENTS[kind], text=self.text(node)) + ] + if kind == "function_definition": + return [self.function_definition(node)] + if kind in ("if_statement", "for_statement", "while_statement", "switch_statement"): + return [self.compound(node)] + if node.has_error: + return [ir.OpaqueStmt(loc=loc, construct="parse:error", text=self.text(node))] + if kind == "break_statement": + return [ir.Break(loc=loc)] + if kind == "continue_statement": + return [ir.Continue(loc=loc)] + if kind == "return_statement": + return [ir.Return(loc=loc)] + if kind == "command": + name_node = node.child_by_field_name("name") or node.named_children[0] + words = [self.text(c) for c in node.named_children if c.type == "command_argument"] + return [ir.Command(loc=loc, name=self.text(name_node), words=words)] + + self.pending_syntax = [] + self.pending_comments = [] + self.collect_continuations(node) + stmt = self.simple_statement(node, display=display) + if display and not isinstance(stmt, ir.OpaqueStmt): + stmt.syntax.append("syntax:display") + stmt.syntax.extend(self.pending_syntax) + if self.pending_comments: + stmt.comment = "; ".join(self.pending_comments) + return [stmt] + + def simple_statement(self, node: TSNode, *, display: bool) -> ir.Stmt: + loc = self.loc(node) + if node.type == "assignment": + return self.assignment(node, display=display) + increment = self._increment(node) + if increment is not None: + ident, op = increment + return ir.AugAssign( + loc=loc, + target=ir.Name(loc=self.loc(ident), id=self.text(ident)), + op=op, + value=ir.Num(loc=loc, text="1", value=1), + ) + value = self.expr(node) + # A lone number statement (`1;`) is how an Octave script declares that it + # is a script before defining functions: it has no effect. + if isinstance(value, ir.Num) and not display: + stmt = ir.ExprStmt(loc=loc, value=value, display=display) + stmt.syntax.append("syntax:script-marker") + return stmt + return ir.ExprStmt(loc=loc, value=value, display=display) + + def _increment(self, node: TSNode) -> tuple[TSNode, str] | None: + """The identifier and operator of a normalized ``x++`` statement, if it is one.""" + if node.type != "binary_operator": + return None + for child in node.named_children: + if child.type == "identifier": + op = self.parsed.source.increments.get(self.offset(child)) + if op is not None: + return child, op + return None + + def assignment(self, node: TSNode, *, display: bool) -> ir.Stmt: + loc = self.loc(node) + left = node.child_by_field_name("left") + right = node.child_by_field_name("right") + if left is None or right is None: + return ir.OpaqueStmt(loc=loc, construct="parse:error", text=self.text(node)) + equals = next((c for c in node.children if c.type == "="), None) + aug = self.parsed.source.aug_ops.get(self.offset(equals)) if equals is not None else None + targets = self.targets(left) + value = self.expr(right) + if aug is not None: + return ir.AugAssign(loc=loc, target=targets[0], op=aug, value=value) + return ir.Assign(loc=loc, targets=targets, value=value, display=display) + + def targets(self, left: TSNode) -> list[ir.Expr]: + loc = self.loc(left) + if left.type == "multioutput_variable": + found: list[ir.Expr] = [] + for child in left.named_children: + if child.type == "ignored_argument": + found.append(ir.Ignore(loc=self.loc(child))) + else: + found.extend(self.targets(child)) + return found + if left.type == "identifier": + return [ir.Name(loc=loc, id=self.text(left))] + if left.type == "function_call" and not self._is_brace(left): + return [self.index(left, force_index=True)] + if left.type == "field_expression": + return [ir.Opaque(loc=loc, construct="expr:field", text=self.text(left))] + if left.type == "function_call": + return [ir.Opaque(loc=loc, construct="expr:cell-index", text=self.text(left))] + return [ir.Opaque(loc=loc, construct="parse:error", text=self.text(left))] + + def function_definition(self, node: TSNode) -> ir.Stmt: + loc = self.loc(node) + name_node = node.child_by_field_name("name") + name = self.text(name_node) if name_node is not None else "" + outputs: list[str] = [] + params: list[str] = [] + body_node: TSNode | None = None + for child in node.named_children: + if child.type == "function_output": + for out in child.named_children: + if out.type == "identifier": + outputs.append(self.text(out)) + elif out.type == "multioutput_variable": + outputs.extend( + self.text(c) for c in out.named_children if c.type == "identifier" + ) + elif child.type == "function_arguments": + for arg in child.named_children: + if arg.type == "identifier": + params.append(self.text(arg)) + elif arg.type == "ignored_argument": + params.append("~") + elif child.type == "block": + body_node = child + header_errors = any( + c.has_error + for c in node.named_children + if c.type in ("function_output", "function_arguments") + ) + if header_errors: + return ir.OpaqueStmt(loc=loc, construct="parse:error", text=self.text(node)) + outer = self.scope + scope = _Scope(variables={*params, *outputs}) + if body_node is not None: + self.scan_assigned(body_node, scope) + self.scope = scope + try: + body = self.block(body_node) if body_node is not None else [] + finally: + self.scope = outer + stmt = ir.FunctionDef(loc=loc, name=name, params=params, outputs=outputs, body=body) + # Comments and blank lines between the header and the first statement + # belong to the body; nothing to do here. + return stmt + + def compound(self, node: TSNode) -> ir.Stmt: + stmt = self._compound(node) + # A comment on the header line (`while x % why`) is a direct child. + remarks = [_comment_text(self.text(c)) for c in node.children if c.type == "comment"] + if remarks and not isinstance(stmt, ir.OpaqueStmt): + stmt.comment = "; ".join(r for r in [stmt.comment, *remarks] if r) + stmt.syntax.append("syntax:comment") + return stmt + + def _compound(self, node: TSNode) -> ir.Stmt: + loc = self.loc(node) + kind = node.type + header = [c for c in node.named_children if c.type not in ("block", "comment")] + if kind == "if_statement": + cond = node.child_by_field_name("condition") + if cond is None or cond.has_error: + return ir.OpaqueStmt(loc=loc, construct="parse:error", text=self.text(node)) + branches = [(self.expr(cond), self.first_block(node))] + orelse: list[ir.Stmt] | None = None + for clause in node.named_children: + if clause.type == "elseif_clause": + clause_cond = clause.child_by_field_name("condition") + if clause_cond is None or clause_cond.has_error: + return ir.OpaqueStmt(loc=loc, construct="parse:error", text=self.text(node)) + branches.append((self.expr(clause_cond), self.first_block(clause))) + elif clause.type == "else_clause": + orelse = self.first_block(clause) + return ir.If(loc=loc, branches=branches, orelse=orelse) + if kind == "for_statement": + iterator = next((c for c in header if c.type == "iterator"), None) + is_parfor = any(c.type == "parfor" for c in node.children) + if iterator is None or iterator.has_error or is_parfor: + construct = "stmt:parfor" if is_parfor else "parse:error" + return ir.OpaqueStmt(loc=loc, construct=construct, text=self.text(node)) + parts = self.named(iterator) + var = parts[0] + iterable = self.expr(parts[-1]) + return ir.For( + loc=loc, + var=ir.Name(loc=self.loc(var), id=self.text(var)), + iterable=iterable, + body=self.first_block(node), + ) + if kind == "while_statement": + cond = node.child_by_field_name("condition") + if cond is None or cond.has_error: + return ir.OpaqueStmt(loc=loc, construct="parse:error", text=self.text(node)) + body = self.first_block(node) + if cond.type == "identifier" and self.text(cond) == DO_MARKER: + return self.do_until(node, body) + return ir.While(loc=loc, cond=self.expr(cond), body=body) + # switch_statement + subject_node = node.child_by_field_name("condition") + if subject_node is None or subject_node.has_error: + return ir.OpaqueStmt(loc=loc, construct="parse:error", text=self.text(node)) + cases: list[tuple[list[ir.Expr], list[ir.Stmt]]] = [] + otherwise: list[ir.Stmt] | None = None + for clause in node.named_children: + if clause.type == "case_clause": + value_node = clause.child_by_field_name("condition") + if value_node is None or value_node.has_error: + return ir.OpaqueStmt(loc=loc, construct="parse:error", text=self.text(node)) + value = self.expr(value_node) + values = value.items if isinstance(value, ir.CellLit) else [value] + cases.append((values, self.first_block(clause))) + elif clause.type == "otherwise_clause": + otherwise = self.first_block(clause) + return ir.Switch(loc=loc, subject=self.expr(subject_node), cases=cases, otherwise=otherwise) + + def first_block(self, node: TSNode) -> list[ir.Stmt]: + """The statements of a clause: its ``block`` child, if any.""" + block = next((c for c in node.named_children if c.type == "block"), None) + body = self.block(block) if block is not None else [] + # Comments that sit directly in the clause (an otherwise empty branch). + for child in node.named_children: + if child.type == "comment" and block is None: + body.append(ir.Comment(loc=self.loc(child), text=_comment_text(self.text(child)))) + return body + + def do_until(self, node: TSNode, body: list[ir.Stmt]) -> ir.Stmt: + loc = self.loc(node) + last = next((s for s in reversed(body) if not isinstance(s, ir.Comment)), None) + if ( + isinstance(last, ir.Assign) + and len(last.targets) == 1 + and isinstance(last.targets[0], ir.Name) + and last.targets[0].id == UNTIL_MARKER + ): + index = body.index(last) + stmt = ir.DoUntil(loc=loc, body=body[:index] + body[index + 1 :], cond=last.value) + stmt.comment = last.comment + return stmt + return ir.OpaqueStmt(loc=loc, construct="parse:error", text=self.text(node)) + + # --- expressions ------------------------------------------------------- + + def expr(self, node: TSNode) -> ir.Expr: + """Lower an expression node.""" + loc = self.loc(node) + kind = node.type + if node.has_error or node.is_missing: + return ir.Opaque(loc=loc, construct="parse:error", text=self.text(node)) + if kind == "_expression" and len(self.named(node)) == 1: + # A wrapper the grammar sometimes leaves in place; it means nothing. + return self.expr(self.named(node)[0]) + if kind in _CHAIN_NODES: + return self.chain(node) + if kind == "parenthesis": + inner = self.named(node) + if len(inner) != 1: + return ir.Opaque(loc=loc, construct="parse:error", text=self.text(node)) + return self.expr(inner[0]) + if kind == "number": + return _number(self.text(node), loc) + if kind == "string": + return self.string(node) + if kind == "identifier": + return self.identifier(node) + if kind == "end_keyword": + if not self.index_stack: + return ir.Opaque(loc=loc, construct="expr:end-outside-index", text="end") + context = self.index_stack[-1] + return ir.End(loc=loc, target=context.target, dim=context.dim, ndims=context.ndims) + if kind == "spread_operator": + return ir.Colon(loc=loc) + if kind == "range": + parts = [self.expr(c) for c in self.named(node)] + if len(parts) == 2: + return ir.Range(loc=loc, start=parts[0], stop=parts[1]) + if len(parts) == 3: + return ir.Range(loc=loc, start=parts[0], step=parts[1], stop=parts[2]) + return ir.Opaque(loc=loc, construct="parse:error", text=self.text(node)) + if kind == "matrix": + rows = [] + for row in self.named(node): + items = [self.expr(c) for c in self.named(row)] + if items: + rows.append(items) + return ir.Matrix(loc=loc, rows=rows) + if kind == "cell": + items = [self.expr(c) for row in self.named(node) for c in self.named(row)] + return ir.CellLit(loc=loc, items=items) + if kind == "function_call": + if self._is_brace(node): + return ir.Opaque(loc=loc, construct="expr:cell-index", text=self.text(node)) + return self.index(node) + if kind == "lambda": + return self.lambda_(node) + if kind == "handle_operator": + target = self.named(node) + if len(target) == 1 and target[0].type == "identifier": + return ir.FuncRef(loc=loc, name=self.text(target[0])) + return ir.Opaque(loc=loc, construct="func:handle-expression", text=self.text(node)) + if kind == "field_expression": + return ir.Opaque(loc=loc, construct="expr:field", text=self.text(node)) + if kind == "boolean": + return ir.Call(loc=loc, func=self.text(node), args=[]) + return ir.Opaque(loc=loc, construct=f"expr:{kind}", text=self.text(node)) + + def string(self, node: TSNode) -> ir.Expr: + raw = self.text(node) + loc = self.loc(node) + quote = raw[0] + body = raw[1:-1] + if quote == "'": + return ir.Str(loc=loc, value=body.replace("''", "'"), quote="'") + if self.interpret_escapes: + # Octave reads backslash escapes in double-quoted strings. + value = re.sub( + r"\\(.)", lambda m: _ESCAPES.get(m.group(1), "\\" + m.group(1)), body + ).replace('""', '"') + else: + value = body.replace('""', '"') + return ir.Str(loc=loc, value=value, quote='"') + + def identifier(self, node: TSNode) -> ir.Expr: + name = self.text(node) + loc = self.loc(node) + if name in self.scope.variables: + return ir.Name(loc=loc, id=name) + return ir.Call(loc=loc, func=name, args=[], local=name in self.functions) + + @staticmethod + def _is_brace(node: TSNode) -> bool: + return any(c.type == "{" for c in node.children) + + def index(self, node: TSNode, *, force_index: bool = False) -> ir.Expr: + """Lower ``name(args)``: an index of a variable, else a function call.""" + loc = self.loc(node) + name_node = node.child_by_field_name("name") + if name_node is None or name_node.type != "identifier": + return ir.Opaque(loc=loc, construct="expr:call-expression", text=self.text(node)) + name = self.text(name_node) + arg_nodes: list[TSNode] = [] + for child in node.named_children: + if child.type == "arguments": + arg_nodes = self.named(child) + is_variable = force_index or name in self.scope.variables + if is_variable and name not in self.scope.handles: + target = ir.Name(loc=self.loc(name_node), id=name) + args: list[ir.Expr] = [] + for dim, arg in enumerate(arg_nodes): + self.index_stack.append(_IndexContext(target=target, dim=dim, ndims=len(arg_nodes))) + try: + args.append(self.expr(arg)) + finally: + self.index_stack.pop() + return ir.Index(loc=loc, target=target, args=args) + # `end` inside a call's arguments would bind to an enclosing index (if any) + # in the language; keep the stack as it is. + call_args = [self.expr(arg) for arg in arg_nodes] + return ir.Call( + loc=loc, + func=name, + args=call_args, + local=name in self.functions, + handle=name in self.scope.handles, + ) + + def lambda_(self, node: TSNode) -> ir.Expr: + loc = self.loc(node) + params: list[str] = [] + body_node = node.child_by_field_name("expression") + for child in node.named_children: + if child.type == "arguments": + params = [self.text(c) for c in child.named_children if c.type == "identifier"] + if body_node is None: + return ir.Opaque(loc=loc, construct="parse:error", text=self.text(node)) + outer = self.scope + self.scope = _Scope( + variables=outer.variables | set(params), handles=outer.handles - set(params) + ) + try: + body = self.expr(body_node) + finally: + self.scope = outer + return ir.Lambda(loc=loc, params=params, body=body) + + # --- operator chains --------------------------------------------------- + + def flatten(self, node: TSNode, tokens: list[tuple[str, object, ir.Loc]]) -> None: + """Flatten an operator chain into tokens: atoms, prefix, binary, postfix ops.""" + kind = node.type + if kind == "_expression" and len(self.named(node)) == 1: + self.flatten(self.named(node)[0], tokens) + return + if kind not in _CHAIN_NODES or node.has_error: + tokens.append(("atom", self.expr(node), self.loc(node))) + return + if kind in ("unary_operator", "not_operator"): + op_token = next(c for c in node.children if not c.is_named) + tokens.append(("pre", _PREFIX[self.text(op_token)], self.loc(op_token))) + for child in self.named(node): + self.flatten(child, tokens) + return + if kind == "postfix_operator": + for child in self.named(node): + self.flatten(child, tokens) + op_token = next(c for c in reversed(node.children) if not c.is_named) + tokens.append(("post", self.text(op_token) == "'", self.loc(op_token))) + return + for child in node.children: + if child.type in ("comment", "line_continuation"): + continue + if child.is_named: + self.flatten(child, tokens) + else: + tokens.append(("bin", _BINARY[self.text(child)], self.loc(child))) + + def chain(self, node: TSNode) -> ir.Expr: + tokens: list[tuple[str, object, ir.Loc]] = [] + try: + self.flatten(node, tokens) + except (KeyError, StopIteration): + return ir.Opaque(loc=self.loc(node), construct="parse:error", text=self.text(node)) + parser = _PrattParser(tokens) + result = parser.expression(0) + if parser.position != len(tokens): + return ir.Opaque(loc=self.loc(node), construct="parse:error", text=self.text(node)) + return result + + +class _PrattParser: + """Rebuilds an operator chain with the language's precedence (see :data:`_BINDING`).""" + + def __init__(self, tokens: list[tuple[str, object, ir.Loc]]) -> None: + self.tokens = tokens + self.position = 0 + + def peek(self) -> tuple[str, object, ir.Loc] | None: + return self.tokens[self.position] if self.position < len(self.tokens) else None + + def take(self) -> tuple[str, object, ir.Loc]: + token = self.tokens[self.position] + self.position += 1 + return token + + def expression(self, min_binding: int) -> ir.Expr: + left = self.prefix() + while (token := self.peek()) is not None: + kind, value, loc = token + if kind == "post": + if min_binding > _POWER_BINDING: + break + self.take() + left = ir.Transpose(loc=_span(left.loc, loc), operand=left, conjugate=bool(value)) + continue + if kind != "bin": + break + op = str(value) + binding = _BINDING[op] + if binding < min_binding: + break + self.take() + # All binary operators are left-associative; a power's exponent may + # carry its own prefix operators (`2^-1`), which bind only to it. + right = ( + self.power_operand() if binding == _POWER_BINDING else self.expression(binding + 1) + ) + left = ir.BinOp(loc=_span(left.loc, right.loc), op=op, left=left, right=right) + return left + + def prefix(self) -> ir.Expr: + kind, value, loc = self.take() + if kind == "pre": + operand = self.expression(_PREFIX_BINDING) + return ir.UnOp(loc=_span(loc, operand.loc), op=str(value), operand=operand) + if kind != "atom" or not isinstance(value, ir.Expr): + raise ValueError("malformed operator chain") + return value + + def power_operand(self) -> ir.Expr: + kind, value, loc = self.take() + if kind == "pre": + operand = self.power_operand() + return ir.UnOp(loc=_span(loc, operand.loc), op=str(value), operand=operand) + if kind != "atom" or not isinstance(value, ir.Expr): + raise ValueError("malformed operator chain") + return value + + +def _reject_stray_until(body: list[ir.Stmt]) -> None: + """Turn an ``until`` that closed no ``do`` into a parse error, in place.""" + for index, stmt in enumerate(body): + if ( + isinstance(stmt, ir.Assign) + and isinstance(stmt.targets[0], ir.Name) + and stmt.targets[0].id == UNTIL_MARKER + ): + body[index] = ir.OpaqueStmt(loc=stmt.loc, construct="parse:error", text="until ...") + for inner in ir.stmt_bodies(stmt): + _reject_stray_until(inner) + + +def _span(first: ir.Loc, last: ir.Loc) -> ir.Loc: + return ir.Loc(first.line, first.col, last.end_line, last.end_col) + + +def _number(text: str, loc: ir.Loc) -> ir.Expr: + """Parse a numeric literal; imaginary literals end in ``i`` or ``j``.""" + body = text + imaginary = body[-1] in "ijIJ" and not body.lower().startswith("0x") + if imaginary: + body = body[:-1] + try: + if body.lower().startswith("0x"): + value: int | float = int(body, 16) + elif _INT_LITERAL.match(body): + value = int(body) + else: + value = float(body) + except ValueError: + return ir.Opaque(loc=loc, construct="literal:number-format", text=text) + if imaginary: + return ir.Num(loc=loc, text=text, value=complex(0, value)) + return ir.Num(loc=loc, text=text, value=value) + + +def _comment_text(text: str) -> str: + """Comment text without its marker; ``%%`` cell dividers keep theirs.""" + stripped = text.strip() + if stripped.startswith("%%"): + return stripped + body = stripped[1:] + return body[1:] if body.startswith(" ") else body + + +def _comment_pieces(text: str) -> list[tuple[int, bool, str, int]]: + """Split a comment node into ``(line offset, is block, text, line count)`` pieces.""" + lines = text.split("\n") + pieces: list[tuple[int, bool, str, int]] = [] + index = 0 + while index < len(lines): + stripped = lines[index].strip() + if stripped == "%{": + depth, end = 1, index + 1 + while end < len(lines) and depth: + marker = lines[end].strip() + depth += 1 if marker == "%{" else -1 if marker == "%}" else 0 + end += 1 + inner = [line.strip() for line in lines[index + 1 : end - 1]] + pieces.append((index, True, "\n".join(inner), end - index)) + index = end + continue + if stripped: + pieces.append((index, False, _comment_text(stripped), 1)) + index += 1 + return pieces + + +def lower_source(*, text: str, name: str = "", dialect: str = "octave") -> ir.Program: + """Parse and lower ``.m`` source text into an :class:`ir.Program`. + + :param text: the source. + :param name: file name for reports. + :param dialect: ``"octave"`` (double-quoted strings read backslash escapes) + or ``"matlab"`` (they do not). + """ + parsed = parse_m(text) + lowerer = _Lowerer(parsed=parsed, interpret_escapes=dialect == "octave") + return lowerer.program(parsed.tree.root_node, name) + + +def lower_parsed(*, parsed: ParsedSource, name: str, dialect: str = "octave") -> ir.Program: + """Lower an already parsed file (see :func:`lower_source`). + + :param parsed: output of :func:`dualect.parse.parse_m`. + :param name: file name for reports. + :param dialect: source dialect. + """ + return _Lowerer(parsed=parsed, interpret_escapes=dialect == "octave").program( + parsed.tree.root_node, name + ) diff --git a/dualect/mcp_server.py b/dualect/mcp_server.py new file mode 100644 index 0000000..12bbf99 --- /dev/null +++ b/dualect/mcp_server.py @@ -0,0 +1,184 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""The MCP server (docs/design.md section 6): dualect's tools for an LLM client. + +``dualect mcp`` serves four tools over stdio, built on the official ``mcp`` +Python SDK: + +* ``scan``: the rules a ``.m`` or ``.py`` file needs, and the constructs that + have none (the same data as ``dualect scan --json``); +* ``get_rule``: one rule's ``rule.yaml`` and cases, as LLM-ready context; +* ``translate``: translate a file in either direction, verify it by running + both sides, and return the output with its per-statement report; +* ``verify``: run a ``.m`` and a ``.py`` file and compare their variables. + +The server never calls an LLM API (section 12): it gives the client's model the +knowledge and the checks, and whatever the model writes comes back through +``verify`` like everything else. +""" + +import tempfile +from pathlib import Path +from typing import Any + +from mcp.server.mcpserver import MCPServer +from mcp.server.mcpserver.exceptions import ToolError + +from dualect import __version__ +from dualect.compare import Tolerance +from dualect.context import render_rule +from dualect.dialect import parse_dialect +from dualect.errors import DualectError +from dualect.paths import default_rules_dir +from dualect.pipeline import StrictModeError, translate_file +from dualect.rulebook import FROM_PYTHON, TO_PYTHON, Rule, load_rules +from dualect.scan import scan_file +from dualect.verify import options_for_pair, verify_pair + +INSTRUCTIONS = """\ +dualect translates numeric code between .m files (Octave/MATLAB style) and +Python/NumPy, one tested rule per construct, and verifies every translation by +running both sides. Use `scan` to see which rules a file needs, `get_rule` to +read a rule (why the languages differ, pitfalls, verified example pairs), +`translate` for the deterministic translation (statements it cannot translate +are left as TODO(dualect) holes and reported), and `verify` to check any +translation, including your own, by execution. Never present an unverified +translation as verified.""" + + +def _source(path: str) -> Path: + source = Path(path).expanduser() + if not source.is_file(): + raise ToolError(f"no such file: {path}") + if source.suffix not in (".m", ".py"): + raise ToolError(f"expected a .m or .py file, got {path}") + return source + + +def build_server(*, rules_dir: Path | None = None) -> MCPServer: + """Create the server with its four tools. + + :param rules_dir: the rules folder (default: the repository's or the + installed copy, see :func:`dualect.paths.default_rules_dir`). + """ + root = rules_dir or default_rules_dir() + server = MCPServer(name="dualect", version=__version__, instructions=INSTRUCTIONS) + + def rules() -> list[Rule]: + return load_rules(rules_dir=root) + + @server.tool() + def scan(path: str, dialect: str | None = None) -> dict[str, Any]: + """List the rules a .m or .py file needs and the constructs no rule covers. + + :param path: the source file (.m: translated to Python; .py: to .m). + :param dialect: for a .m file, the source dialect, e.g. "octave" or "matlab@R2023a". + """ + try: + result = scan_file(path=_source(path), rules=rules(), dialect=parse_dialect(dialect)) + except DualectError as exc: + raise ToolError(str(exc)) from exc + return result.as_json() + + @server.tool() + def get_rule(rule_id: str, cases: int = 2) -> dict[str, Any]: + """Return one rule: its rule.yaml (the knowledge) and up to `cases` verified example pairs. + + :param rule_id: e.g. "indexing/end-in-index" (see `scan` for the ids a file needs). + :param cases: how many example pairs to include. + """ + found = {rule.id: rule for rule in rules()} + rule = found.get(rule_id) + if rule is None: + raise ToolError(f"no rule {rule_id!r}; known: {', '.join(sorted(found))}") + return { + "id": rule.id, + "title": rule.title, + "status": { + TO_PYTHON: rule.status.value, + FROM_PYTHON: rule.python_status.value if rule.python_status else None, + }, + "markdown": render_rule(rule, limit=max(cases, 0)), + } + + @server.tool() + def translate( + path: str, + output: str | None = None, + dialect: str | None = None, + strict: bool = False, + verify: bool = True, + ) -> dict[str, Any]: + """Translate a .m file to Python or a .py file to .m, then verify it by running both. + + :param path: the source file; its suffix picks the direction. + :param output: where to write the result; by default nothing is written + and the text is returned. + :param dialect: for a .m file, the source dialect. + :param strict: fail instead of leaving holes for untranslated statements. + :param verify: run both sides and compare (needs GNU Octave). + """ + source = _source(path) + suffix = ".m" if source.suffix == ".py" else ".py" + with tempfile.TemporaryDirectory() as scratch: + target = ( + Path(output).expanduser() if output else Path(scratch) / f"{source.stem}{suffix}" + ) + try: + result = translate_file( + source=source, + output=target, + rules=rules(), + dialect=parse_dialect(dialect), + strict=strict, + verify=verify, + ) + except StrictModeError as exc: + raise ToolError(f"{exc}\nnothing was written") from exc + except DualectError as exc: + raise ToolError(str(exc)) from exc + text = target.read_text(encoding="utf-8") + return { + "output": str(target) if output else None, + "text": text, + "verified": result.verified, + "complete": result.complete, + "holes": [ + {"line": h.loc.line, "status": h.status.value, "reason": h.reason} + for h in result.holes + ], + "report": result.report(), + } + + @server.tool() + def verify(m_file: str, py_file: str) -> dict[str, Any]: + """Run a .m script and a .py script and compare every variable the .m script leaves. + + :param m_file: the .m script (run in GNU Octave). + :param py_file: the Python script. + """ + m_path, py_path = _source(m_file), _source(py_file) + try: + options = options_for_pair(m_path=m_path, py_path=py_path, tolerance=Tolerance()) + result = verify_pair(m_path=m_path, py_path=py_path, options=options) + except DualectError as exc: + raise ToolError(str(exc)) from exc + return { + "ok": result.ok, + "variables": [ + {"name": v.name, "ok": v.ok, "detail": v.detail} for v in result.variables + ], + "python_only": list(result.python_only), + "report": result.report(), + } + + return server + + +def serve(*, rules_dir: Path | None = None) -> None: + """Run the server on stdio until the client disconnects. + + :param rules_dir: the rules folder (default: see :func:`build_server`). + """ + build_server(rules_dir=rules_dir).run("stdio") diff --git a/dualect/memit.py b/dualect/memit.py new file mode 100644 index 0000000..4d5dec6 --- /dev/null +++ b/dualect/memit.py @@ -0,0 +1,235 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Printing the IR as ``.m`` source (the Python -> ``.m`` direction, step 5). + +By the time a program reaches this module it already has ``.m`` semantics: +the lifting step (:mod:`dualect.lift`, with each rule's ``lift``) produced +1-based :class:`~dualect.ir.Index` subscripts, inclusive ranges, ``mtimes`` +for the matrix product and transposes where a 1-D NumPy array must be seen as +a column. What is left here is surface syntax: precedence and parentheses, +statement layout, and comments. + +The output avoids anything newer than Octave 8 and MATLAB R2016b: every +statement ends with ``;``, functions are defined before use in a script that +starts with ``1;``, and matrix elements are separated by commas, so +``[1, -2]`` is never read as ``[1 - 2]``. +""" + +from dualect import ir + +INDENT = " " + +#: Binding power, loosest first (as in :mod:`dualect.lower`). +_BINDING = { + "oror": 1, "andand": 2, "or": 3, "and": 4, + "eq": 5, "ne": 5, "lt": 5, "le": 5, "gt": 5, "ge": 5, + "range": 6, + "plus": 7, "minus": 7, + "mtimes": 8, "times": 8, "mrdivide": 8, "rdivide": 8, "mldivide": 8, "ldivide": 8, + "unary": 9, + "mpower": 10, "power": 10, "postfix": 10, +} # fmt: skip +_ATOM = 11 + +_SYMBOLS = { + "plus": "+", "minus": "-", "mtimes": "*", "times": ".*", "mrdivide": "/", + "rdivide": "./", "mldivide": "\\", "ldivide": ".\\", "mpower": "^", "power": ".^", + "eq": "==", "ne": "~=", "lt": "<", "le": "<=", "gt": ">", "ge": ">=", + "and": "&", "or": "|", "andand": "&&", "oror": "||", +} # fmt: skip +_PREFIX = {"uminus": "-", "uplus": "+", "not": "~"} + +#: Construct of an :class:`~dualect.ir.OpaqueStmt` whose text is printed verbatim +#: (an untranslated statement: its TODO comment and the ``error`` call). +HOLE = "dualect:hole" + + +def _binding(node: ir.Expr) -> int: + match node: + case ir.BinOp(op=op): + return _BINDING[op] + case ir.UnOp(): + return _BINDING["unary"] + case ir.Transpose(): + return _BINDING["postfix"] + case ir.Range(): + return _BINDING["range"] + case ir.Lambda(): + return 0 + case ir.Num(value=value) if isinstance(value, int | float) and value < 0: + return _BINDING["unary"] + return _ATOM + + +def _wrap(node: ir.Expr, minimum: int) -> str: + text = expr(node) + return f"({text})" if _binding(node) < minimum else text + + +def number(node: ir.Num) -> str: + """A numeric literal in ``.m`` spelling (``1i`` for an imaginary unit).""" + value = node.value + if isinstance(value, complex): + if value.real == 0: + return f"{_real(value.imag)}i" + return f"({_real(value.real)} + {_real(value.imag)}i)" + if node.text and not node.text.endswith(("j", "J")): + return node.text + return _real(value) + + +def _real(value: float) -> str: + if isinstance(value, int) or float(value).is_integer() and abs(value) < 1e15: + return str(int(value)) + return repr(float(value)) + + +def string(value: str) -> str: + """A single-quoted char array literal.""" + return "'" + value.replace("'", "''") + "'" + + +def expr(node: ir.Expr) -> str: + """Print one expression.""" + match node: + case ir.Num(): + return number(node) + case ir.Str(value=value): + return string(value) + case ir.Name(id=name): + return name + case ir.Colon(): + return ":" + case ir.End(): + return "end" + case ir.Ignore(): + return "~" + case ir.Range(start=start, stop=stop, step=step): + parts = [start, step, stop] if step is not None else [start, stop] + return ":".join(_wrap(p, _BINDING["range"] + 1) for p in parts) + case ir.Matrix(rows=rows): + return "[" + "; ".join(", ".join(expr(item) for item in row) for row in rows) + "]" + case ir.CellLit(items=items): + return "{" + ", ".join(expr(item) for item in items) + "}" + case ir.BinOp(op=op, left=left, right=right): + binding = _BINDING[op] + if op in ("mpower", "power"): + # A prefix operator binds looser than a power: (-2)^2. + left_text = _wrap(left, binding + 1) + right_text = _wrap(right, _ATOM if isinstance(right, ir.BinOp) else binding) + else: + left_text = _wrap(left, binding) + right_text = _wrap(right, binding + 1) + return f"{left_text} {_SYMBOLS[op]} {right_text}" + case ir.UnOp(op=op, operand=operand): + return f"{_PREFIX[op]}{_wrap(operand, _BINDING['unary'])}" + case ir.Transpose(operand=operand, conjugate=conjugate): + mark = "'" if conjugate else ".'" + return f"{_wrap(operand, _ATOM)}{mark}" + case ir.Index(target=target, args=args): + return f"{_wrap(target, _ATOM)}({', '.join(expr(a) for a in args)})" + case ir.Call(func=func, args=args): + if not args: + return func + return f"{func}({', '.join(expr(a) for a in args)})" + case ir.Lambda(params=params, body=body): + return f"@({', '.join(params)}) {expr(body)}" + case ir.FuncRef(name=name): + return f"@{name}" + case ir.Opaque(text=text): + return text + raise ValueError(f"cannot print {type(node).__name__} as .m code") + + +def statements(body: list[ir.Stmt], depth: int = 0) -> list[str]: + """Print a statement list at a nesting depth.""" + lines: list[str] = [] + for stmt in body: + lines.extend(statement(stmt, depth)) + return lines + + +def _with_comment(line: str, stmt: ir.Stmt) -> str: + return f"{line} % {stmt.comment}" if stmt.comment else line + + +def statement(stmt: ir.Stmt, depth: int = 0) -> list[str]: + """Print one statement (several lines for a compound one).""" + pad = INDENT * depth + match stmt: + case ir.Comment(text=text): + return [f"{pad}% {line}".rstrip() for line in text.split("\n")] + case ir.OpaqueStmt(construct=construct, text=text) if construct == HOLE: + return [f"{pad}{line}" for line in text.split("\n")] + case ir.Assign(targets=targets, value=value): + if len(targets) == 1: + lhs = expr(targets[0]) + else: + lhs = "[" + ", ".join(expr(t) for t in targets) + "]" + return [_with_comment(f"{pad}{lhs} = {expr(value)};", stmt)] + case ir.ExprStmt(value=value): + return [_with_comment(f"{pad}{expr(value)};", stmt)] + case ir.If(branches=branches, orelse=orelse): + lines = [] + for k, (cond, body) in enumerate(branches): + keyword = "if" if k == 0 else "elseif" + header = f"{pad}{keyword} {expr(cond)}" + lines.append(_with_comment(header, stmt) if k == 0 else header) + lines.extend(statements(body, depth + 1)) + if orelse: + lines.append(f"{pad}else") + lines.extend(statements(orelse, depth + 1)) + lines.append(f"{pad}end") + return lines + case ir.For(var=var, iterable=iterable, body=body): + header = _with_comment(f"{pad}for {var.id} = {expr(iterable)}", stmt) + return [header, *statements(body, depth + 1), f"{pad}end"] + case ir.While(cond=cond, body=body): + header = _with_comment(f"{pad}while {expr(cond)}", stmt) + return [header, *statements(body, depth + 1), f"{pad}end"] + case ir.Switch(subject=subject, cases=cases, otherwise=otherwise): + lines = [_with_comment(f"{pad}switch {expr(subject)}", stmt)] + for values, body in cases: + label = expr(values[0]) if len(values) == 1 else expr(ir.CellLit(ir.NO_LOC, values)) + lines.append(f"{pad}{INDENT}case {label}") + lines.extend(statements(body, depth + 2)) + if otherwise is not None: + lines.append(f"{pad}{INDENT}otherwise") + lines.extend(statements(otherwise, depth + 2)) + lines.append(f"{pad}end") + return lines + case ir.Break(): + return [f"{pad}break;"] + case ir.Continue(): + return [f"{pad}continue;"] + case ir.Return(): + return [f"{pad}return;"] + case ir.FunctionDef(name=name, params=params, outputs=outputs, body=body): + if not outputs: + out = "" + elif len(outputs) == 1: + out = f"{outputs[0]} = " + else: + out = f"[{', '.join(outputs)}] = " + header = _with_comment(f"{pad}function {out}{name}({', '.join(params)})", stmt) + return [header, *statements(body, depth + 1), f"{pad}end"] + raise ValueError(f"cannot print {type(stmt).__name__} as .m code") + + +def program(body: list[ir.Stmt]) -> str: + """Print a whole script; ``1;`` first when it defines functions.""" + lines: list[str] = [] + if any(isinstance(s, ir.FunctionDef) for s in body): + # Octave reads a file whose first statement is `function` as a function + # file; `1;` makes it a script that may define functions before use. + lines.append("1;") + previous: ir.Stmt | None = None + for stmt in body: + separate = isinstance(stmt, ir.FunctionDef) or isinstance(previous, ir.FunctionDef) + gap = previous is not None and stmt.loc.line > previous.loc.end_line + 1 + if lines and (separate or gap) and lines[-1] != "": + lines.append("") + lines.extend(statement(stmt)) + previous = stmt + return "\n".join(lines) + "\n" diff --git a/dualect/parse.py b/dualect/parse.py new file mode 100644 index 0000000..6d7734e --- /dev/null +++ b/dualect/parse.py @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Parsing ``.m`` source with tree-sitter (docs/design.md section 9). + +The grammar is ``tree-sitter-matlab``; Octave-only syntax is rewritten first by +:mod:`dualect.source`. Locations reported anywhere in dualect are positions in +the *original* text, mapped back through the normalization. +""" + +import functools +from dataclasses import dataclass, field + +import tree_sitter_matlab +from tree_sitter import Language, Node, Parser, Tree + +from dualect.ir import Loc +from dualect.source import NormalizedSource, normalize + + +@functools.cache +def _parser() -> Parser: + """Build the parser once; loading the grammar is the expensive part.""" + return Parser(Language(tree_sitter_matlab.language())) + + +@dataclass +class ParsedSource: + """A parsed ``.m`` file. + + :param source: the normalized source and its map to the original. + :param tree: the tree-sitter syntax tree of the normalized text. + """ + + source: NormalizedSource + tree: Tree + _byte_to_char: list[int] = field(repr=False) + + def char_offset(self, byte_offset: int) -> int: + """Convert a tree-sitter byte offset into a normalized character offset.""" + if byte_offset >= len(self._byte_to_char): + return len(self.source.text) + return self._byte_to_char[byte_offset] + + def text(self, node: Node) -> str: + """The normalized text a node spans.""" + return self.source.text[self.char_offset(node.start_byte) : self.char_offset(node.end_byte)] + + def original_text(self, node: Node) -> str: + """The original source text a node spans (what the user wrote).""" + start = self.source.original_offset(self.char_offset(node.start_byte)) + end = self.source.original_offset(self.char_offset(node.end_byte)) + return self.source.original[start:end] + + def loc(self, node: Node) -> Loc: + """The node's span in the original source.""" + line, col = self.source.position(self.char_offset(node.start_byte)) + end_line, end_col = self.source.position(self.char_offset(node.end_byte)) + return Loc(line, col, end_line, end_col) + + +def parse_m(text: str) -> ParsedSource: + """Parse ``.m`` source text. + + Parsing never raises: regions the grammar cannot read become ``ERROR`` (or + zero-width ``MISSING``) nodes, which :mod:`dualect.lower` turns into named + ``parse:error`` constructs so they are reported, not dropped. + + :param text: the source. + """ + normalized = normalize(text) + encoded = normalized.text.encode("utf-8") + byte_to_char: list[int] = [] + for index, char in enumerate(normalized.text): + byte_to_char.extend([index] * len(char.encode("utf-8"))) + tree = _parser().parse(encoded) + return ParsedSource(source=normalized, tree=tree, _byte_to_char=byte_to_char) diff --git a/dualect/paths.py b/dualect/paths.py new file mode 100644 index 0000000..c2c878a --- /dev/null +++ b/dualect/paths.py @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Where dualect finds its rule knowledge base.""" + +import os +from pathlib import Path + +#: Environment variable that points dualect at a different ``rules/`` folder, +#: e.g. a working copy while editing rules outside the repository checkout. +RULES_DIR_ENV = "DUALECT_RULES_DIR" + +_PACKAGE_DIR = Path(__file__).resolve().parent + + +def default_rules_dir() -> Path: + """Return the rules folder dualect should use when none is given. + + Order: the ``DUALECT_RULES_DIR`` environment variable; the repository's + ``rules/`` next to the package (a source checkout or editable install); the + copy bundled into a built wheel as ``dualect/_rules``. + + :returns: path to the folder holding ``//`` subfolders. + """ + override = os.environ.get(RULES_DIR_ENV) + if override: + return Path(override) + source_tree = _PACKAGE_DIR.parent / "rules" + if source_tree.is_dir(): + return source_tree + return _PACKAGE_DIR / "_rules" + + +def schema_path() -> Path: + """Return the path of the JSON Schema that every ``rule.yaml`` must satisfy.""" + return _PACKAGE_DIR / "schema" / "rule.schema.json" diff --git a/dualect/pipeline.py b/dualect/pipeline.py new file mode 100644 index 0000000..d47fa29 --- /dev/null +++ b/dualect/pipeline.py @@ -0,0 +1,304 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""``dualect translate``: the whole pipeline of docs/design.md section 5. + +parse -> scan -> plan -> translate -> emit -> verify -> report, in either +direction: a ``.m`` source becomes Python (planning and translation statement +by statement in :mod:`dualect.emit`), a ``.py`` source becomes ``.m`` code +(lifted into the IR by :mod:`dualect.lift`, printed by :mod:`dualect.memit`). +This module +assembles the file (header, imports, ruff formatting), writes it, verifies it +against the source by execution, and reports every statement with the rules +it needed, the status used and whether the result was verified. + +The output always says what it is. Its first line states whether the file was +verified; untranslated statements are holes that raise ``NotImplementedError``; +an unverified file is labelled UNVERIFIED with the reason. +""" + +import dataclasses +from dataclasses import dataclass, field +from pathlib import Path + +from dualect import memit +from dualect.compare import Tolerance +from dualect.dialect import Dialect +from dualect.emit import Context, StmtReport, render +from dualect.errors import DualectError, ExecutionError, RuntimeMissingError +from dualect.lift import lift_python +from dualect.pyformat import format_python +from dualect.rulebook import FROM_PYTHON, TO_PYTHON, Rule, Status +from dualect.runners import MRunner +from dualect.scan import RuleIndex, ScanResult, scan_python_text, scan_text +from dualect.translators import TranslatorSet +from dualect.verify import VerifyResult, options_for_pair, parse_directives, verify_pair + +UNVERIFIED = "UNVERIFIED" + + +class StrictModeError(DualectError): + """``--strict``: the file needs guided or unsupported translation.""" + + +@dataclass +class Translation: + """The result of translating one file. + + :param source_name: the ``.m`` file. + :param code: the Python source (formatted), without the status header. + :param statements: one report per statement, in source order. + :param scan: the scan the translation was planned from. + :param verify: the verification result, when verification ran. + :param verify_note: why verification did not run, or how it failed. + :param rules_used: the rules the file needed. + :param direction: ``to-python`` (``.m`` source) or ``from-python`` (``.py`` source). + """ + + source_name: str + code: str + statements: list[StmtReport] + scan: ScanResult + verify: VerifyResult | None = None + verify_note: str = "" + rules_used: list[Rule] = field(default_factory=list) + direction: str = TO_PYTHON + + @property + def comment(self) -> str: + """The comment marker of the output language.""" + return "#" if self.direction == TO_PYTHON else "%" + + @property + def source_kind(self) -> str: + """The source language's file suffix.""" + return ".m" if self.direction == TO_PYTHON else ".py" + + @property + def holes(self) -> list[StmtReport]: + """Statements that were not translated mechanically.""" + return [s for s in self.statements if s.status is not Status.MECHANICAL] + + @property + def complete(self) -> bool: + """Every statement was translated mechanically.""" + return not self.holes + + @property + def verified(self) -> bool: + """The output ran and matched the source on every compared variable.""" + return self.verify is not None and self.verify.ok + + def header(self) -> str: + """The first line of the output file: what this file is and whether it was checked.""" + name = Path(self.source_name).name + mark = self.comment + if self.verified: + return ( + f"{mark} Translated from {name} by dualect; " + f"verified against the {self.source_kind} source." + ) + reason = self.verify_note or "not verified" + return f"{mark} Translated from {name} by dualect. {UNVERIFIED}: {reason}." + + def text(self) -> str: + """The complete output file.""" + return f"{self.header()}\n{self.code}" + + def report(self) -> str: + """Per-statement report: location, status used, verified, rules.""" + verified = "yes" if self.verified else "no" + lines = [f"translate {self.source_name}"] + for stmt in self.statements: + rules = ", ".join(stmt.rules) or "-" + status = stmt.status.value + lines.append( + f" {str(stmt.loc):<7} {stmt.kind:<10} {status:<11} {verified:<3} {rules}" + ) + if stmt.reason: + lines.append(f" {stmt.reason}") + counts = {status: 0 for status in Status} + for stmt in self.statements: + counts[stmt.status] += 1 + lines.append( + f"{len(self.statements)} statements: {counts[Status.MECHANICAL]} mechanical, " + f"{counts[Status.GUIDED]} guided, {counts[Status.UNSUPPORTED]} unsupported" + ) + if self.verify is not None: + lines.append(self.verify.report()) + if self.verified: + lines.append("verified: yes") + else: + lines.append(f"verified: no ({self.verify_note or 'not run'})") + if not self.complete: + lines.append( + "untranslated statements are marked TODO(dualect) in the output; " + f"`dualect context {self.source_name}` prints the rules an LLM needs for them" + ) + return "\n".join(lines) + + +def translate_scan( + *, scan: ScanResult, index: RuleIndex, translators: TranslatorSet +) -> Translation: + """Translate a scanned file into formatted Python (no verification). + + :param scan: the scanner's result for the file. + :param index: the rules, by construct tag. + :param translators: the rules' translator modules. + """ + ctx = Context( + scan=scan, + translator_for=translators.get, + rule_for=index.rule_for, + rule_by_id=index.rule_by_id, + ) + ctx.enter_script() + lines = ctx.statements(scan.program.body) + body = render(lines) + imports = "".join(f"{line}\n" for line in sorted(ctx.imports)) + code = format_python(f"{imports}\n{body}" if imports else body) + return Translation( + source_name=scan.source_name, + code=code, + statements=ctx.reports, + scan=scan, + rules_used=scan.needed_rules(), + ) + + +def translate_text( + *, text: str, name: str, rules: list[Rule], dialect: Dialect, strict: bool = False +) -> Translation: + """Scan and translate ``.m`` source text (no verification). + + :param text: the source. + :param name: its file name, for reports. + :param rules: all loaded rules. + :param dialect: the source dialect. + :param strict: raise :class:`StrictModeError` instead of leaving holes. + """ + index = RuleIndex(rules=rules, dialect=dialect) + scan = scan_text(text=text, name=name, index=index) + result = translate_scan(scan=scan, index=index, translators=TranslatorSet(rules=rules)) + if strict and not result.complete: + raise StrictModeError( + f"--strict: {len(result.holes)} statement(s) need guided or unsupported " + f"translation\n{result.report()}" + ) + return result + + +def translate_python_text( + *, text: str, name: str, rules: list[Rule], strict: bool = False +) -> Translation: + """Lift and print Python source as ``.m`` code (no verification). + + :param text: the source. + :param name: its file name, for reports. + :param rules: all loaded rules. + :param strict: raise :class:`StrictModeError` instead of leaving holes. + """ + translators = TranslatorSet(rules=rules) + lifted = lift_python(text=text, name=name, rules=rules, translator_for=translators.get) + scan = scan_python_text(text=text, name=name, rules=rules) + result = Translation( + source_name=name, + code=memit.program(lifted.body), + statements=lifted.reports, + scan=scan, + rules_used=scan.needed_rules(), + direction=FROM_PYTHON, + ) + if strict and not result.complete: + raise StrictModeError( + f"--strict: {len(result.holes)} statement(s) need guided or unsupported " + f"translation\n{result.report()}" + ) + return result + + +def tolerance_for(rules: list[Rule]) -> Tolerance: + """The loosest per-rule tolerance among the rules used (or the default).""" + tolerance = Tolerance() + rtol, atol = tolerance.rtol, tolerance.atol + for rule in rules: + rtol = max(rtol, rule.tolerance.get("rtol", rtol)) + atol = max(atol, rule.tolerance.get("atol", atol)) + return Tolerance(rtol=rtol, atol=atol) + + +def verify_translation( + *, result: Translation, source: Path, output: Path, runner: MRunner | None = None +) -> None: + """Run the source and the written output and compare; updates ``result``. + + :param result: the translation (already written to ``output``). + :param source: the ``.m`` file. + :param output: the ``.py`` file. + :param runner: an Octave session to reuse. + """ + if not result.complete: + result.verify_note = f"{len(result.holes)} statement(s) not translated" + return + if result.direction == TO_PYTHON: + m_path, py_path = source, output + options = options_for_pair( + m_path=m_path, py_path=py_path, tolerance=tolerance_for(result.rules_used) + ) + else: + m_path, py_path = output, source + # The source's own `index` directives describe its pairing with some + # other .m file; the generated .m keeps Python's values, so only its + # own directives (and either side's `ignore`) apply. + generated = options_for_pair( + m_path=m_path, py_path=m_path, tolerance=tolerance_for(result.rules_used) + ) + _index, ignored = parse_directives(text=source.read_text(encoding="utf-8"), path=source) + options = dataclasses.replace(generated, ignore=generated.ignore | ignored) + try: + result.verify = verify_pair(m_path=m_path, py_path=py_path, options=options, runner=runner) + except RuntimeMissingError as exc: + result.verify_note = f"cannot run the .m side ({exc})" + return + except ExecutionError as exc: + result.verify_note = f"execution failed: {exc}" + return + if not result.verify.ok: + result.verify_note = f"outputs differ from the {result.source_kind} source" + + +def translate_file( + *, + source: Path, + output: Path, + rules: list[Rule], + dialect: Dialect, + strict: bool = False, + verify: bool = True, + runner: MRunner | None = None, +) -> Translation: + """The full pipeline for one file: translate, write, verify, rewrite the header. + + :param source: the ``.m`` file (or a ``.py`` file, for the other direction). + :param output: where to write the ``.py`` (or the ``.m``). + :param rules: all loaded rules. + :param dialect: the source dialect (of a ``.m`` source). + :param strict: stop (raise, write nothing) unless every statement is mechanical. + :param verify: run both sides and compare (needs Octave). + :param runner: an Octave session to reuse. + """ + text = source.read_text(encoding="utf-8") + if source.suffix == ".py": + result = translate_python_text(text=text, name=str(source), rules=rules, strict=strict) + else: + result = translate_text( + text=text, name=str(source), rules=rules, dialect=dialect, strict=strict + ) + if not verify: + result.verify_note = "verification was not requested" + output.write_text(result.text(), encoding="utf-8") + if verify: + verify_translation(result=result, source=source, output=output, runner=runner) + output.write_text(result.text(), encoding="utf-8") + return result diff --git a/dualect/promotion.py b/dualect/promotion.py new file mode 100644 index 0000000..5026d96 --- /dev/null +++ b/dualect/promotion.py @@ -0,0 +1,272 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""The promotion check (docs/design.md section 4.3): does a rule earn ``mechanical``? + +For each rule and each direction it declares, every case is run through the +deterministic translator and checked twice: + +* **layer 2** (section 7): the translation is the same code as the case's + hand-written target. To Python, both are compared after formatting with + comments ignored (:func:`dualect.pyformat.same_code`). From Python, the + generated ``.m`` and the hand-written ``.m`` are both lowered into the IR and + compared structurally; the hand-written ``.m`` files are idiomatic sources + written for the other direction (positions 1-based, ``x(end)`` forms), so + this match is reported but not required from Python. +* **execution**: the translation runs and matches the source by value. + +A direction *qualifies* for ``mechanical`` when the rule has its translator, +every case translates with no hole, every required layer-2 match holds and, +when verification runs, every case verifies. The check fails for a rule +marked ``mechanical`` that does not qualify, and for a ``guided`` rule that +does (it should be promoted); a rule with no case cannot qualify. +""" + +import tempfile +from dataclasses import dataclass, field, fields, is_dataclass +from pathlib import Path +from typing import Any + +from dualect import ir +from dualect.dialect import Dialect +from dualect.errors import DualectError +from dualect.lower import lower_source +from dualect.pipeline import Translation, translate_file, translate_python_text, translate_text +from dualect.pyformat import same_code +from dualect.rulebook import DIRECTIONS, TO_PYTHON, CasePair, Rule, Status +from dualect.runners import MRunner +from dualect.translators import load_translator + + +@dataclass +class CaseCheck: + """One case in one direction. + + :param name: the case name. + :param complete: translated with no hole. + :param layer2: matches the hand-written target (``None`` when not checked). + :param verified: verified by execution (``None`` when not run). + :param note: why it failed, briefly. + """ + + name: str + complete: bool + layer2: bool | None + verified: bool | None + note: str = "" + + +@dataclass +class RuleCheck: + """One rule in one direction. + + :param rule_id: the rule. + :param direction: ``to-python`` or ``from-python``. + :param declared: the status the rule declares for this direction. + :param cases: per-case results. + :param qualifies: whether the evidence supports ``mechanical``. + :param reasons: what keeps it from qualifying. + """ + + rule_id: str + direction: str + declared: Status + cases: list[CaseCheck] = field(default_factory=list) + qualifies: bool = False + reasons: list[str] = field(default_factory=list) + + @property + def problem(self) -> str | None: + """Why the declared status disagrees with the evidence, or ``None``.""" + if self.declared is Status.MECHANICAL and not self.qualifies: + return "marked mechanical but does not qualify: " + "; ".join(self.reasons) + if self.declared is Status.GUIDED and self.qualifies: + return "qualifies for mechanical: promote it" + return None + + def line(self) -> str: + """One summary line.""" + verdict = "qualifies" if self.qualifies else "does not qualify" + problem = self.problem + mark = "FAIL" if problem else "ok " + if self.direction != TO_PYTHON and self.cases: + # Informational from Python (see the module docstring). + matched = sum(1 for case in self.cases if case.layer2) + verdict += f", layer 2 {matched}/{len(self.cases)}" + detail = ( + f" ({problem})" + if problem + else f" ({'; '.join(self.reasons)})" + if self.reasons + else "" + ) + return ( + f"{mark} {self.rule_id:<32} {self.direction:<11} {self.declared.value:<11} " + f"{verdict}{detail}" + ) + + +def _has_translator(rule: Rule, direction: str) -> bool: + module = load_translator(rule) + if module is None: + return False + name = "translate" if direction == TO_PYTHON else "lift" + return callable(getattr(module, name, None)) + + +def _fingerprint(node: Any) -> Any: + """A structural key of IR nodes: kinds and values, without locations or comments.""" + if isinstance(node, list): + return [_fingerprint(item) for item in node if not isinstance(item, ir.Comment)] + if isinstance(node, tuple): + return tuple(_fingerprint(item) for item in node) + if is_dataclass(node) and not isinstance(node, type): + skip = {"loc", "comment", "syntax", "source_name", "text"} + if isinstance(node, ir.End): + skip |= {"target"} # a back-reference, not a child + values = [ + (f.name, _fingerprint(getattr(node, f.name))) + for f in fields(node) + if f.name not in skip + ] + if isinstance(node, ir.Num): + values.append(("value", complex(node.value))) + return (type(node).__name__, tuple(values)) + return node + + +def same_m_code(a: str, b: str) -> bool: + """Whether two ``.m`` sources lower to the same IR (layout and comments ignored).""" + try: + return _fingerprint(lower_source(text=a).body) == _fingerprint(lower_source(text=b).body) + except (DualectError, ValueError): + return False + + +def _translate(case: CasePair, direction: str, rules: list[Rule]) -> Translation: + if direction == TO_PYTHON: + text = case.m_path.read_text(encoding="utf-8") + return translate_text(text=text, name=str(case.m_path), rules=rules, dialect=Dialect()) + text = case.py_path.read_text(encoding="utf-8") + return translate_python_text(text=text, name=str(case.py_path), rules=rules) + + +def check_case( + *, case: CasePair, direction: str, rules: list[Rule], runner: MRunner | None +) -> CaseCheck: + """Translate one case in one direction; check layer 2 and (with a runner) execution. + + :param case: the case pair. + :param direction: ``to-python`` or ``from-python``. + :param rules: all loaded rules. + :param runner: an Octave session for verification, or ``None`` to skip it. + """ + try: + result = _translate(case, direction, rules) + except DualectError as exc: + return CaseCheck(name=case.name, complete=False, layer2=False, verified=None, note=str(exc)) + target = case.py_path if direction == TO_PYTHON else case.m_path + expected = target.read_text(encoding="utf-8") + if direction == TO_PYTHON: + layer2 = same_code(result.code, expected) + else: + layer2 = same_m_code(result.code, expected) + check = CaseCheck(name=case.name, complete=result.complete, layer2=layer2, verified=None) + if not result.complete: + check.note = "; ".join(f"line {h.loc.line}: {h.reason}" for h in result.holes) + return check + if runner is None: + return check + source = case.m_path if direction == TO_PYTHON else case.py_path + suffix = ".py" if direction == TO_PYTHON else ".m" + with tempfile.TemporaryDirectory() as scratch: + output = Path(scratch) / f"{case.name}{suffix}" + verified = translate_file( + source=source, output=output, rules=rules, dialect=Dialect(), runner=runner + ) + check.verified = verified.verified + if not verified.verified: + check.note = verified.verify_note + return check + + +def check_rule( + *, rule: Rule, direction: str, rules: list[Rule], runner: MRunner | None +) -> RuleCheck | None: + """Check one rule in one direction (``None`` when it declares nothing for it). + + :param rule: the rule. + :param direction: ``to-python`` or ``from-python``. + :param rules: all loaded rules. + :param runner: an Octave session for verification, or ``None`` to skip it. + """ + declared = rule.status_for(direction) + if declared is None: + return None + result = RuleCheck(rule_id=rule.id, direction=direction, declared=declared) + if not rule.cases: + result.reasons.append("no cases") + if not _has_translator(rule, direction): + name = "translate()" if direction == TO_PYTHON else "lift()" + result.reasons.append(f"no {name} in translate.py") + else: + result.cases = [ + check_case(case=case, direction=direction, rules=rules, runner=runner) + for case in rule.cases + ] + for case in result.cases: + if not case.complete: + result.reasons.append(f"{case.name}: holes ({case.note})") + elif direction == TO_PYTHON and not case.layer2: + result.reasons.append(f"{case.name}: differs from the hand-written .py") + elif case.verified is False: + result.reasons.append(f"{case.name}: does not verify ({case.note})") + result.qualifies = not result.reasons + if result.qualifies and runner is None and declared is not Status.MECHANICAL: + # Without execution there is no evidence enough to ask for a promotion. + result.qualifies = False + result.reasons.append("not verified by execution") + return result + + +def check_rules( + *, + rules: list[Rule], + selected: list[str] | None = None, + directions: tuple[str, ...] = DIRECTIONS, + verify: bool = True, +) -> list[RuleCheck]: + """Check rules in the given directions. + + :param rules: all loaded rules (translations need every rule). + :param selected: rule ids to check (default: all). + :param directions: which directions. + :param verify: run the translations (needs GNU Octave). + :raises DualectError: for an unknown rule id. + """ + known = {rule.id for rule in rules} + unknown = [rule_id for rule_id in selected or [] if rule_id not in known] + if unknown: + raise DualectError(f"no such rule: {', '.join(unknown)}") + chosen = [rule for rule in rules if not selected or rule.id in selected] + results: list[RuleCheck] = [] + runner = MRunner() if verify else None + try: + for rule in chosen: + for direction in directions: + checked = check_rule(rule=rule, direction=direction, rules=rules, runner=runner) + if checked is not None: + results.append(checked) + finally: + if runner is not None: + runner.close() + return results + + +def report(results: list[RuleCheck], *, verified: bool) -> str: + """The check as text: one line per rule and direction, then a summary.""" + lines = [check.line() for check in results] + problems = [check for check in results if check.problem] + mode = "" if verified else " (not verified by execution: --no-verify)" + lines.append(f"{len(results)} checked, {len(problems)} with a status problem{mode}") + return "\n".join(lines) diff --git a/dualect/py.typed b/dualect/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/dualect/pyconstructs.py b/dualect/pyconstructs.py new file mode 100644 index 0000000..80c1088 --- /dev/null +++ b/dualect/pyconstructs.py @@ -0,0 +1,342 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Construct tags for Python source (the Python -> ``.m`` direction). + +The ``.m`` scanner tags what a statement uses (:mod:`dualect.constructs`); this +module does the same for Python, with tags in the ``py:`` namespace: +``py:op:matmult``, ``py:call:np.zeros``, ``py:method:sum``, ``py:attr:T``, +``py:subscript``, ``py:for``, ... Each rule lists the Python tags it covers +under ``from_python: match:`` in its ``rule.yaml``, next to the ``.m`` tags it +covers under ``match:``, so one rule folder serves both directions. A tag that +no rule matches is reported as unsupported by that tag (``py:call:np.fft.fft``, +``py:stmt:try``), which is the named error of the design. + +Core constructs that mean the same in both languages carry no tag: names, +numbers, ``True``/``False``, plain assignment to a name, ``import numpy as +np``, ``pass`` and ``x.copy()`` (the ``.m`` side always copies). +""" + +import ast +from dataclasses import dataclass + +from dualect import ir +from dualect.pyinfer import PyAnalysis, PyKind, dotted + +#: Tag families (besides ``py:call:``, ``py:method:``, +#: ``py:attr:``, ``py:const:``, ``py:import:``, +#: ``py:stmt:`` and ``py:expr:``, whose names are open-ended). +PY_VOCABULARY: dict[str, str] = { + "py:comment": "a # comment", + "py:subscript": "indexing x[i], A[i, j]", + "py:index:negative": "a negative index x[-1] (counts from the end)", + "py:index:slice": "a slice x[a:b:c]", + "py:index:mask": "indexing with a boolean mask", + "py:index:newaxis": "a new axis c[:, np.newaxis]", + "py:list": "a list literal", + "py:tuple": "a tuple literal", + "py:str": "a string literal", + "py:fstring": "an f-string", + "py:complex": "an imaginary literal 2j", + "py:none": "None", + "py:ifexp": "a conditional expression a if c else b", + "py:lambda": "a lambda", + "py:call-local": "a call to a function defined in the same file", + "py:call-handle": "a call through a variable holding a lambda", + "py:assign-multi": "unpacking several values: a, b = f(x)", + "py:assign-store": "assigning into an element or slice", + "py:augassign": "x += e and friends", + "py:for": "a for loop", + "py:while": "a while loop", + "py:if": "if / elif / else", + "py:match": "match / case", + "py:break": "break", + "py:continue": "continue", + "py:def": "a function definition", + "py:def-default": "a parameter with a default value", + "py:return": "return", + "py:return-multi": "returning several values", + "py:cmp:chain": "a chained comparison a < b < c", +} +for _op in ("add", "sub", "mult", "matmult", "div", "floordiv", "mod", "pow", "lshift", + "rshift", "bitor", "bitxor", "bitand", "usub", "uadd", "not", "invert"): # fmt: skip + PY_VOCABULARY[f"py:op:{_op}"] = f"the Python {_op} operator" +for _cmp in ("eq", "noteq", "lt", "lte", "gt", "gte", "is", "isnot", "in", "notin"): + PY_VOCABULARY[f"py:cmp:{_cmp}"] = f"the {_cmp} comparison" +for _bool in ("and", "or"): + PY_VOCABULARY[f"py:boolop:{_bool}"] = f"the {_bool} operator" + +_OPEN_FAMILIES = ("py:call:", "py:method:", "py:attr:", "py:const:", "py:import:", "py:stmt:", + "py:expr:") # fmt: skip + + +def is_known_py_tag(tag: str) -> bool: + """Whether a ``py:`` tag is in the vocabulary (open families always are).""" + if tag in PY_VOCABULARY: + return True + return any(tag.startswith(family) and len(tag) > len(family) for family in _OPEN_FAMILIES) + + +@dataclass(frozen=True) +class PyUse: + """One use of a Python construct. + + :param tag: the construct tag. + :param loc: where it is. + """ + + tag: str + loc: ir.Loc + + +def loc_of(node: ast.AST) -> ir.Loc: + """The span of a Python node, in the IR's 1-based convention.""" + line = getattr(node, "lineno", 0) + col = getattr(node, "col_offset", 0) + 1 + end_line = getattr(node, "end_lineno", None) or line + end_col = (getattr(node, "end_col_offset", None) or 0) + 1 + return ir.Loc(line, col, end_line, end_col) + + +_OPS = { + ast.Add: "add", ast.Sub: "sub", ast.Mult: "mult", ast.MatMult: "matmult", ast.Div: "div", + ast.FloorDiv: "floordiv", ast.Mod: "mod", ast.Pow: "pow", ast.LShift: "lshift", + ast.RShift: "rshift", ast.BitOr: "bitor", ast.BitXor: "bitxor", ast.BitAnd: "bitand", + ast.USub: "usub", ast.UAdd: "uadd", ast.Not: "not", ast.Invert: "invert", +} # fmt: skip +_CMPS = { + ast.Eq: "eq", ast.NotEq: "noteq", ast.Lt: "lt", ast.LtE: "lte", ast.Gt: "gt", + ast.GtE: "gte", ast.Is: "is", ast.IsNot: "isnot", ast.In: "in", ast.NotIn: "notin", +} # fmt: skip + + +def op_name(op: ast.operator | ast.unaryop) -> str: + """The tag name of an operator (``add``, ``matmult``, ``usub``, ...).""" + return _OPS[type(op)] + + +def cmp_name(op: ast.cmpop) -> str: + """The tag name of a comparison (``eq``, ``lt``, ...).""" + return _CMPS[type(op)] + + +class Tagger: + """Tags Python nodes, given the inference results (names need them).""" + + def __init__(self, *, analysis: PyAnalysis, functions: set[str]) -> None: + """:param analysis: inference results. :param functions: names of the file's ``def``s.""" + self.analysis = analysis + self.functions = functions + + @property + def alias(self) -> str | None: + """The numpy alias.""" + return self.analysis.numpy_alias + + def primary(self, node: ast.AST) -> str | None: + """The tag whose rule lifts ``node`` itself (``None`` for core nodes).""" + match node: + case ast.Constant(value=value): + if isinstance(value, str): + return "py:str" + if isinstance(value, complex): + return "py:complex" + if value is None: + return "py:none" + return None + case ast.Name(): + return None + case ast.BinOp(op=op) | ast.UnaryOp(op=op): + return f"py:op:{op_name(op)}" + case ast.Compare(ops=ops): + return f"py:cmp:{cmp_name(ops[0])}" if len(ops) == 1 else "py:cmp:chain" + case ast.BoolOp(op=op): + return "py:boolop:and" if isinstance(op, ast.And) else "py:boolop:or" + case ast.Subscript(): + return "py:subscript" + case ast.Attribute(): + name = dotted(node, self.alias) + if name is not None: + return f"py:const:{name}" + return f"py:attr:{node.attr}" + case ast.Call(): + return self.call_tag(node) + case ast.List(): + return "py:list" + case ast.Tuple(): + return "py:tuple" + case ast.JoinedStr(): + return "py:fstring" + case ast.IfExp(): + return "py:ifexp" + case ast.Lambda(): + return "py:lambda" + return f"py:expr:{type(node).__name__}" + + def call_tag(self, node: ast.Call) -> str: + """``py:call:np.zeros``, ``py:call:abs``, ``py:method:sum``, ``py:call-local``, ...""" + func = node.func + name = dotted(func, self.alias) + if name is not None: + return f"py:call:{name}" + if isinstance(func, ast.Attribute): + if func.attr == "copy" and not node.args and not node.keywords: + return "py:method:copy" + return f"py:method:{func.attr}" + if isinstance(func, ast.Name): + info = self.analysis.info(func) + if info.kind is PyKind.FUNC: + return "py:call-handle" + if func.id in self.functions: + return "py:call-local" + return f"py:call:{func.id}" + return "py:expr:call-expression" + + def expression_uses(self, node: ast.AST) -> list[PyUse]: + """Every tag inside an expression tree (lambdas included).""" + uses: list[PyUse] = [] + self._walk(node, uses) + return uses + + def _walk(self, node: ast.AST, uses: list[PyUse]) -> None: + if isinstance(node, ast.expr) and not isinstance(node, ast.Slice): + tag = self.primary(node) + if tag is not None and tag != "py:method:copy": + uses.append(PyUse(tag, loc_of(node))) + if isinstance(node, ast.Subscript): + uses.extend(self.subscript_uses(node)) + if isinstance(node, ast.Attribute) and dotted(node, self.alias) is not None: + return # `np.linalg.solve` is one name, not three + if isinstance(node, ast.Call): + func = node.func + if isinstance(func, ast.Attribute) and dotted(func, self.alias) is None: + self._walk(func.value, uses) # the receiver of a method + for arg in node.args: + self._walk(arg, uses) + for keyword in node.keywords: + self._walk(keyword.value, uses) + return + if isinstance(node, ast.JoinedStr): + return # its pieces belong to the f-string + if isinstance(node, ast.Lambda): + for default in node.args.defaults: + self._walk(default, uses) + self._walk(node.body, uses) + return + for child in ast.iter_child_nodes(node): + if isinstance(child, ast.expr | ast.keyword | ast.comprehension): + self._walk(child, uses) + + def subscript_uses(self, node: ast.Subscript) -> list[PyUse]: + """Extra tags of one subscript: slices, negative indices, masks, new axes.""" + uses = [] + parts = node.slice.elts if isinstance(node.slice, ast.Tuple) else [node.slice] + for part in parts: + loc = loc_of(part) + if isinstance(part, ast.Slice): + uses.append(PyUse("py:index:slice", loc)) + bounds = [part.lower, part.upper] + if any(b is not None and _negative(b) for b in bounds): + uses.append(PyUse("py:index:negative", loc)) + elif dotted(part, self.alias) == "np.newaxis" or ( + isinstance(part, ast.Constant) and part.value is None + ): + uses.append(PyUse("py:index:newaxis", loc)) + elif _negative(part): + uses.append(PyUse("py:index:negative", loc)) + elif self.analysis.info(part).is_bool and not self.analysis.info(part).is_scalar: + uses.append(PyUse("py:index:mask", loc)) + return uses + + def statement_uses(self, stmt: ast.stmt) -> list[PyUse]: + """Tags of one statement itself (headers, not nested bodies).""" + loc = loc_of(stmt) + uses: list[PyUse] = [] + add = uses.append + match stmt: + case ast.Assign(targets=targets, value=value): + if len(targets) > 1: + add(PyUse("py:stmt:chained-assign", loc)) + for target in targets: + if isinstance(target, ast.Tuple | ast.List): + add(PyUse("py:assign-multi", loc)) + elif isinstance(target, ast.Subscript): + add(PyUse("py:assign-store", loc)) + uses.extend(self.expression_uses(target)) + elif not isinstance(target, ast.Name): + uses.extend(self.expression_uses(target)) + uses.extend(self.expression_uses(value)) + case ast.AugAssign(target=target, op=op, value=value): + add(PyUse("py:augassign", loc)) + add(PyUse(f"py:op:{op_name(op)}", loc)) + if not isinstance(target, ast.Name): + uses.extend(self.expression_uses(target)) + uses.extend(self.expression_uses(value)) + case ast.Expr(value=value): + if isinstance(value, ast.Constant) and isinstance(value.value, str): + add(PyUse("py:comment", loc)) # a docstring + else: + uses.extend(self.expression_uses(value)) + case ast.For(target=target, iter=iterable, orelse=orelse): + add(PyUse("py:for", loc)) + if orelse: + add(PyUse("py:stmt:for-else", loc)) + if not isinstance(target, ast.Name): + add(PyUse("py:stmt:for-unpack", loc)) + uses.extend(self.expression_uses(iterable)) + case ast.While(test=test, orelse=orelse): + add(PyUse("py:while", loc)) + if orelse: + add(PyUse("py:stmt:while-else", loc)) + uses.extend(self.expression_uses(test)) + case ast.If(test=test): + add(PyUse("py:if", loc)) + uses.extend(self.expression_uses(test)) + # elif chains are nested If nodes in orelse: tag their tests here. + orelse = stmt.orelse + while len(orelse) == 1 and isinstance(orelse[0], ast.If): + uses.extend(self.expression_uses(orelse[0].test)) + orelse = orelse[0].orelse + case ast.Match(subject=subject): + add(PyUse("py:match", loc)) + uses.extend(self.expression_uses(subject)) + case ast.Break(): + add(PyUse("py:break", loc)) + case ast.Continue(): + add(PyUse("py:continue", loc)) + case ast.Return(value=value): + add(PyUse("py:return", loc)) + if isinstance(value, ast.Tuple): + add(PyUse("py:return-multi", loc)) + for item in value.elts: + uses.extend(self.expression_uses(item)) + elif value is not None: + uses.extend(self.expression_uses(value)) + case ast.FunctionDef(args=args, decorator_list=decorators): + add(PyUse("py:def", loc)) + if args.defaults: + add(PyUse("py:def-default", loc)) + if args.vararg or args.kwarg or args.kwonlyargs or args.posonlyargs: + add(PyUse("py:stmt:def-varargs", loc)) + if decorators: + add(PyUse("py:stmt:decorator", loc)) + case ast.Import(names=names): + for alias in names: + if alias.name != "numpy": + add(PyUse(f"py:import:{alias.name}", loc)) + case ast.ImportFrom(module=module): + add(PyUse(f"py:import:{module or '.'}", loc)) + case ast.Pass(): + pass + case _: + add(PyUse(f"py:stmt:{type(stmt).__name__.lower()}", loc)) + return uses + + +def _negative(node: ast.expr) -> bool: + """A literal negative index, or an expression that starts with one (``-1 - n``).""" + if isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.USub): + return True + if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Add | ast.Sub): + return _negative(node.left) + return False diff --git a/dualect/pyformat.py b/dualect/pyformat.py new file mode 100644 index 0000000..01021d0 --- /dev/null +++ b/dualect/pyformat.py @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Formatting emitted Python with ruff, and comparing code structurally. + +The comparison is testing layer 2 of docs/design.md section 7: a translator's +output must match the hand-written ``.py`` of each case *after formatting*. +Both sides are parsed and printed back with :func:`ast.unparse`, which is +formatting-independent and drops comments: comments in case files are +teaching notes, not code, so they are not part of the match. +""" + +import ast +import subprocess + +from dualect.errors import DualectError + + +class FormatError(DualectError): + """ruff could not format the emitted code (a bug in a translator).""" + + +def _ruff() -> str: + from ruff.__main__ import find_ruff_bin # deferred: only needed when formatting + + return str(find_ruff_bin()) + + +def format_python(text: str) -> str: + """Format Python source with ruff's defaults (no project configuration). + + :param text: the source. + :raises FormatError: if ruff rejects it (the text is not valid Python). + """ + result = subprocess.run( + [_ruff(), "format", "--isolated", "--stdin-filename", "dualect_output.py", "-"], + input=text, + capture_output=True, + text=True, + check=False, + ) + if result.returncode != 0: + raise FormatError(f"ruff format failed: {result.stderr.strip()}") + return result.stdout + + +def normalized_code(text: str) -> str: + """The code of a Python file, with formatting and comments normalized away.""" + return ast.unparse(ast.parse(text)) + + +def same_code(a: str, b: str) -> bool: + """Whether two Python sources are the same code, ignoring layout and comments.""" + return normalized_code(a) == normalized_code(b) diff --git a/dualect/pyinfer.py b/dualect/pyinfer.py new file mode 100644 index 0000000..880993b --- /dev/null +++ b/dualect/pyinfer.py @@ -0,0 +1,939 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Shape and type inference over Python source (the Python -> ``.m`` direction). + +The ``.m`` -> Python direction infers facts over the IR (:mod:`dualect.infer`); +this module does the same job for a Python :mod:`ast` tree, *before* it is +lifted into the IR, because the lifting itself depends on the facts: ``A @ v`` +is ``(A * v.').'`` when ``v`` is a 1-D array and ``A * B`` when both are 2-D, +``x[i]`` is an element of a vector but a whole row of a matrix, and +``x.max()`` may only become ``max(x)`` when ``x`` holds no NaN (the ``.m`` +``max`` skips NaN, NumPy's propagates it). + +Facts describe *NumPy* semantics: a :attr:`PyKind.VECTOR` is a 1-D array +(it becomes a ``1xN`` row in ``.m`` code), a :attr:`PyKind.MATRIX` a 2-D +array. The analysis is flow-sensitive within a body, joins branches, runs loop +bodies to a fixed point and analyses each function (and lambda) once for the +join of the arguments at its call sites, like :mod:`dualect.infer`. +""" + +from __future__ import annotations + +import ast +import math +from dataclasses import dataclass, field, replace +from enum import StrEnum + + +class PyKind(StrEnum): + """Coarse shape class of a Python value.""" + + SCALAR = "scalar" # a Python or NumPy number (or bool) + VECTOR = "vector" # a 1-D array + MATRIX = "matrix" # a 2-D array + STRING = "string" + FUNC = "func" + LIST = "list" # a list literal (an argument to np functions) + TUPLE = "tuple" + RANGE = "range" # range(...) + NONE = "none" + MODULE = "module" # the numpy module (or np.linalg) + UNKNOWN = "unknown" + + +class DType(StrEnum): + """Element type.""" + + BOOL = "bool" + INT = "int" + FLOAT = "float" + COMPLEX = "complex" + UNKNOWN = "unknown" + + +_ARRAYS = frozenset({PyKind.VECTOR, PyKind.MATRIX}) + + +@dataclass(frozen=True) +class PyInfo: + """What is known about one Python value. + + :param kind: shape class. + :param dtype: element type. + :param finite: known to hold no NaN or Inf. + :param nonneg: known to hold no negative value. + :param value: the exact value of a scalar constant, when known. + :param items: element facts of a tuple (``A.shape``, a multiple return). + :param length: number of elements of a vector, when known. + :param func: for a lambda value, its node. + :param module: for a module value, its dotted name (``"np"``, ``"np.linalg"``). + :param view: the value may share memory with another array (a slice, a + transpose, a plain alias): writing into it would change that array. + """ + + kind: PyKind = PyKind.UNKNOWN + dtype: DType = DType.UNKNOWN + finite: bool = False + nonneg: bool = False + value: int | float | complex | str | None = None + items: tuple[PyInfo, ...] | None = field(default=None, compare=False) + length: int | None = None + func: ast.Lambda | None = field(default=None, compare=False) + module: str | None = None + view: bool = False + + @property + def is_scalar(self) -> bool: + """A single number.""" + return self.kind is PyKind.SCALAR + + @property + def is_array(self) -> bool: + """A NumPy array (1-D or 2-D).""" + return self.kind in _ARRAYS + + @property + def is_vector(self) -> bool: + """A 1-D array.""" + return self.kind is PyKind.VECTOR + + @property + def is_matrix(self) -> bool: + """A 2-D array.""" + return self.kind is PyKind.MATRIX + + @property + def is_bool(self) -> bool: + """Boolean elements.""" + return self.dtype is DType.BOOL + + @property + def is_int(self) -> bool: + """Integer (or bool) elements: a NumPy store of a fraction would truncate.""" + return self.dtype in (DType.INT, DType.BOOL) + + +UNKNOWN = PyInfo() + + +def scalar( + dtype: DType = DType.FLOAT, + *, + finite: bool = True, + nonneg: bool = False, + value: int | float | complex | None = None, +) -> PyInfo: + """Facts for a scalar.""" + return PyInfo(kind=PyKind.SCALAR, dtype=dtype, finite=finite, nonneg=nonneg, value=value) + + +def array( + kind: PyKind, + dtype: DType = DType.FLOAT, + *, + finite: bool = False, + nonneg: bool = False, + length: int | None = None, +) -> PyInfo: + """Facts for an array.""" + return PyInfo(kind=kind, dtype=dtype, finite=finite, nonneg=nonneg, length=length) + + +def join(a: PyInfo, b: PyInfo) -> PyInfo: + """Facts that hold for a value that may be either ``a`` or ``b``.""" + if a == b and a.func is b.func: + return a + return PyInfo( + kind=a.kind if a.kind is b.kind else PyKind.UNKNOWN, + dtype=a.dtype if a.dtype is b.dtype else _promote(a.dtype, b.dtype, join=True), + finite=a.finite and b.finite, + nonneg=a.nonneg and b.nonneg, + value=a.value if a.value == b.value else None, + items=a.items if a.items == b.items else None, + length=a.length if a.length == b.length else None, + func=a.func if a.func is b.func else None, + module=a.module if a.module == b.module else None, + view=a.view or b.view, + ) + + +_ORDER = [DType.BOOL, DType.INT, DType.FLOAT, DType.COMPLEX] + + +def _promote(a: DType, b: DType, *, join: bool = False) -> DType: + """NumPy's result type for two element types (for a join: the wider one).""" + if DType.UNKNOWN in (a, b): + return DType.UNKNOWN + if join and a is not b: + return DType.UNKNOWN if DType.BOOL in (a, b) else max(a, b, key=_ORDER.index) + return max(a, b, key=_ORDER.index) + + +Env = dict[str, PyInfo] + + +def join_envs(a: Env, b: Env) -> Env: + """Join two environments; a name missing on one side is unknown.""" + return {name: join(a.get(name, UNKNOWN), b.get(name, UNKNOWN)) for name in a.keys() | b.keys()} + + +#: NumPy element-wise functions that keep the argument's shape. +ELEMENTWISE = frozenset( + {"abs", "sqrt", "exp", "log", "log2", "log10", "sin", "cos", "tan", "arcsin", "arccos", + "arctan", "sinh", "cosh", "tanh", "floor", "ceil", "trunc", "sign", "real", "imag", + "conj", "isnan", "isinf", "isfinite", "mod", "fmod", "arctan2", "hypot", "round"} +) # fmt: skip +_BOOL_RESULT = frozenset({"isnan", "isinf", "isfinite"}) +_REDUCTIONS = frozenset({"sum", "mean", "max", "min", "prod", "nanmax", "nanmin", "all", "any"}) +_NAN_FREE_RESULT = frozenset({"floor", "ceil", "trunc", "sign", "abs", "round", "conj"}) + + +@dataclass +class FunctionFacts: + """What the analysis learned about one ``def``. + + :param params: joined argument facts over all call sites. + :param result: facts about the returned value (a tuple for several). + """ + + params: list[PyInfo] + result: PyInfo = UNKNOWN + + +@dataclass +class PyAnalysis: + """Inference results for one Python module. + + :param infos: ``id(node)`` -> facts about that expression. + :param functions: ``def`` name -> facts. + :param numpy_alias: the name numpy is imported as (``"np"``), or ``None``. + :param env_before: ``id(stmt)`` -> environment before the statement. + """ + + infos: dict[int, PyInfo] = field(default_factory=dict) + functions: dict[str, FunctionFacts] = field(default_factory=dict) + numpy_alias: str | None = None + env_before: dict[int, Env] = field(default_factory=dict) + + def info(self, node: ast.AST) -> PyInfo: + """Facts about an expression (unknown when it was never analysed).""" + return self.infos.get(id(node), UNKNOWN) + + +def dotted(node: ast.expr, alias: str | None) -> str | None: + """``np.linalg.solve`` for an attribute chain rooted at the numpy alias, else ``None``.""" + parts: list[str] = [] + while isinstance(node, ast.Attribute): + parts.append(node.attr) + node = node.value + if isinstance(node, ast.Name) and alias is not None and node.id == alias: + return ".".join(["np", *reversed(parts)]) + return None + + +class _Inferrer: + def __init__(self, module: ast.Module) -> None: + self.module = module + self.analysis = PyAnalysis() + self.defs: dict[str, ast.FunctionDef] = {} + for stmt in module.body: + if isinstance(stmt, ast.FunctionDef): + self.defs[stmt.name] = stmt + if isinstance(stmt, ast.Import): + for alias in stmt.names: + if alias.name == "numpy": + self.analysis.numpy_alias = alias.asname or "numpy" + self.call_sites: dict[str, list[list[PyInfo]]] = {} + self.lambda_params: dict[int, list[PyInfo]] = {} + self.returns: list[PyInfo] = [] + + def run(self) -> PyAnalysis: + for name, fdef in self.defs.items(): + self.analysis.functions[name] = FunctionFacts(params=[UNKNOWN] * len(fdef.args.args)) + for _round in range(3): + self.call_sites = {} + self.lambda_params = {} + self.body(self.module.body, {}) + for name, fdef in self.defs.items(): + self.function(name, fdef) + return self.analysis + + def function(self, name: str, fdef: ast.FunctionDef) -> None: + facts = self.analysis.functions[name] + sites = self.call_sites.get(name, []) + params: list[PyInfo] = [] + defaults = fdef.args.defaults + first_default = len(fdef.args.args) - len(defaults) + for k, _arg in enumerate(fdef.args.args): + passed = [site[k] for site in sites if k < len(site)] + if k >= first_default and any(len(site) <= k for site in sites): + passed.append(self.expr(defaults[k - first_default], {})) + joined = passed[0] if passed else UNKNOWN + for info in passed[1:]: + joined = join(joined, info) + params.append(joined) + facts.params = params + env = {arg.arg: info for arg, info in zip(fdef.args.args, params, strict=True)} + outer = self.returns + self.returns = [] + try: + self.body(fdef.body, env) + result = self.returns[0] if self.returns else PyInfo(kind=PyKind.NONE) + for info in self.returns[1:]: + result = join(result, info) + facts.result = result + finally: + self.returns = outer + + # --- statements -------------------------------------------------------- + + def body(self, stmts: list[ast.stmt], env: Env) -> Env: + for stmt in stmts: + self.analysis.env_before[id(stmt)] = dict(env) + env = self.stmt(stmt, env) + return env + + def stmt(self, stmt: ast.stmt, env: Env) -> Env: + match stmt: + case ast.Assign(targets=targets, value=value): + info = self.expr(value, env) + for target in targets: + env = self.bind(target, info, env, value) + return env + case ast.AugAssign(target=target, op=op, value=value): + current = self.expr(target, env) + result = self.binop(op, current, self.expr(value, env)) + if isinstance(target, ast.Name): + # In-place on an array: the dtype stays that of the target. + if current.is_array: + result = replace(result, dtype=current.dtype, view=current.view) + return {**env, target.id: result} + return env + case ast.Expr(value=value): + self.expr(value, env) + return env + case ast.If(test=test, body=body, orelse=orelse): + self.expr(test, env) + return join_envs(self.body(body, dict(env)), self.body(orelse, dict(env))) + case ast.For(target=target, iter=iterable, body=body, orelse=orelse): + element = self.element(self.expr(iterable, env), iterable) + state = dict(env) + for _ in range(4): + entry = self.bind(target, element, dict(state), None) + out = self.body(body, entry) + merged = join_envs(state, out) + if merged == state: + break + state = merged + entry = self.bind(target, element, dict(state), None) + out = join_envs(state, self.body(body, entry)) + return self.body(orelse, out) if orelse else out + case ast.While(test=test, body=body, orelse=orelse): + state = dict(env) + for _ in range(4): + self.expr(test, state) + merged = join_envs(state, self.body(body, dict(state))) + if merged == state: + break + state = merged + self.expr(test, state) + out = join_envs(state, self.body(body, dict(state))) + return self.body(orelse, out) if orelse else out + case ast.Match(subject=subject, cases=cases): + self.expr(subject, env) + joined = dict(env) + for case in cases: + for pattern in ast.walk(case.pattern): + if isinstance(pattern, ast.MatchValue): + self.expr(pattern.value, env) + joined = join_envs(joined, self.body(case.body, dict(env))) + return joined + case ast.Return(value=value): + self.returns.append( + self.expr(value, env) if value is not None else PyInfo(kind=PyKind.NONE) + ) + return env + case ast.FunctionDef(): + return env + return env + + def bind(self, target: ast.expr, info: PyInfo, env: Env, value: ast.expr | None) -> Env: + """Bind an assignment target; tuple targets take the tuple's items.""" + if isinstance(target, ast.Name): + self.analysis.infos[id(target)] = info + # `y = x` binds the same array: y is a view of x from here on. + aliased = isinstance(value, ast.Name) and info.is_array + return {**env, target.id: replace(info, view=info.view or aliased)} + if isinstance(target, ast.Tuple): + items = info.items or () + for k, element in enumerate(target.elts): + item = items[k] if k < len(items) else UNKNOWN + env = self.bind(element, item, env, None) + return env + if isinstance(target, ast.Subscript): + self.expr(target, env) + base = target.value + if isinstance(base, ast.Name) and base.id in env: + before = env[base.id] + stored = self.expr(target, env) + del stored + updated = replace( + before, + finite=before.finite and info.finite, + nonneg=before.nonneg and info.nonneg, + value=None, + ) + return {**env, base.id: updated} + return env + + @staticmethod + def element(info: PyInfo, iterable: ast.expr) -> PyInfo: + """Facts about one item of a ``for`` iterable.""" + if info.kind is PyKind.RANGE: + return scalar(DType.INT, nonneg=info.nonneg) + if info.kind is PyKind.VECTOR: + return scalar(info.dtype, finite=info.finite, nonneg=info.nonneg) + if info.kind is PyKind.MATRIX: + return array(PyKind.VECTOR, info.dtype, finite=info.finite, nonneg=info.nonneg) + if info.kind is PyKind.LIST and info.items: + item = info.items[0] + for other in info.items[1:]: + item = join(item, other) + return item + return UNKNOWN + + # --- expressions ------------------------------------------------------- + + def expr(self, node: ast.expr, env: Env) -> PyInfo: + info = self._expr(node, env) + self.analysis.infos[id(node)] = info + return info + + def _expr(self, node: ast.expr, env: Env) -> PyInfo: + alias = self.analysis.numpy_alias + match node: + case ast.Constant(value=value): + return _constant(value) + case ast.Name(id=name): + if name == alias: + return PyInfo(kind=PyKind.MODULE, module="np") + return env.get(name, UNKNOWN) + case ast.List(elts=elts) | ast.Tuple(elts=elts): + items = tuple(self.expr(e, env) for e in elts) + kind = PyKind.LIST if isinstance(node, ast.List) else PyKind.TUPLE + return PyInfo(kind=kind, items=items, length=len(items)) + case ast.BinOp(left=left, op=op, right=right): + return self.binop(op, self.expr(left, env), self.expr(right, env)) + case ast.UnaryOp(op=op, operand=operand): + inner = self.expr(operand, env) + if isinstance(op, ast.Not): + return scalar(DType.BOOL, nonneg=True) + if isinstance(op, ast.USub): + value = -inner.value if isinstance(inner.value, int | float) else None + return replace(inner, nonneg=value == 0, value=value, view=False) + return replace(inner, view=False) + case ast.Compare(left=left, comparators=comparators): + shape = self.expr(left, env) + for other in comparators: + shape = _broadcast(shape, self.expr(other, env)) + return replace(shape, dtype=DType.BOOL, finite=True, nonneg=True, value=None) + case ast.BoolOp(values=values): + infos = [self.expr(v, env) for v in values] + result = infos[0] + for info in infos[1:]: + result = join(result, info) + return result + case ast.IfExp(test=test, body=body, orelse=orelse): + self.expr(test, env) + return join(self.expr(body, env), self.expr(orelse, env)) + case ast.Subscript(): + return self.subscript(node, env) + case ast.Attribute(): + return self.attribute(node, env) + case ast.Call(): + return self.call(node, env) + case ast.Lambda(): + return PyInfo(kind=PyKind.FUNC, func=node) + case ast.JoinedStr(): + return PyInfo(kind=PyKind.STRING) + for child in ast.iter_child_nodes(node): + if isinstance(child, ast.expr): + self.expr(child, env) + return UNKNOWN + + def binop(self, op: ast.operator, a: PyInfo, b: PyInfo) -> PyInfo: + if a.kind is PyKind.STRING and b.kind is PyKind.STRING and isinstance(op, ast.Add): + return PyInfo(kind=PyKind.STRING) + shape = _matmul(a, b) if isinstance(op, ast.MatMult) else _broadcast(a, b) + if shape.kind is PyKind.UNKNOWN: + return UNKNOWN + dtype = _promote(a.dtype, b.dtype) + if isinstance(op, ast.Div): + dtype = DType.COMPLEX if dtype is DType.COMPLEX else DType.FLOAT + if dtype is DType.UNKNOWN: + dtype = DType.UNKNOWN + if isinstance(op, ast.FloorDiv | ast.Mod) and dtype is DType.BOOL: + dtype = DType.INT + if isinstance(op, ast.Pow) and dtype is DType.BOOL: + dtype = DType.INT + finite = a.finite and b.finite and isinstance(op, ast.Add | ast.Sub | ast.Mult) + if isinstance(op, ast.Pow): + exponent = b.value + finite = a.finite and b.finite and isinstance(exponent, int) and exponent >= 0 + nonneg = False + if isinstance(op, ast.Add | ast.Mult | ast.Div | ast.MatMult): + nonneg = a.nonneg and b.nonneg + elif isinstance(op, ast.Pow): + even = isinstance(b.value, int) and b.value % 2 == 0 + nonneg = a.nonneg or even + elif isinstance(op, ast.Mod): + nonneg = b.nonneg + value = _fold(op, a.value, b.value) if a.is_scalar and b.is_scalar else None + return replace(shape, dtype=dtype, finite=finite, nonneg=nonneg, value=value, view=False) + + def subscript(self, node: ast.Subscript, env: Env) -> PyInfo: + target = self.expr(node.value, env) + index = node.slice + parts = index.elts if isinstance(index, ast.Tuple) else [index] + subs = [ + self.expr(p, env) if not isinstance(p, ast.Slice) else self.slice(p, env) for p in parts + ] + facts = { + "dtype": target.dtype, + "finite": target.finite, + "nonneg": target.nonneg, + } + if target.kind is PyKind.STRING: + return PyInfo(kind=PyKind.STRING) + if target.kind in (PyKind.TUPLE, PyKind.LIST) and target.items is not None: + value = subs[0].value if len(subs) == 1 else None + if isinstance(value, int) and -len(target.items) <= value < len(target.items): + return target.items[value] + return UNKNOWN + if not target.is_array: + return UNKNOWN + dims = [] + for part, sub in zip(parts, subs, strict=True): + if _is_newaxis(part, self.analysis.numpy_alias): + dims.append("new") + elif isinstance(part, ast.Slice): + dims.append("slice") + elif sub.is_scalar and not sub.is_bool: + dims.append("int") + elif sub.is_bool: + dims.append("mask") + else: + dims.append("array") + view = "slice" in dims or "new" in dims + if target.is_vector: + if dims == ["int"]: + return scalar(**facts) # type: ignore[arg-type] + if dims in (["slice", "new"], ["new", "slice"]): + return replace(array(PyKind.MATRIX, **facts), view=True) # type: ignore[arg-type] + if len(dims) == 1: + return replace(array(PyKind.VECTOR, **facts), view=view) # type: ignore[arg-type] + return UNKNOWN + # a matrix + if dims == ["mask"]: + return array(PyKind.VECTOR, **facts) # type: ignore[arg-type] + if len(dims) == 1: + dims.append("slice") + if len(dims) != 2 or "new" in dims: + return UNKNOWN + ints = dims.count("int") + if ints == 2: + return scalar(**facts) # type: ignore[arg-type] + if ints == 1: + return replace(array(PyKind.VECTOR, **facts), view=view) # type: ignore[arg-type] + return replace(array(PyKind.MATRIX, **facts), view=view) # type: ignore[arg-type] + + def slice(self, node: ast.Slice, env: Env) -> PyInfo: + for part in (node.lower, node.upper, node.step): + if part is not None: + self.expr(part, env) + return PyInfo(kind=PyKind.UNKNOWN) + + def attribute(self, node: ast.Attribute, env: Env) -> PyInfo: + name = dotted(node, self.analysis.numpy_alias) + if name is not None: + if name == "np.linalg": + return PyInfo(kind=PyKind.MODULE, module=name) + constants = { + "np.pi": scalar(nonneg=True, value=math.pi), + "np.e": scalar(nonneg=True, value=math.e), + "np.inf": scalar(finite=False, nonneg=True, value=math.inf), + "np.nan": scalar(finite=False), + } + return constants.get(name, UNKNOWN) + base = self.expr(node.value, env) + if node.attr == "T": + return replace(base, view=base.is_array or base.view) + if node.attr == "size": + return scalar(DType.INT, nonneg=True, value=base.length if base.is_vector else None) + if node.attr == "shape": + dim = scalar(DType.INT, nonneg=True) + if base.is_vector: + return PyInfo(kind=PyKind.TUPLE, items=(replace(dim, value=base.length),), length=1) + if base.is_matrix: + return PyInfo(kind=PyKind.TUPLE, items=(dim, dim), length=2) + return PyInfo(kind=PyKind.TUPLE) + if node.attr in ("real", "imag"): + return replace(base, dtype=DType.FLOAT, view=base.is_array) + if node.attr == "ndim": + return scalar(DType.INT, nonneg=True) + return UNKNOWN + + def call(self, node: ast.Call, env: Env) -> PyInfo: + alias = self.analysis.numpy_alias + args = [self.expr(a, env) for a in node.args] + keywords = {k.arg: self.expr(k.value, env) for k in node.keywords if k.arg is not None} + func = node.func + name = dotted(func, alias) + if name is not None: + return self.numpy_call(name[3:], node, args, keywords) + if isinstance(func, ast.Attribute): + receiver = self.expr(func.value, env) + return self.method(func.attr, receiver, args, keywords) + if isinstance(func, ast.Name): + fname = func.id + self.analysis.infos[id(func)] = env.get(fname, UNKNOWN) + if fname in self.defs and fname not in env: + self.call_sites.setdefault(fname, []).append(args) + return self.analysis.functions[fname].result + if fname in env: + handle = env[fname] + lam = handle.func + if lam is not None and len(lam.args.args) >= len(args): + return self.lambda_call(lam, args, env) + return UNKNOWN + return _builtin(fname, args) + return UNKNOWN + + def lambda_call(self, lam: ast.Lambda, args: list[PyInfo], env: Env) -> PyInfo: + """A lambda's result for this call; its body is annotated for every call.""" + params = [a.arg for a in lam.args.args] + defaults = lam.args.defaults + first_default = len(params) - len(defaults) + full = list(args) + for k in range(len(args), len(params)): + full.append(self.expr(defaults[k - first_default], env)) + result = self.expr(lam.body, {**env, **dict(zip(params, full, strict=True))}) + seen = self.lambda_params.get(id(lam)) + joined = full if seen is None else [join(a, b) for a, b in zip(seen, full, strict=True)] + self.lambda_params[id(lam)] = joined + self.expr(lam.body, {**env, **dict(zip(params, joined, strict=True))}) + return result + + def numpy_call( + self, name: str, node: ast.Call, args: list[PyInfo], keywords: dict[str, PyInfo] + ) -> PyInfo: + first = args[0] if args else UNKNOWN + if name == "array": + return _array_literal(first) + if name in ("zeros", "ones"): + if first.kind is PyKind.TUPLE: + dims = first.length + if dims == 1: + return array(PyKind.VECTOR, finite=True, nonneg=True) + if dims == 2: + return array(PyKind.MATRIX, finite=True, nonneg=True) + return UNKNOWN + if first.is_scalar: + length = first.value if isinstance(first.value, int) else None + return array(PyKind.VECTOR, finite=True, nonneg=True, length=length) + return UNKNOWN + if name == "eye": + return array(PyKind.MATRIX, finite=True, nonneg=True) + if name == "linspace": + count = args[2].value if len(args) > 2 else keywords.get("num", scalar(value=50)).value + finite = all(a.finite for a in args[:2]) + points = count if isinstance(count, int) else None + return array(PyKind.VECTOR, finite=finite, length=points) + if name == "arange": + ints = all(a.dtype is DType.INT for a in args) + nonneg = ( + (len(args) == 1 or args[0].nonneg) + and (len(args) < 3 or args[2].nonneg) + and all(a.is_scalar for a in args) + ) + return array( + PyKind.VECTOR, DType.INT if ints else DType.FLOAT, finite=True, nonneg=nonneg + ) + if name in ELEMENTWISE: + shape = _broadcast(first, args[1]) if len(args) == 2 else _as_array(first) + if shape.kind is PyKind.UNKNOWN: + return UNKNOWN + dtype = DType.BOOL if name in _BOOL_RESULT else DType.FLOAT + if name in ("abs", "sign", "mod", "fmod") and first.dtype is DType.INT: + dtype = DType.INT + if first.dtype is DType.COMPLEX and name not in ("abs", "real", "imag", *_BOOL_RESULT): + dtype = DType.COMPLEX + return replace( + shape, + dtype=dtype, + finite=(first.finite and name in _NAN_FREE_RESULT) or name in _BOOL_RESULT, + nonneg=name in ("abs", "sqrt", "exp", "hypot") + or name in _BOOL_RESULT + or (first.nonneg and name in _NAN_FREE_RESULT), + value=None, + view=False, + ) + if name in _REDUCTIONS: + return self.method(name, first, args[1:], keywords) + if name in ("argmax", "argmin", "nanargmax", "nanargmin", "count_nonzero"): + return scalar(DType.INT, nonneg=True) + if name in ("maximum", "minimum", "fmax", "fmin"): + second = args[1] if len(args) > 1 else UNKNOWN + shape = _broadcast(_as_array(first), _as_array(second)) + return replace( + shape, + dtype=_promote(first.dtype, second.dtype), + finite=all(a.finite for a in args), + nonneg=any(a.nonneg for a in args), + view=False, + ) + if name == "clip": + return replace(_as_array(first), finite=all(a.finite for a in args), view=False) + if name in ("logical_and", "logical_or", "logical_xor", "logical_not"): + shape = _as_array(first) + for other in args[1:]: + shape = _broadcast(shape, _as_array(other)) + return replace( + shape, dtype=DType.BOOL, finite=True, nonneg=True, value=None, view=False + ) + if name == "outer": + return array( + PyKind.MATRIX, + _promote(first.dtype, args[1].dtype) if len(args) > 1 else DType.UNKNOWN, + ) + if name == "linalg.solve": + b = args[1] if len(args) > 1 else UNKNOWN + return replace(b, dtype=DType.FLOAT, finite=False, nonneg=False, view=False) + if name == "linalg.matrix_power": + return array(PyKind.MATRIX, first.dtype, finite=False) + if name in ("flatnonzero",): + return array(PyKind.VECTOR, DType.INT, finite=True, nonneg=True) + if name in ("concatenate", "append"): + parts = first.items if name == "concatenate" and first.items else tuple(args) + dtype = DType.BOOL + for part in parts: + dtype = _promote( + dtype, part.dtype if part.kind is not PyKind.LIST else _list_dtype(part) + ) + return array(PyKind.VECTOR, dtype, finite=all(_finite(p) for p in parts)) + if name in ("vstack", "column_stack"): + parts = first.items or () + dtype = DType.BOOL + for part in parts: + dtype = _promote(dtype, part.dtype) + return array(PyKind.MATRIX, dtype, finite=all(p.finite for p in parts)) + if name in ("size",): + return scalar(DType.INT, nonneg=True) + if name in ("conj", "transpose"): + return replace(first, view=False) + if name == "finfo": + return PyInfo(kind=PyKind.UNKNOWN) + return UNKNOWN + + def method( + self, name: str, receiver: PyInfo, args: list[PyInfo], keywords: dict[str, PyInfo] + ) -> PyInfo: + if receiver.kind is PyKind.UNKNOWN and receiver.dtype is DType.UNKNOWN: + return UNKNOWN + if name in ("copy",): + return replace(receiver, view=False) + if name in ("conj",): + return replace(receiver, view=False) + if name in ("ravel", "flatten"): + return replace(receiver, kind=PyKind.VECTOR, view=name == "ravel", length=None) + if name == "reshape": + shape = args[0] if args else UNKNOWN + count = shape.length if shape.kind is PyKind.TUPLE else len(args) + kind = PyKind.MATRIX if count == 2 else PyKind.VECTOR if count == 1 else PyKind.UNKNOWN + return replace(receiver, kind=kind, view=True, length=None) + if name == "astype": + return replace(receiver, dtype=DType.UNKNOWN, view=False) + if name in _REDUCTIONS: + axis = keywords.get("axis", args[0] if args else None) + dtype = receiver.dtype + if name in ("sum", "prod") and dtype is DType.BOOL: + dtype = DType.INT + if name == "mean": + dtype = DType.FLOAT if dtype is not DType.COMPLEX else dtype + if name in ("all", "any"): + dtype = DType.BOOL + facts = { + "dtype": dtype, + "finite": receiver.finite and name != "prod", + "nonneg": receiver.nonneg or name in ("all", "any"), + } + if axis is not None and receiver.is_matrix: + return array(PyKind.VECTOR, **facts) # type: ignore[arg-type] + if receiver.is_array or receiver.kind is PyKind.LIST: + return scalar(**facts) # type: ignore[arg-type] + return UNKNOWN + if name in ("argmax", "argmin"): + return scalar(DType.INT, nonneg=True) + if name == "all" or name == "any": + return scalar(DType.BOOL, nonneg=True) + if name == "append": + return PyInfo(kind=PyKind.NONE) + return UNKNOWN + + +def _constant(value: object) -> PyInfo: + if isinstance(value, bool): + return scalar(DType.BOOL, nonneg=True, value=int(value)) + if isinstance(value, int): + return scalar(DType.INT, nonneg=value >= 0, value=value) + if isinstance(value, float): + return scalar(DType.FLOAT, finite=math.isfinite(value), nonneg=value >= 0, value=value) + if isinstance(value, complex): + return scalar(DType.COMPLEX, value=value) + if isinstance(value, str): + return PyInfo(kind=PyKind.STRING, value=value) + if value is None: + return PyInfo(kind=PyKind.NONE) + return UNKNOWN + + +def _fold(op: ast.operator, a: object, b: object) -> int | float | None: + if not (isinstance(a, int | float) and isinstance(b, int | float)): + return None + try: + if isinstance(op, ast.Add): + return a + b + if isinstance(op, ast.Sub): + return a - b + if isinstance(op, ast.Mult): + return a * b + if isinstance(op, ast.Div): + return a / b + except (ZeroDivisionError, OverflowError): + return None + return None + + +def _list_dtype(info: PyInfo) -> DType: + dtype = DType.BOOL + for item in info.items or (): + if item.kind is PyKind.LIST: + dtype = _promote(dtype, _list_dtype(item)) + elif item.is_scalar or item.is_array: + dtype = _promote(dtype, item.dtype) + else: + return DType.UNKNOWN + return dtype + + +def _finite(info: PyInfo) -> bool: + if info.kind is PyKind.LIST: + return all(_finite(item) for item in info.items or ()) + return info.finite + + +def _array_literal(first: PyInfo) -> PyInfo: + """``np.array()``: a vector of scalars or a matrix of equal rows.""" + if first.is_array: + return replace(first, view=False) + if first.kind is not PyKind.LIST or first.items is None: + return UNKNOWN + items = first.items + dtype = _list_dtype(first) + finite = _finite(first) + nonneg = all(i.nonneg for i in items) if items else True + if all(i.is_scalar for i in items): + return array(PyKind.VECTOR, dtype, finite=finite, nonneg=nonneg, length=len(items)) + if all( + i.kind is PyKind.LIST and i.items is not None and all(x.is_scalar for x in i.items) + for i in items + ): + rows = {i.length for i in items} + if len(rows) == 1: + nonneg = all(x.nonneg for i in items for x in (i.items or ())) + return array(PyKind.MATRIX, dtype, finite=finite, nonneg=nonneg) + return UNKNOWN + + +def _as_array(info: PyInfo) -> PyInfo: + """A list argument is a 1-D array (or a 2-D one for a list of lists).""" + if info.kind is PyKind.LIST: + return _array_literal(info) + return info + + +def _broadcast(a: PyInfo, b: PyInfo) -> PyInfo: + a, b = _as_array(a), _as_array(b) + if a.is_scalar and b.is_scalar: + return replace(a, value=None, view=False) + if a.is_scalar and b.is_array: + return replace(b, value=None, view=False) + if b.is_scalar and a.is_array: + return replace(a, value=None, view=False) + if a.is_array and b.is_array: + kind = PyKind.MATRIX if PyKind.MATRIX in (a.kind, b.kind) else PyKind.VECTOR + return array(kind, length=a.length if a.length == b.length else None) + return UNKNOWN + + +def _matmul(a: PyInfo, b: PyInfo) -> PyInfo: + a, b = _as_array(a), _as_array(b) + if not (a.is_array and b.is_array): + return UNKNOWN + if a.is_vector and b.is_vector: + return scalar(finite=False) + if a.is_matrix and b.is_matrix: + return array(PyKind.MATRIX) + return array(PyKind.VECTOR) + + +def _builtin(name: str, args: list[PyInfo]) -> PyInfo: + first = args[0] if args else UNKNOWN + if name == "range": + nonneg = (len(args) == 1 or first.nonneg) and (len(args) < 3 or args[2].nonneg) + return PyInfo(kind=PyKind.RANGE, nonneg=nonneg) + if name == "len": + return scalar(DType.INT, nonneg=True) + if name == "abs": + if first.is_scalar: + value = abs(first.value) if isinstance(first.value, int | float) else None + return replace( + first, + nonneg=True, + value=value, + dtype=DType.FLOAT if first.dtype is DType.COMPLEX else first.dtype, + ) + return replace(first, nonneg=True, view=False) + if name in ("max", "min"): + if len(args) == 1 and first.kind is PyKind.TUPLE: + return scalar(DType.INT, nonneg=True) + if all(a.is_scalar for a in args) and args: + result = args[0] + for other in args[1:]: + result = join(result, other) + return replace(result, value=None) + return UNKNOWN + if name == "float": + return scalar(DType.FLOAT, finite=first.finite, nonneg=first.nonneg) + if name == "int": + return scalar(DType.INT, nonneg=first.nonneg) + if name == "bool": + return scalar(DType.BOOL, nonneg=True) + if name == "print": + return PyInfo(kind=PyKind.NONE) + return UNKNOWN + + +def _is_newaxis(node: ast.expr, alias: str | None) -> bool: + return (isinstance(node, ast.Constant) and node.value is None) or dotted( + node, alias + ) == "np.newaxis" + + +def analyze_python(module: ast.Module) -> PyAnalysis: + """Infer facts about every expression of a Python module. + + :param module: the parsed source. + """ + return _Inferrer(module).run() diff --git a/dualect/rulebook.py b/dualect/rulebook.py new file mode 100644 index 0000000..a71f709 --- /dev/null +++ b/dualect/rulebook.py @@ -0,0 +1,201 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Loading the rule knowledge base from ``rules///``. + +This module only *reads* rules; checking them against the schema and the +folder conventions is :mod:`dualect.validate`. Later milestones (scanner, +context command, translators) build on :func:`load_rules`. +""" + +from dataclasses import dataclass, field +from enum import StrEnum +from pathlib import Path +from typing import Any + +import yaml + +from dualect.errors import RuleError + +RULE_FILE = "rule.yaml" +TRANSLATOR_FILE = "translate.py" +CASES_DIR = "cases" + +#: The two translation directions, as named in reports and the promotion check. +TO_PYTHON = "to-python" +FROM_PYTHON = "from-python" +DIRECTIONS = (TO_PYTHON, FROM_PYTHON) + + +class Status(StrEnum): + """Lifecycle stage of a rule (docs/design.md section 4.3).""" + + UNSUPPORTED = "unsupported" + GUIDED = "guided" + MECHANICAL = "mechanical" + + +@dataclass(frozen=True) +class CasePair: + """One paired example: a ``.m`` script and its hand-written ``.py`` twin. + + :param name: file stem shared by both files, e.g. ``"basic"``. + :param m_path: the ``.m`` file. + :param py_path: the ``.py`` file. + """ + + name: str + m_path: Path + py_path: Path + + +@dataclass(frozen=True) +class Rule: + """A loaded rule folder. + + :param id: ``/``. + :param path: the rule folder. + :param data: the parsed ``rule.yaml`` mapping, as written. + :param cases: complete ``.m``/``.py`` pairs, sorted by name. + """ + + id: str + path: Path + data: dict[str, Any] + cases: tuple[CasePair, ...] = field(default=()) + + @property + def category(self) -> str: + """The category part of the id, e.g. ``"indexing"``.""" + return self.id.split("/", 1)[0] + + @property + def title(self) -> str: + """Short human-readable title.""" + return str(self.data.get("title", "")) + + @property + def status(self) -> Status: + """Lifecycle stage; raises :class:`RuleError` for an unknown value.""" + try: + return Status(str(self.data.get("status"))) + except ValueError as exc: + raise RuleError(f"{self.id}: unknown status {self.data.get('status')!r}") from exc + + @property + def match(self) -> tuple[str, ...]: + """Construct tags this rule covers (see :mod:`dualect.constructs`).""" + return tuple(str(tag) for tag in self.data.get("match") or ()) + + @property + def python_status(self) -> Status | None: + """Lifecycle stage in the Python -> ``.m`` direction (``from_python.status``). + + ``None`` when the rule says nothing about that direction. A rule may be + ``mechanical`` one way and ``guided`` the other. + """ + block = self.data.get("from_python") + if not isinstance(block, dict): + return None + try: + return Status(str(block.get("status"))) + except ValueError as exc: + raise RuleError( + f"{self.id}: unknown from_python status {block.get('status')!r}" + ) from exc + + @property + def python_match(self) -> tuple[str, ...]: + """Python construct tags this rule covers (see :mod:`dualect.pyconstructs`).""" + block = self.data.get("from_python") + if not isinstance(block, dict): + return () + return tuple(str(tag) for tag in block.get("match") or ()) + + def status_for(self, direction: str) -> Status | None: + """Status in a direction: ``"to-python"`` (``status``) or ``"from-python"``.""" + return self.status if direction == TO_PYTHON else self.python_status + + @property + def has_translator(self) -> bool: + """Whether the folder contains a deterministic ``translate.py``.""" + return (self.path / TRANSLATOR_FILE).is_file() + + @property + def tolerance(self) -> dict[str, float]: + """Per-rule verify tolerance override (may be empty).""" + raw = self.data.get("tolerance") or {} + return {key: float(value) for key, value in raw.items()} + + +def rule_dirs(*, rules_dir: Path) -> list[Path]: + """Return every ``//`` folder that holds a ``rule.yaml``. + + :param rules_dir: root of the knowledge base. + :returns: folders sorted by rule id, so listings and test ids are stable. + """ + return sorted(path.parent for path in rules_dir.glob(f"*/*/{RULE_FILE}")) + + +def find_cases(*, rule_dir: Path) -> tuple[CasePair, ...]: + """Return the complete ``.m``/``.py`` pairs in a rule's ``cases/`` folder. + + Unpaired files are not returned here; :mod:`dualect.validate` reports them, + because a lone file is a mistake to fix rather than something to skip. + + :param rule_dir: the rule folder. + """ + cases_dir = rule_dir / CASES_DIR + pairs = [] + for m_path in sorted(cases_dir.glob("*.m")): + py_path = m_path.with_suffix(".py") + if py_path.is_file(): + pairs.append(CasePair(name=m_path.stem, m_path=m_path, py_path=py_path)) + return tuple(pairs) + + +def read_rule_yaml(*, path: Path) -> dict[str, Any]: + """Parse a ``rule.yaml`` file into a mapping. + + :param path: the file. + :raises RuleError: if the YAML is invalid or not a mapping. + """ + try: + data = yaml.safe_load(path.read_text(encoding="utf-8")) + except yaml.YAMLError as exc: + raise RuleError(f"{path}: invalid YAML: {exc}") from exc + if not isinstance(data, dict): + raise RuleError(f"{path}: expected a mapping at the top level") + return data + + +def rule_id_for(*, rule_dir: Path) -> str: + """Return the id a rule folder must declare: ``/``.""" + return f"{rule_dir.parent.name}/{rule_dir.name}" + + +def load_rule(*, rule_dir: Path) -> Rule: + """Load one rule folder (without schema validation). + + :param rule_dir: folder containing ``rule.yaml``. + """ + data = read_rule_yaml(path=rule_dir / RULE_FILE) + return Rule( + id=rule_id_for(rule_dir=rule_dir), + path=rule_dir, + data=data, + cases=find_cases(rule_dir=rule_dir), + ) + + +def load_rules(*, rules_dir: Path, status: Status | None = None) -> list[Rule]: + """Load every rule under ``rules_dir``. + + :param rules_dir: root of the knowledge base. + :param status: if given, keep only rules at this lifecycle stage. + :returns: rules sorted by id. + """ + rules = [load_rule(rule_dir=path) for path in rule_dirs(rules_dir=rules_dir)] + if status is not None: + rules = [rule for rule in rules if rule.status is status] + return rules diff --git a/dualect/runners.py b/dualect/runners.py new file mode 100644 index 0000000..f1d6d9b --- /dev/null +++ b/dualect/runners.py @@ -0,0 +1,187 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Executing both sides of a translation pair and collecting their variables. + +A script's *outputs* are the variables it leaves in its workspace. Both runners +return them as a ``{name: value}`` mapping so :mod:`dualect.compare` can match +them by name. + +The ``.m`` side runs in GNU Octave through oct2py. Starting Octave takes about a +second, so :class:`MRunner` keeps one session and clears it between scripts. +""" + +import contextlib +import io +import os +import shutil +import traceback +import types +from dataclasses import dataclass +from pathlib import Path +from typing import Any, Self + +import numpy as np + +from dualect.errors import ExecutionError, RuntimeMissingError + +#: Environment variable oct2py reads to find the interpreter; we honour it too. +EXECUTABLE_ENV = "OCTAVE_EXECUTABLE" + +#: Names never treated as outputs: Octave's implicit result variable. +_M_IMPLICIT = frozenset({"ans"}) + + +@dataclass(frozen=True) +class CallableValue: + """Stand-in for a function handle or lambda. + + Behaviour of a callable cannot be compared by value; case authors compare + the results of calling it instead. The marker lets both sides agree that a + name holds *a* callable without pretending the bodies were checked. + """ + + description: str + + +def m_runtime_available() -> bool: + """Return whether an Octave executable can be found for running ``.m`` code.""" + configured = os.environ.get(EXECUTABLE_ENV) + if configured: + return Path(configured).is_file() or shutil.which(configured) is not None + return shutil.which("octave") is not None or shutil.which("octave-cli") is not None + + +def _quote_m_string(text: str) -> str: + """Quote text as a single-quoted .m string literal (quotes are doubled).""" + return "'" + text.replace("'", "''") + "'" + + +class MRunner: + """Runs ``.m`` scripts in one reusable Octave session. + + Use as a context manager, or call :meth:`close` when done:: + + with MRunner() as runner: + outputs = runner.run(path=Path("case.m")) + """ + + def __init__(self) -> None: + """Create the runner; Octave itself starts lazily on the first run.""" + self._session: Any = None + + def _ensure_session(self) -> Any: + """Start Octave on first use, with a clear error when it is missing.""" + if self._session is None: + if not m_runtime_available(): + raise RuntimeMissingError( + "GNU Octave was not found on PATH (or via OCTAVE_EXECUTABLE); " + "install it to run .m code (macOS: brew install octave; " + "Ubuntu: apt install octave)" + ) + from oct2py import Oct2Py # deferred: importing is cheap, starting is not + + self._session = Oct2Py() + return self._session + + def run(self, *, path: Path) -> dict[str, Any]: + """Execute a ``.m`` script in a cleared workspace and return its variables. + + The script runs with ``source`` from its own folder, so it may define + functions before use (with a leading ``1;``) and read neighbouring files. + + :param path: the script. + :returns: variable name -> value. Logical arrays come back as NumPy + ``bool`` arrays and function handles as :class:`CallableValue`. + :raises ExecutionError: if Octave reports an error. + """ + from oct2py import Oct2PyError + + session = self._ensure_session() + path = path.resolve() + printed: list[str] = [] + try: + # Change directory first: the previous script's folder may have been + # a temporary one that is gone now, and Octave refuses to run + # anything from a working directory that no longer exists. + session.eval(f"cd({_quote_m_string(str(path.parent))});", stream_handler=printed.append) + # A fresh workspace per script: leftovers from an earlier script + # (variables or command-line functions) would otherwise leak in. + session.eval("clear all; close all; more off;", stream_handler=printed.append) + session.eval(f"source({_quote_m_string(str(path))});", stream_handler=printed.append) + return self._collect(session=session) + except Oct2PyError as exc: + raise ExecutionError(side="m", path=path, message=str(exc)) from exc + + @staticmethod + def _collect(*, session: Any) -> dict[str, Any]: + """Pull every workspace variable, using its Octave class to decode it.""" + names = session.eval("who();", nout=1) + if isinstance(names, str): + names = [names] + outputs: dict[str, Any] = {} + for name in (str(n) for n in np.asarray(names, dtype=object).ravel()): + if name in _M_IMPLICIT: + continue + m_class = session.eval(f"class({name});", nout=1) + if m_class == "function_handle": + outputs[name] = CallableValue(description=str(session.pull(name))) + continue + value = session.pull(name) + # oct2py transfers logicals as uint8; restore the type so a + # logical-vs-double mix-up between the sides is detectable. + if m_class == "logical": + value = np.asarray(value, dtype=bool) + outputs[name] = value + return outputs + + def close(self) -> None: + """Stop the Octave session, if one was started.""" + if self._session is not None: + self._session.exit() + self._session = None + + def __enter__(self) -> Self: + """Support ``with MRunner() as runner:``.""" + return self + + def __exit__(self, *exc_info: object) -> None: + """Stop Octave when the ``with`` block ends.""" + self.close() + + +def run_py_script(*, path: Path) -> dict[str, Any]: + """Execute a Python script in a fresh namespace and return its variables. + + The script runs in this process (it is code the user asked to verify). + Standard output is captured and discarded so verification output stays clean. + + :param path: the script. + :returns: variable name -> value. Names starting with ``_``, modules, + classes and ``def`` functions are dropped (they are scaffolding, not + outputs); lambdas become :class:`CallableValue`. + :raises ExecutionError: if the script raises. + """ + path = path.resolve() + source = path.read_text(encoding="utf-8") + namespace: dict[str, Any] = {"__name__": "__main__", "__file__": str(path)} + try: + code = compile(source, str(path), "exec") + with contextlib.redirect_stdout(io.StringIO()): + exec(code, namespace) + except Exception as exc: # any failure of user code is reported, not raised raw + last = traceback.format_exception_only(exc)[-1].strip() + raise ExecutionError(side="py", path=path, message=last) from exc + + outputs: dict[str, Any] = {} + for name, value in namespace.items(): + if name.startswith("_") or isinstance(value, types.ModuleType | type): + continue + # Any other callable (def functions, imported functions, ufuncs) is a + # tool the script used, not a result it produced. + if callable(value): + if isinstance(value, types.FunctionType) and value.__name__ == "": + outputs[name] = CallableValue(description="lambda") + continue + outputs[name] = value + return outputs diff --git a/dualect/scaffold.py b/dualect/scaffold.py new file mode 100644 index 0000000..46391d1 --- /dev/null +++ b/dualect/scaffold.py @@ -0,0 +1,75 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""``dualect rules new``: create a rule folder from a template. + +The new rule starts as ``unsupported`` with ``TODO`` placeholders. It passes the +schema (so tooling can load it straight away), but the test suite rejects any +rule that still contains ``TODO``, so a half-written rule cannot be merged. +""" + +import re +from pathlib import Path + +from dualect.errors import RuleError +from dualect.rulebook import CASES_DIR, RULE_FILE + +#: Marker the test suite searches for; anything carrying it is unfinished. +PLACEHOLDER = "TODO" + +_RULE_ID = re.compile(r"^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$") + +_RULE_TEMPLATE = """\ +id: {rule_id} +title: "{PLACEHOLDER}: short title for {rule_id}" +status: unsupported # unsupported | guided | mechanical +dialects: [octave, matlab] +match: [call:{PLACEHOLDER}] # construct tags, see dualect/constructs.py +octave: | + % {PLACEHOLDER}: the .m form +python: | + # {PLACEHOLDER}: the idiomatic NumPy form +why: > + {PLACEHOLDER}: why the two forms differ, in two or three sentences. +pitfalls: [] +related: [] +python_imports: [import numpy as np] +""" + +_CASE_M = """\ +% {PLACEHOLDER}: a short .m script; every variable it leaves behind is compared. +% Directives: '% dualect: index ' marks 1-based index outputs, +% '% dualect: ignore ' skips variables that legitimately differ. +""" + +_CASE_PY = """\ +# {PLACEHOLDER}: the hand-written idiomatic NumPy twin of basic.m. +import numpy as np +""" + + +def new_rule(*, rules_dir: Path, rule_id: str) -> Path: + """Create ``rules_dir///`` with a template rule and case pair. + + :param rules_dir: root of the knowledge base. + :param rule_id: ``/``, lowercase with hyphens. + :returns: the new rule folder. + :raises RuleError: if the id is malformed or the folder already exists. + """ + if not _RULE_ID.match(rule_id): + raise RuleError( + f"invalid rule id {rule_id!r}: expected /, " + "lowercase letters, digits and hyphens" + ) + rule_dir = rules_dir / rule_id + if rule_dir.exists(): + raise RuleError(f"{rule_dir} already exists") + + cases_dir = rule_dir / CASES_DIR + cases_dir.mkdir(parents=True) + (rule_dir / RULE_FILE).write_text( + _RULE_TEMPLATE.format(rule_id=rule_id, PLACEHOLDER=PLACEHOLDER), encoding="utf-8" + ) + (cases_dir / "basic.m").write_text(_CASE_M.format(PLACEHOLDER=PLACEHOLDER), encoding="utf-8") + (cases_dir / "basic.py").write_text(_CASE_PY.format(PLACEHOLDER=PLACEHOLDER), encoding="utf-8") + return rule_dir diff --git a/dualect/scan.py b/dualect/scan.py new file mode 100644 index 0000000..a557523 --- /dev/null +++ b/dualect/scan.py @@ -0,0 +1,285 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""``dualect scan``: which rules does a file need? (docs/design.md section 6). + +The scanner parses and lowers the file, infers shapes, tags every statement's +constructs (:mod:`dualect.constructs`) and looks each tag up in the rules' +``match`` lists. A tag no rule matches is reported as unsupported under its +own name; so is text the parser could not read, and (under ``--dialect +matlab``) Octave-only syntax. +""" + +import json +from collections.abc import Iterable +from dataclasses import dataclass, field +from pathlib import Path +from typing import Any + +from dualect import ir +from dualect.constructs import Use, statement_uses +from dualect.dialect import Dialect +from dualect.errors import RuleError +from dualect.infer import Analysis, analyze +from dualect.lower import lower_parsed +from dualect.parse import parse_m +from dualect.rulebook import FROM_PYTHON, TO_PYTHON, Rule, Status +from dualect.source import OctaveFeature + +#: Tag for Octave-only syntax found while scanning for the matlab dialect. +OCTAVE_ONLY_TAG = "dialect:octave-only" + + +class RuleIndex: + """Maps construct tags to the rule that covers them, for one dialect.""" + + def __init__(self, *, rules: Iterable[Rule], dialect: Dialect) -> None: + """Index the rules that apply to ``dialect``. + + :param rules: all loaded rules. + :param dialect: the source dialect; rules for other dialects or + versions are left out. + :raises RuleError: when two applicable rules claim the same tag. + """ + self.dialect = dialect + self.by_tag: dict[str, Rule] = {} + for rule in rules: + if not dialect.allows(rule.data): + continue + for tag in rule.match: + other = self.by_tag.get(tag) + if other is not None: + raise RuleError( + f"{rule.id} and {other.id} both match {tag!r} for dialect {dialect}" + ) + self.by_tag[tag] = rule + + def rule_for(self, tag: str) -> Rule | None: + """The rule covering ``tag``, or ``None``.""" + return self.by_tag.get(tag) + + def rule_by_id(self, rule_id: str) -> Rule | None: + """An applicable rule by id, or ``None`` (absent, or not for this dialect).""" + for rule in self.by_tag.values(): + if rule.id == rule_id: + return rule + return None + + +@dataclass(frozen=True) +class Finding: + """One construct use, resolved to a rule. + + :param tag: construct tag. + :param loc: where it is. + :param rule: the rule covering it, or ``None`` when no rule does. + :param text: a short source excerpt, for reports. + :param direction: ``to-python`` (a ``.m`` construct) or ``from-python``. + """ + + tag: str + loc: ir.Loc + rule: Rule | None + text: str = "" + direction: str = TO_PYTHON + + @property + def status(self) -> Status: + """The rule's status in this direction; ``unsupported`` when there is none.""" + if self.rule is None: + return Status.UNSUPPORTED + return self.rule.status_for(self.direction) or Status.UNSUPPORTED + + @property + def unsupported(self) -> bool: + """Whether this use has no rule or only an ``unsupported`` one.""" + return self.status is Status.UNSUPPORTED + + +@dataclass +class ScanResult: + """Everything the scanner learned about one file. + + :param source_name: the file, for reports. + :param program: the lowered IR. + :param analysis: inference results. + :param findings: every construct use, in source order. + :param uses_by_stmt: ``id(stmt)`` -> the findings of that statement itself. + :param features: Octave-only syntax found by the normalizer. + :param program_text: the source text. + :param direction: ``to-python`` for a ``.m`` file, ``from-python`` for a ``.py`` file. + """ + + source_name: str + program: ir.Program + analysis: Analysis + program_text: str = "" + findings: list[Finding] = field(default_factory=list) + uses_by_stmt: dict[int, list[Finding]] = field(default_factory=dict) + features: list[OctaveFeature] = field(default_factory=list) + direction: str = TO_PYTHON + + def status_of(self, rule: Rule) -> Status: + """A rule's status in this scan's direction.""" + return rule.status_for(self.direction) or Status.UNSUPPORTED + + def needed_rules(self) -> list[Rule]: + """The rules this file needs, sorted by id.""" + rules = {f.rule.id: f.rule for f in self.findings if f.rule is not None} + return [rules[key] for key in sorted(rules)] + + def unsupported(self) -> list[Finding]: + """Uses with no rule (or an ``unsupported`` rule), in source order.""" + return [f for f in self.findings if f.unsupported] + + def report(self) -> str: + """Human-readable listing: each rule with its locations, then the gaps.""" + lines = [f"scan {self.source_name}"] + rules = self.needed_rules() + width = max((len(rule.id) for rule in rules), default=0) + for rule in rules: + locs = [str(f.loc) for f in self.findings if f.rule is rule] + shown = ", ".join(_unique(locs)[:8]) + more = len(_unique(locs)) - 8 + suffix = f" (+{more} more)" if more > 0 else "" + lines.append(f" {rule.id:<{width}} {self.status_of(rule).value:<11} {shown}{suffix}") + gaps = self.unsupported() + if gaps: + lines.append(f"unsupported ({len(gaps)}):") + for finding in gaps: + label = finding.rule.id if finding.rule is not None else "no rule" + excerpt = f" {finding.text}" if finding.text else "" + lines.append(f" {str(finding.loc):<7} {finding.tag} ({label}){excerpt}") + counts = {status: 0 for status in Status} + for rule in rules: + counts[self.status_of(rule)] += 1 + lines.append( + f"{len(rules)} rules: {counts[Status.MECHANICAL]} mechanical, " + f"{counts[Status.GUIDED]} guided, {counts[Status.UNSUPPORTED]} unsupported; " + f"{len(gaps)} unsupported construct uses" + ) + return "\n".join(lines) + + def as_json(self) -> dict[str, Any]: + """Machine-readable form (for tools and, later, the MCP server).""" + return { + "source": self.source_name, + "direction": self.direction, + "rules": [ + { + "id": rule.id, + "status": self.status_of(rule).value, + "locations": _unique(str(f.loc) for f in self.findings if f.rule is rule), + } + for rule in self.needed_rules() + ], + "unsupported": [ + { + "tag": f.tag, + "location": str(f.loc), + "rule": f.rule.id if f.rule is not None else None, + "text": f.text, + } + for f in self.unsupported() + ], + } + + def to_json(self) -> str: + """:meth:`as_json` serialized.""" + return json.dumps(self.as_json(), indent=2) + + +def _unique(items: Iterable[str]) -> list[str]: + return list(dict.fromkeys(items)) + + +def _excerpt(text: str, loc: ir.Loc) -> str: + """The first source line of a span, trimmed, for reports.""" + lines = text.splitlines() + if not 1 <= loc.line <= len(lines): + return "" + line = lines[loc.line - 1] + start = max(loc.col - 1, 0) + end = loc.end_col - 1 if loc.end_line == loc.line else len(line) + snippet = line[start:end].strip() or line.strip() + return snippet if len(snippet) <= 48 else snippet[:45] + "..." + + +def scan_text(*, text: str, name: str, index: RuleIndex) -> ScanResult: + """Scan ``.m`` source text. + + :param text: the source. + :param name: file name for reports. + :param index: the rules to match against (already filtered by dialect). + """ + parsed = parse_m(text) + program = lower_parsed(parsed=parsed, name=name, dialect=index.dialect.name) + analysis = analyze(program) + result = ScanResult( + source_name=name, + program=program, + analysis=analysis, + features=parsed.source.features, + program_text=text, + ) + for stmt in ir.walk_stmts(program.body): + found = [ + Finding( + tag=use.tag, + loc=use.loc, + rule=index.rule_for(use.tag), + text=_excerpt(text, use.loc) if index.rule_for(use.tag) is None else "", + ) + for use in statement_uses(stmt, analysis) + ] + result.uses_by_stmt[id(stmt)] = found + result.findings.extend(found) + if index.dialect.name == "matlab": + for feature in parsed.source.features: + loc = ir.Loc(feature.line, feature.col, feature.line, feature.col + len(feature.name)) + finding = Finding( + tag=OCTAVE_ONLY_TAG, loc=loc, rule=None, text=f"{feature.name} is Octave-only" + ) + result.findings.append(finding) + result.findings.sort(key=lambda f: (f.loc.line, f.loc.col)) + return result + + +def scan_python_text(*, text: str, name: str, rules: list[Rule]) -> ScanResult: + """Scan Python source: the rules it needs to become ``.m`` code, and the gaps. + + :param text: the source. + :param name: file name for reports. + :param rules: all loaded rules. + :raises DualectError: when the text is not valid Python. + """ + from dualect.lift import plan_python # deferred: lift imports this module + + findings = plan_python(text=text, name=name, rules=rules) + result = ScanResult( + source_name=name, + program=ir.Program(loc=ir.NO_LOC, body=[], source_name=name), + analysis=Analysis(), + program_text=text, + direction=FROM_PYTHON, + ) + result.findings = sorted(findings, key=lambda f: (f.loc.line, f.loc.col)) + return result + + +def scan_file(*, path: Path, rules: list[Rule], dialect: Dialect) -> ScanResult: + """Scan a ``.m`` file, or a ``.py`` file for the other direction. + + :param path: the file. + :param rules: all loaded rules. + :param dialect: the source dialect (of a ``.m`` file). + """ + text = path.read_text(encoding="utf-8") + if path.suffix == ".py": + return scan_python_text(text=text, name=str(path), rules=rules) + return scan_text(text=text, name=str(path), index=RuleIndex(rules=rules, dialect=dialect)) + + +def uses_of(findings: Iterable[Finding]) -> list[Use]: + """Strip findings back to plain uses (tag and location).""" + return [Use(f.tag, f.loc) for f in findings] diff --git a/dualect/schema/rule.schema.json b/dualect/schema/rule.schema.json new file mode 100644 index 0000000..1618704 --- /dev/null +++ b/dualect/schema/rule.schema.json @@ -0,0 +1,174 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/kovirlabs/dualect/rule.schema.json", + "title": "dualect rule", + "description": "One translation rule: rules///rule.yaml. See docs/design.md section 4.2.", + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "title", + "status", + "dialects", + "match", + "octave", + "python", + "why" + ], + "properties": { + "id": { + "description": "/; must match the folder the file lives in.", + "$ref": "#/$defs/ruleId" + }, + "title": { + "type": "string", + "minLength": 1, + "maxLength": 120 + }, + "status": { + "description": "Lifecycle stage: unsupported -> guided -> mechanical.", + "enum": [ + "unsupported", + "guided", + "mechanical" + ] + }, + "dialects": { + "description": "Source dialects the rule applies to.", + "type": "array", + "items": { + "enum": [ + "octave", + "matlab" + ] + }, + "minItems": 1, + "uniqueItems": true + }, + "match": { + "description": "Construct tags this rule covers (vocabulary in dualect/constructs.py); the scanner maps every use of these tags to this rule.", + "type": "array", + "items": { + "type": "string", + "pattern": "^[a-z]+:[A-Za-z0-9_.-]+$" + }, + "minItems": 1, + "uniqueItems": true + }, + "since": { + "$ref": "#/$defs/versionBound" + }, + "until": { + "$ref": "#/$defs/versionBound" + }, + "octave": { + "description": "The .m form, as a short snippet.", + "type": "string", + "minLength": 1 + }, + "python": { + "description": "The idiomatic NumPy form of the same snippet.", + "type": "string", + "minLength": 1 + }, + "why": { + "description": "Why the forms differ; written for a human learner and an LLM.", + "type": "string", + "minLength": 1 + }, + "pitfalls": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "related": { + "type": "array", + "items": { + "$ref": "#/$defs/ruleId" + }, + "uniqueItems": true + }, + "python_imports": { + "description": "Import lines the Python form needs, e.g. 'import numpy as np'.", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "uniqueItems": true + }, + "tolerance": { + "description": "Per-rule override of the verify tolerance (numpy.allclose rtol/atol).", + "type": "object", + "additionalProperties": false, + "minProperties": 1, + "properties": { + "rtol": { + "type": "number", + "minimum": 0 + }, + "atol": { + "type": "number", + "minimum": 0 + } + } + }, + "from_python": { + "description": "The Python -> .m direction: its own lifecycle stage and the Python construct tags (dualect/pyconstructs.py) this rule covers.", + "type": "object", + "additionalProperties": false, + "required": [ + "status", + "match" + ], + "properties": { + "status": { + "enum": [ + "unsupported", + "guided", + "mechanical" + ] + }, + "match": { + "type": "array", + "items": { + "type": "string", + "pattern": "^py:[a-z-]+(:[A-Za-z0-9_.-]+)?$" + }, + "uniqueItems": true + } + } + } + }, + "$defs": { + "ruleId": { + "type": "string", + "pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$" + }, + "versionBound": { + "description": "Per-dialect version (inclusive for since, exclusive for until), or null for unbounded.", + "oneOf": [ + { + "type": "null" + }, + { + "type": "object", + "additionalProperties": false, + "minProperties": 1, + "properties": { + "octave": { + "type": "string", + "pattern": "^[0-9]+(\\.[0-9]+)*$" + }, + "matlab": { + "type": "string", + "pattern": "^R[0-9]{4}[ab]$" + } + } + } + ] + } + } +} diff --git a/dualect/source.py b/dualect/source.py new file mode 100644 index 0000000..b0e160a --- /dev/null +++ b/dualect/source.py @@ -0,0 +1,401 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Rewriting Octave-only syntax so the tree-sitter grammar can read it. + +The ``tree-sitter-matlab`` grammar knows only the MATLAB dialect. Fed Octave's +extensions it either reports an error (``#`` comments, ``!=``) or, worse, +*silently misreads* them (``do`` and ``until`` parse as command syntax, ``n++`` +as ``n + (+ )``). Rather than fork the grammar, :func:`normalize` +rewrites those spellings into equivalents the grammar understands, outside +strings and comments, and records what it changed: + +* ``#`` comments and ``#{ ... #}`` blocks become ``%`` (same length); +* ``!=`` becomes ``~=`` and ``!x`` becomes ``~x`` (same length); +* ``endfunction``, ``endif``, ``endfor``, ``endwhile``, ``endswitch``, ... become + ``end`` padded with spaces (same length); +* ``x += e`` (and ``-=``, ``*=``, ``/=``, ``^=``) blank the operator character and + record it in :attr:`NormalizedSource.aug_ops`; +* ``x++`` / ``x--`` / ``++x`` / ``--x`` statements become ``x+0`` / ``0+x`` (a + blanked operator would read as command syntax) and are recorded in + :attr:`NormalizedSource.increments`; +* ``do ... until cond`` becomes ``while __dualect_do__ ... __dualect_until__ = + cond; end``, which :mod:`dualect.lower` turns back into a ``DoUntil`` node. + +No newline is ever added or removed, so line numbers survive unchanged; the few +rewrites that change a line's length are mapped back by +:meth:`NormalizedSource.position`. Each rewrite is also recorded as an +:class:`OctaveFeature`, so a run with ``--dialect matlab`` can reject code that +is not valid MATLAB. +""" + +from dataclasses import dataclass, field + +DO_MARKER = "__dualect_do__" +UNTIL_MARKER = "__dualect_until__" + +#: Octave's specific block terminators; all mean ``end``. +_END_KEYWORDS = frozenset( + { + "endfunction", "endif", "endfor", "endwhile", "endswitch", "end_try_catch", + "end_unwind_protect", "endparfor", + } +) # fmt: skip + +_AUG_OPS = {"+": "plus", "-": "minus", "*": "mtimes", "/": "mrdivide", "^": "mpower"} +_IDENT_START = frozenset("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_") +_IDENT_CHARS = _IDENT_START | frozenset("0123456789") +#: A quote right after one of these characters is a transpose, not a string. +_TRANSPOSE_AFTER = _IDENT_CHARS | frozenset(")]}'.") +_OPEN = frozenset("([{") +_CLOSE = frozenset(")]}") + + +@dataclass(frozen=True) +class OctaveFeature: + """One use of syntax that only Octave accepts. + + :param name: what it is, e.g. ``"# comment"`` or ``"!="``. + :param line: 1-based line in the original source. + :param col: 1-based column in the original source. + """ + + name: str + line: int + col: int + + +@dataclass +class NormalizedSource: + """Source text after :func:`normalize`, with the way back to the original. + + :param original: the text as the user wrote it. + :param text: the rewritten text handed to the parser. + :param features: Octave-only syntax that was found. + :param aug_ops: normalized offset of an ``=`` that was ``op=`` -> operator name. + :param increments: normalized offset of the identifier of an ``x++``-style + statement -> ``"plus"`` or ``"minus"``. + """ + + original: str + text: str + _to_original: list[int] = field(repr=False) + features: list[OctaveFeature] = field(default_factory=list) + aug_ops: dict[int, str] = field(default_factory=dict) + increments: dict[int, str] = field(default_factory=dict) + + def __post_init__(self) -> None: + """Index line starts of the original text for :meth:`position`.""" + self._line_starts = [0] + for index, char in enumerate(self.original): + if char == "\n": + self._line_starts.append(index + 1) + + def original_offset(self, offset: int) -> int: + """Map a character offset in :attr:`text` to one in :attr:`original`.""" + if offset >= len(self._to_original): + return len(self.original) + return self._to_original[offset] + + def position(self, offset: int) -> tuple[int, int]: + """Return the 1-based ``(line, column)`` in the original of a normalized offset.""" + original = self.original_offset(offset) + lo, hi = 0, len(self._line_starts) - 1 + while lo < hi: + mid = (lo + hi + 1) // 2 + if self._line_starts[mid] <= original: + lo = mid + else: + hi = mid - 1 + return lo + 1, original - self._line_starts[lo] + 1 + + +class _Writer: + """Accumulates normalized text together with the original offset of each char.""" + + def __init__(self) -> None: + self.chars: list[str] = [] + self.origin: list[int] = [] + + def put(self, text: str, origin: int) -> None: + """Append ``text``; every character maps back to ``origin`` plus its index.""" + for index, char in enumerate(text): + self.chars.append(char) + self.origin.append(origin + index) + + def insert(self, text: str, origin: int) -> None: + """Append text that has no counterpart; all of it maps to ``origin``.""" + for char in text: + self.chars.append(char) + self.origin.append(origin) + + @property + def offset(self) -> int: + """Offset of the next character to be written.""" + return len(self.chars) + + +#: Characters that make ``.`` the start of a dotted operator after a number. +_DOT_OPS = frozenset({"^", "*", "/", "\\", "'"}) + + +def _line_col(source: str, offset: int) -> tuple[int, int]: + """1-based line and column of an offset in ``source``.""" + line = source.count("\n", 0, offset) + 1 + col = offset - (source.rfind("\n", 0, offset) + 1) + 1 + return line, col + + +def _rest_is_statement_end(source: str, start: int) -> bool: + """Whether only whitespace then a terminator (newline, ``;``, ``,``, comment) follows.""" + index = start + while index < len(source) and source[index] in " \t": + index += 1 + return index >= len(source) or source[index] in "\r\n;,%#" + + +def _block_marker(line: str) -> str | None: + """Return ``"{"``/``"}"`` when a line is only a block-comment marker.""" + stripped = line.strip() + if stripped in ("%{", "#{"): + return "{" + if stripped in ("%}", "#}"): + return "}" + return None + + +def normalize(source: str) -> NormalizedSource: + """Rewrite Octave-only syntax into what the grammar accepts (see module doc). + + :param source: ``.m`` source text. + :returns: the rewritten text with the map back to ``source``. + """ + out = _Writer() + features: list[OctaveFeature] = [] + aug_ops: dict[int, str] = {} + increments: dict[int, str] = {} + + def note(name: str, offset: int) -> None: + line, col = _line_col(source, offset) + features.append(OctaveFeature(name=name, line=line, col=col)) + + i = 0 + n = len(source) + depth = 0 # bracket nesting: separators inside brackets do not end statements + block_depth = 0 # %{ ... %} nesting + statement_start = True + pending_until = False # an `until` condition is open and needs "; end" + line_start = True + + while i < n: + char = source[i] + + # Block comments are recognized per line, before any other lexing. + if line_start: + line_end = source.find("\n", i) + line_end = n if line_end == -1 else line_end + marker = _block_marker(source[i:line_end]) + if marker == "{" or (block_depth and marker is not None): + block_depth += 1 if marker == "{" else -1 + text = source[i:line_end] + if "#" in text: + note("#{ #} block comment", i) + text = text.replace("#", "%", 1) + out.put(text, i) + i = line_end + line_start = False + continue + if block_depth: + out.put(source[i:line_end], i) + i = line_end + line_start = False + continue + line_start = False + + if char == "\n": + if pending_until: + out.insert("; end", i) + pending_until = False + out.put(char, i) + i += 1 + line_start = True + if depth == 0: + statement_start = True + continue + + if char in " \t\r": + out.put(char, i) + i += 1 + continue + + # Comments: `%` or `#` up to the end of the line. + if char in "%#": + if pending_until: + out.insert("; end ", i) + pending_until = False + end = source.find("\n", i) + end = n if end == -1 else end + if char == "#": + note("# comment", i) + out.put("%", i) + out.put(source[i + 1 : end], i + 1) + else: + out.put(source[i:end], i) + i = end + continue + + # `...` continues the line; the rest of the line is a comment. + if source.startswith("...", i): + end = source.find("\n", i) + end = n if end == -1 else end + out.put(source[i:end], i) + i = end + continue + + # Strings: double-quoted always; single-quoted unless it is a transpose. + if char == '"' or (char == "'" and not (i > 0 and source[i - 1] in _TRANSPOSE_AFTER)): + end = i + 1 + while end < n and source[end] != "\n": + if source[end] == char: + if end + 1 < n and source[end + 1] == char: # doubled quote + end += 2 + continue + end += 1 + break + if char == '"' and source[end] == "\\": + end += 2 + continue + end += 1 + out.put(source[i:end], i) + i = end + statement_start = False + continue + + if char in ";," and depth == 0: + if pending_until: + out.insert("; end", i) + pending_until = False + out.put(char, i) + i += 1 + statement_start = True + continue + + if char in _OPEN: + depth += 1 + elif char in _CLOSE: + depth = max(depth - 1, 0) + + # `!=` and `!x`: Octave spellings of `~=` and `~x`. + if char == "!": + note("!=" if source.startswith("!=", i) else "! (not)", i) + out.put("~", i) + i += 1 + statement_start = False + continue + + # Prefix increment statement `++x` / `--x`. + if statement_start and depth == 0 and source.startswith(("++", "--"), i): + j = i + 2 + while j < n and source[j] in " \t": + j += 1 + k = j + while k < n and source[k] in _IDENT_CHARS: + k += 1 + if j < k and source[j] in _IDENT_START and _rest_is_statement_end(source, k): + note(source[i : i + 2], i) + out.put("0+", i) + out.put(source[i + 2 : j], i + 2) + increments[out.offset] = "plus" if char == "+" else "minus" + out.put(source[j:k], j) + i = k + statement_start = False + continue + + if char in _IDENT_START and not (i > 0 and source[i - 1] in _IDENT_CHARS | {"."}): + k = i + while k < n and source[k] in _IDENT_CHARS: + k += 1 + word = source[i:k] + if word in _END_KEYWORDS: + note(word, i) + out.put("end", i) + out.insert(" " * (len(word) - 3), i + 3) + i = k + statement_start = False + continue + if ( + word == "do" + and statement_start + and depth == 0 + and _rest_is_statement_end(source, k) + ): + note("do ... until", i) + out.insert(f"while {DO_MARKER}", i) + i = k + statement_start = False + continue + if word == "until" and statement_start and depth == 0: + note("do ... until", i) + out.insert(f"{UNTIL_MARKER} =", i) + i = k + pending_until = True + statement_start = False + continue + if statement_start and depth == 0: + # Postfix increment statement `x++` / `x--`. + j = k + while j < n and source[j] in " \t": + j += 1 + if source.startswith(("++", "--"), j) and _rest_is_statement_end(source, j + 2): + note(source[j : j + 2], j) + increments[out.offset] = "plus" if source[j] == "+" else "minus" + out.put(source[i:j], i) + out.put("+0", j) + i = j + 2 + statement_start = False + continue + out.put(word, i) + i = k + statement_start = False + continue + + # Augmented assignment `x op= e` at statement level. + if ( + depth == 0 + and char in _AUG_OPS + and source.startswith("=", i + 1) + and not source.startswith("==", i + 1) + ): + note(f"{char}=", i) + out.put(" ", i) + aug_ops[out.offset] = _AUG_OPS[char] + out.put("=", i + 1) + i += 2 + statement_start = False + continue + + # `2.^x` is `2 .^ x` in both dialects (the lexer prefers the dotted + # operator), but the grammar reads the number `2.` and then `^`, a + # matrix power. A space keeps the dotted operator whole. + if char.isdigit() and source.startswith(".", i + 1) and source[i + 2 : i + 3] in _DOT_OPS: + out.put(char, i) + out.insert(" ", i + 1) + i += 1 + statement_start = False + continue + + out.put(char, i) + i += 1 + statement_start = False + + if pending_until: + out.insert("; end", n) + + return NormalizedSource( + original=source, + text="".join(out.chars), + _to_original=out.origin, + features=features, + aug_ops=aug_ops, + increments=increments, + ) diff --git a/dualect/translators.py b/dualect/translators.py new file mode 100644 index 0000000..5e967a6 --- /dev/null +++ b/dualect/translators.py @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Loading the per-rule deterministic translators (``rules/**/translate.py``). + +A rule's ``translate.py`` is a small module next to its ``rule.yaml``. It +defines ``translate(node, ctx)``, which turns the IR nodes of that rule's +constructs into Python (:mod:`ast` expressions, or :class:`dualect.emit.Line` +lists for statements), using the :class:`dualect.emit.Context` it is given. +Optional hooks: + +* ``translate_store(stmt, ctx)``: an assignment *to* the construct + (indexing: ``x(i) = v``); +* ``translate_multi(stmt, ctx)``: a call with several outputs (``[m, i] = max(v)``); +* ``position_outputs(call, nargout)``: which outputs of a built-in call are + 1-based positions (``find``), so the emitter may store them 0-based; +* ``translate_positions(call, ctx)``: the 0-based form of such a call. + +Translators live with their rule so that a language change touches one folder. +The engine only runs the translator of a rule whose status is ``mechanical``. +""" + +import importlib.util +from types import ModuleType + +from dualect.errors import RuleError +from dualect.rulebook import TRANSLATOR_FILE, Rule + + +class TranslatorSet: + """Lazily loaded translators, by rule id.""" + + def __init__(self, *, rules: list[Rule]) -> None: + """Remember where each rule's translator lives. + + :param rules: all loaded rules. + """ + self._rules = {rule.id: rule for rule in rules} + self._modules: dict[str, ModuleType | None] = {} + + def get(self, rule_id: str) -> ModuleType | None: + """The translator module of a rule, or ``None`` when it has none.""" + if rule_id not in self._modules: + rule = self._rules.get(rule_id) + self._modules[rule_id] = load_translator(rule) if rule is not None else None + return self._modules[rule_id] + + +def load_translator(rule: Rule) -> ModuleType | None: + """Import ``translate.py`` from a rule folder. + + :param rule: the rule. + :returns: the module, or ``None`` when the folder has no translator. + :raises RuleError: if the file does not define ``translate``. + """ + path = rule.path / TRANSLATOR_FILE + if not path.is_file(): + return None + name = "dualect_rules." + rule.id.replace("/", ".").replace("-", "_") + spec = importlib.util.spec_from_file_location(name, path) + if spec is None or spec.loader is None: + raise RuleError(f"{rule.id}: cannot load {path}") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + if not callable(getattr(module, "translate", None)): + raise RuleError(f"{rule.id}: {TRANSLATOR_FILE} must define translate(node, ctx)") + return module diff --git a/dualect/validate.py b/dualect/validate.py new file mode 100644 index 0000000..c37e0b3 --- /dev/null +++ b/dualect/validate.py @@ -0,0 +1,162 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Validating rule folders against the schema and the folder conventions. + +The JSON Schema (``dualect/schema/rule.schema.json``) checks the shape of one +``rule.yaml``. The checks here add what a schema cannot see: the id matches the +folder, cases come in pairs, the status agrees with the files present, and +``related`` ids point at rules that exist. +""" + +import ast +import functools +import json +from pathlib import Path +from typing import Any + +from jsonschema import Draft202012Validator + +from dualect.constructs import is_known_tag +from dualect.errors import RuleError +from dualect.paths import schema_path +from dualect.pyconstructs import is_known_py_tag +from dualect.rulebook import ( + CASES_DIR, + TRANSLATOR_FILE, + Status, + find_cases, + read_rule_yaml, + rule_dirs, + rule_id_for, +) + + +@functools.cache +def _validator() -> Draft202012Validator: + """Build the schema validator once; the schema file never changes at runtime.""" + schema = json.loads(schema_path().read_text(encoding="utf-8")) + Draft202012Validator.check_schema(schema) + return Draft202012Validator(schema) + + +def schema_errors(*, data: dict[str, Any]) -> list[str]: + """Return human-readable schema violations for one parsed ``rule.yaml``. + + :param data: the parsed mapping. + :returns: one message per violation; empty when valid. + """ + errors = sorted(_validator().iter_errors(data), key=lambda err: list(err.absolute_path)) + messages = [] + for err in errors: + where = "/".join(str(part) for part in err.absolute_path) or "(top level)" + messages.append(f"{where}: {err.message}") + return messages + + +def validate_rule_dir(*, rule_dir: Path) -> list[str]: + """Check one rule folder; return problems as ``": "`` strings. + + :param rule_dir: folder containing ``rule.yaml``. + """ + expected_id = rule_id_for(rule_dir=rule_dir) + try: + data = read_rule_yaml(path=rule_dir / "rule.yaml") + except RuleError as exc: + return [f"{expected_id}: {exc}"] + + problems = schema_errors(data=data) + if data.get("id") != expected_id: + problems.append(f"id {data.get('id')!r} does not match folder (expected {expected_id!r})") + + # Cases must come in pairs: a lone .m or .py is a half-written example, and + # silently skipping it would hide the gap. + cases_dir = rule_dir / CASES_DIR + m_stems = {path.stem for path in cases_dir.glob("*.m")} + py_stems = {path.stem for path in cases_dir.glob("*.py")} + for stem in sorted(m_stems - py_stems): + problems.append(f"cases/{stem}.m has no matching cases/{stem}.py") + for stem in sorted(py_stems - m_stems): + problems.append(f"cases/{stem}.py has no matching cases/{stem}.m") + + for tag in data.get("match") or []: + if isinstance(tag, str) and not is_known_tag(tag): + problems.append(f"match: unknown construct tag {tag!r} (see dualect/constructs.py)") + + from_python = data.get("from_python") + if isinstance(from_python, dict): + for tag in from_python.get("match") or []: + if isinstance(tag, str) and not is_known_py_tag(tag): + problems.append( + f"from_python.match: unknown construct tag {tag!r} " + "(see dualect/pyconstructs.py)" + ) + if from_python.get("status") == Status.MECHANICAL and not _defines_lift(rule_dir): + problems.append("from_python status 'mechanical' needs lift() in translate.py") + + status = data.get("status") + has_cases = bool(find_cases(rule_dir=rule_dir)) + if status in (Status.GUIDED, Status.MECHANICAL) and not has_cases: + problems.append(f"status {status!r} needs at least one case pair in cases/") + if status == Status.MECHANICAL and not (rule_dir / TRANSLATOR_FILE).is_file(): + problems.append(f"status 'mechanical' needs a {TRANSLATOR_FILE}") + + return [f"{expected_id}: {problem}" for problem in problems] + + +def _defines_lift(rule_dir: Path) -> bool: + """Whether the rule's ``translate.py`` defines a top-level ``lift`` function.""" + path = rule_dir / TRANSLATOR_FILE + if not path.is_file(): + return False + tree = ast.parse(path.read_text(encoding="utf-8")) + return any(isinstance(node, ast.FunctionDef) and node.name == "lift" for node in tree.body) + + +def validate_all(*, rules_dir: Path) -> list[str]: + """Validate every rule under ``rules_dir``, including cross-rule references. + + :param rules_dir: root of the knowledge base. + :returns: every problem found; empty when the whole knowledge base is valid. + """ + dirs = rule_dirs(rules_dir=rules_dir) + problems: list[str] = [] + known_ids = {rule_id_for(rule_dir=path) for path in dirs} + owners: dict[str, str] = {} + for rule_dir in dirs: + problems.extend(validate_rule_dir(rule_dir=rule_dir)) + rule_id = rule_id_for(rule_dir=rule_dir) + try: + related = read_rule_yaml(path=rule_dir / "rule.yaml").get("related") or [] + except RuleError: + continue # already reported by validate_rule_dir + problems.extend(_claim_tags(rule_dir=rule_dir, rule_id=rule_id, owners=owners)) + for other in related: + if other not in known_ids: + problems.append(f"{rule_id}: related rule {other!r} does not exist") + elif other == rule_id: + problems.append(f"{rule_id}: lists itself in related") + return problems + + +def _claim_tags(*, rule_dir: Path, rule_id: str, owners: dict[str, str]) -> list[str]: + """Record the tags a rule matches; two unversioned rules may not share one. + + Variant rules (docs/design.md section 4.4) may share a tag when at least one + of them is bounded by ``since``/``until``; the dialect filter then decides. + """ + try: + data = read_rule_yaml(path=rule_dir / "rule.yaml") + except RuleError: + return [] + problems = [] + # Python tags are not filtered by source dialect: they may never be shared. + block = data.get("from_python") + tags = list(block.get("match") or []) if isinstance(block, dict) else [] + if not (data.get("since") or data.get("until")): + tags = list(data.get("match") or []) + tags + for tag in tags: + other = owners.setdefault(str(tag), rule_id) + if other != rule_id: + problems.append(f"{rule_id}: tag {tag!r} is already matched by {other}") + return problems diff --git a/dualect/verify.py b/dualect/verify.py new file mode 100644 index 0000000..a6f0cd0 --- /dev/null +++ b/dualect/verify.py @@ -0,0 +1,190 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""The verify harness: run a ``.m`` script and a ``.py`` script, compare outputs. + +Every variable the ``.m`` script leaves behind (except ``ans``) must exist on the +Python side with an equal value (see :mod:`dualect.compare`). Python-only names +are allowed, since an idiomatic translation may need extra temporaries, and are +listed in the result. A pair that compares *nothing* fails: a check that checked +nothing must not read as a pass. + +Case files may carry directives in comments, on either side:: + + % dualect: index idx k -- 1-based on the .m side, 0-based in Python + % dualect: ignore tmp -- legitimately differs (e.g. a loop counter) +""" + +import re +from collections.abc import Iterable +from dataclasses import dataclass, field +from pathlib import Path + +from dualect.compare import Tolerance, compare_values +from dualect.errors import DirectiveError +from dualect.runners import MRunner, run_py_script + +_DIRECTIVE = re.compile(r"^\s*[%#]+\s*dualect:\s*(?P.*)$") +_IDENTIFIER = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$") +_KNOWN_DIRECTIVES = ("index", "ignore") + + +@dataclass(frozen=True) +class VerifyOptions: + """What to compare and how strictly. + + :param tolerance: allclose tolerances. + :param index_vars: names holding indices (1-based in ``.m``, 0-based in Python). + :param ignore: names excluded from comparison. + """ + + tolerance: Tolerance = field(default_factory=Tolerance) + index_vars: frozenset[str] = frozenset() + ignore: frozenset[str] = frozenset() + + +@dataclass(frozen=True) +class VarResult: + """Outcome for one compared variable. + + :param name: variable name. + :param ok: whether the values matched. + :param detail: reason for a mismatch, or a note; empty when plainly equal. + """ + + name: str + ok: bool + detail: str = "" + + +@dataclass(frozen=True) +class VerifyResult: + """Outcome of verifying one ``.m``/``.py`` pair. + + :param m_path: the ``.m`` script. + :param py_path: the ``.py`` script. + :param variables: per-variable results, sorted by name. + :param python_only: names defined only by the Python script (informational). + """ + + m_path: Path + py_path: Path + variables: tuple[VarResult, ...] + python_only: tuple[str, ...] = () + + @property + def ok(self) -> bool: + """True when at least one variable was compared and all matched.""" + return bool(self.variables) and all(var.ok for var in self.variables) + + def report(self) -> str: + """Return a human-readable, multi-line summary.""" + lines = [f"verify {self.m_path} <-> {self.py_path}"] + if not self.variables: + lines.append(" FAIL nothing compared: the .m script left no variables") + for var in self.variables: + mark = "ok " if var.ok else "FAIL" + suffix = f" ({var.detail})" if var.detail else "" + lines.append(f" {mark} {var.name}{suffix}") + if self.python_only: + lines.append(f" note: Python-only names not compared: {', '.join(self.python_only)}") + lines.append("PASS" if self.ok else "FAIL") + return "\n".join(lines) + + +def parse_directives(*, text: str, path: Path) -> tuple[frozenset[str], frozenset[str]]: + """Read ``dualect:`` comment directives from a script. + + :param text: the script source. + :param path: used in error messages. + :returns: ``(index_vars, ignore)``. + :raises DirectiveError: for an unknown directive or a malformed name, so a + typo cannot silently weaken a comparison. + """ + found: dict[str, set[str]] = {key: set() for key in _KNOWN_DIRECTIVES} + for line_number, line in enumerate(text.splitlines(), start=1): + match = _DIRECTIVE.match(line) + if match is None: + continue + words = match.group("body").replace(",", " ").split() + if not words or words[0] not in _KNOWN_DIRECTIVES: + raise DirectiveError( + f"{path}:{line_number}: unknown directive {line.strip()!r}; " + f"expected one of {', '.join(_KNOWN_DIRECTIVES)}" + ) + names = words[1:] + if not names or not all(_IDENTIFIER.match(name) for name in names): + raise DirectiveError(f"{path}:{line_number}: expected variable names after {words[0]}") + found[words[0]].update(names) + return frozenset(found["index"]), frozenset(found["ignore"]) + + +def options_for_pair( + *, m_path: Path, py_path: Path, tolerance: Tolerance, extra_index: Iterable[str] = () +) -> VerifyOptions: + """Build :class:`VerifyOptions` from the directives in both files. + + :param m_path: the ``.m`` script. + :param py_path: the ``.py`` script. + :param tolerance: tolerances to use (global default or a rule's override). + :param extra_index: additional index names, e.g. from the command line. + """ + index_vars: set[str] = set(extra_index) + ignore: set[str] = set() + for path in (m_path, py_path): + found_index, found_ignore = parse_directives( + text=path.read_text(encoding="utf-8"), path=path + ) + index_vars |= found_index + ignore |= found_ignore + return VerifyOptions( + tolerance=tolerance, index_vars=frozenset(index_vars), ignore=frozenset(ignore) + ) + + +def verify_pair( + *, + m_path: Path, + py_path: Path, + options: VerifyOptions | None = None, + runner: MRunner | None = None, +) -> VerifyResult: + """Run both scripts and compare every ``.m`` output with the Python value. + + :param m_path: the ``.m`` script. + :param py_path: the ``.py`` script. + :param options: comparison settings; by default, read from the files' + directives with the global default tolerance. + :param runner: an existing :class:`MRunner` to reuse (saves Octave start-up); + one is created and closed here if not given. + :raises ExecutionError: if either script fails to run. + :raises RuntimeMissingError: if Octave is not installed. + """ + if options is None: + options = options_for_pair(m_path=m_path, py_path=py_path, tolerance=Tolerance()) + + if runner is None: + with MRunner() as own_runner: + m_outputs = own_runner.run(path=m_path) + else: + m_outputs = runner.run(path=m_path) + py_outputs = run_py_script(path=py_path) + + results = [] + for name in sorted(set(m_outputs) - options.ignore): + if name not in py_outputs: + results.append(VarResult(name=name, ok=False, detail="missing on the Python side")) + continue + reason = compare_values( + m_value=m_outputs[name], + py_value=py_outputs[name], + tolerance=options.tolerance, + index=name in options.index_vars, + ) + note = "index, compared as 0-based" if name in options.index_vars else "" + results.append(VarResult(name=name, ok=reason is None, detail=reason or note)) + + python_only = tuple(sorted(set(py_outputs) - set(m_outputs) - options.ignore)) + return VerifyResult( + m_path=m_path, py_path=py_path, variables=tuple(results), python_only=python_only + ) diff --git a/llms.txt b/llms.txt new file mode 100644 index 0000000..91c5f60 --- /dev/null +++ b/llms.txt @@ -0,0 +1,53 @@ +# dualect + +> Translates numeric code between .m files (Octave/MATLAB style) and Python/NumPy +> in both directions, one tested rule per construct, and verifies every +> translation by running both sides. + +Each rule lives in `rules///`: `rule.yaml` explains the +difference between the languages (`why`, `pitfalls`) for a human or an LLM, +`translate.py` holds the deterministic translators, and `cases/` holds `.m` / +`.py` pairs that run in both languages. A rule's status is given per direction: +`mechanical` (translated by its `translate.py`, every case verified), `guided` +(an LLM applies the rule; the result is verified) or `unsupported`. Use +`dualect scan FILE` for the rules a file needs and `dualect context FILE` for +them as prompt context; the MCP server (`dualect mcp`) offers the same as tools. +Generated by `dualect llms-txt`; do not edit by hand. + +## Rules + +- [builtins/constants](rules/builtins/constants/rule.yaml): Constants: `pi`, `Inf`, `NaN`, `eps`, `true`, `false`, `i` (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [builtins/elementwise-math](rules/builtins/elementwise-math/rule.yaml): Element-wise math: `abs`, `sqrt`, `exp`, `floor`, `mod`, `rem`, `isnan`, ... (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [builtins/find](rules/builtins/find/rule.yaml): `find`: 1-based, column-major indices (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [builtins/isempty](rules/builtins/isempty/rule.yaml): `isempty` (.m to Python: mechanical; Python to .m: n/a; 1 case) +- [builtins/linspace](rules/builtins/linspace/rule.yaml): `linspace` default count and edge cases (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [builtins/size-numel-length](rules/builtins/size-numel-length/rule.yaml): `size`, `numel`, `length` (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [builtins/sum-mean-max](rules/builtins/sum-mean-max/rule.yaml): `sum`, `mean`, `max`, `min`: dimensions and index outputs (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [builtins/zeros-ones-eye](rules/builtins/zeros-ones-eye/rule.yaml): `zeros`, `ones`, `eye` (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [control-flow/for-columns](rules/control-flow/for-columns/rule.yaml): `for` loops iterate over columns (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [control-flow/if-elseif](rules/control-flow/if-elseif/rule.yaml): `if` / `elseif` / `else` and array conditions (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [control-flow/switch](rules/control-flow/switch/rule.yaml): `switch` / `case` / `otherwise` (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [control-flow/while](rules/control-flow/while/rule.yaml): `while` loops and Octave's `do ... until` (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [functions/definition](rules/functions/definition/rule.yaml): Function definitions and argument copy semantics (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [functions/multiple-returns](rules/functions/multiple-returns/rule.yaml): Multiple return values and `nargout` (.m to Python: guided; Python to .m: mechanical; 1 case) +- [functions/nargin](rules/functions/nargin/rule.yaml): Optional arguments with `nargin` (.m to Python: guided; Python to .m: guided; 1 case) +- [indexing/colon-all](rules/indexing/colon-all/rule.yaml): `A(:)`: all elements as one column (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [indexing/end-in-index](rules/indexing/end-in-index/rule.yaml): `end` inside an index expression (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [indexing/grow-on-assign](rules/indexing/grow-on-assign/rule.yaml): Growing an array by assigning past its end (.m to Python: guided; Python to .m: guided; 2 cases) +- [indexing/logical](rules/indexing/logical/rule.yaml): Logical (mask) indexing (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [indexing/one-based](rules/indexing/one-based/rule.yaml): One-based indexing and column-major linear indices (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [indexing/ranges](rules/indexing/ranges/rule.yaml): Colon ranges `a:b` and `a:step:b` (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [io/display](rules/io/display/rule.yaml): Printing: missing `;`, `disp`, `printf` / `fprintf` (.m to Python: guided; Python to .m: guided; 1 case) +- [operators/arithmetic](rules/operators/arithmetic/rule.yaml): `+`, `-`, comparisons and implicit expansion (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [operators/augmented-assignment](rules/operators/augmented-assignment/rule.yaml): `x += e`, `x++` and friends (Octave only) (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [operators/division](rules/operators/division/rule.yaml): `/`, `./` and `\`: true division and linear solves (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [operators/matrix-multiply](rules/operators/matrix-multiply/rule.yaml): `*` (matrix product) vs `.*` (element-wise) (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [operators/not-equal](rules/operators/not-equal/rule.yaml): `~=` / `!=` and logical NOT `~` / `!` (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [operators/power](rules/operators/power/rule.yaml): `^` (matrix power) vs `.^` (element-wise power) (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [operators/short-circuit](rules/operators/short-circuit/rule.yaml): `&&`/`||` (short-circuit) vs `&`/`|` (element-wise) (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [operators/transpose](rules/operators/transpose/rule.yaml): `'` (conjugate transpose) vs `.'` (transpose) (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [syntax/array-literals](rules/syntax/array-literals/rule.yaml): Bracket literals: rows, columns, matrices, `[]` and concatenation (.m to Python: mechanical; Python to .m: mechanical; 2 cases) +- [syntax/command-syntax](rules/syntax/command-syntax/rule.yaml): Command syntax: `name arg1 arg2` vs `name('arg1', 'arg2')` (.m to Python: guided; Python to .m: n/a; 1 case) +- [syntax/comments](rules/syntax/comments/rule.yaml): Comments: `%`, `#`, and `%{ ... %}` blocks (.m to Python: mechanical; Python to .m: mechanical; 1 case) +- [syntax/line-continuation](rules/syntax/line-continuation/rule.yaml): Line continuation with `...` (.m to Python: mechanical; Python to .m: n/a; 1 case) +- [types/char-strings](rules/types/char-strings/rule.yaml): Char arrays `'...'` and double-quoted strings (.m to Python: mechanical; Python to .m: mechanical; 1 case) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8ab9b51 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,115 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +[project] +name = "dualect" +version = "0.1.0" +description = "Translate numeric code between .m files and Python/NumPy, verified by running both sides." +readme = "README.md" +requires-python = ">=3.11" +license = "Apache-2.0" +license-files = ["LICENSE"] +authors = [{ name = "Evan Gress" }] +keywords = ["numpy", "translation", "transpiler", "scientific-computing"] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Science/Research", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering", + "Topic :: Software Development :: Code Generators", + "Typing :: Typed", +] +dependencies = [ + "jsonschema>=4.23", + "numpy>=2.0", + # Runs .m code from Python; used by `dualect verify` and the rule-case tests. + "oct2py>=5.8", + "pyyaml>=6.0", + # Parses .m source (docs/design.md section 9). The grammar knows only the + # MATLAB dialect; dualect/source.py rewrites Octave syntax in front of it. + "tree-sitter>=0.24", + "tree-sitter-matlab>=1.3.3,<2", + # Formats the Python that `dualect translate` emits. + "ruff>=0.8", + # The official Model Context Protocol SDK, for `dualect mcp` (2.x API: MCPServer). + "mcp>=2.3,<3", +] + +[project.scripts] +dualect = "dualect.cli:main" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["dualect"] + +# Rules live in this repository (docs/design.md section 12). A built wheel +# carries a copy inside the package so an installed `dualect` still finds them; +# dualect.paths looks there when the source-tree `rules/` folder is absent. +[tool.hatch.build.targets.wheel.force-include] +"rules" = "dualect/_rules" + +[tool.hatch.build.targets.sdist] +include = ["/dualect", "/rules", "/README.md", "/LICENSE", "/docs"] + +[dependency-groups] +dev = [ + "mypy>=1.13", + "pytest>=8.3", + "ruff>=0.8", + # Type stubs are only needed by mypy, so they live here. + "types-jsonschema", + "types-pyyaml", +] + +[tool.pytest.ini_options] +testpaths = ["tests"] +addopts = "-ra" +markers = [ + "octave: needs the GNU Octave executable (skipped when it is not installed)", +] + +# --- Ruff: linter + formatter ------------------------------------------------- +[tool.ruff] +line-length = 100 +target-version = "py311" + +[tool.ruff.lint] +select = [ + "E", "W", # pycodestyle + "F", # pyflakes + "I", # isort + "B", # flake8-bugbear + "UP", # pyupgrade + "SIM", # flake8-simplify + "NPY", # NumPy-specific checks +] + +[tool.ruff.lint.per-file-ignores] +# Rule case files are hand-written translation targets: they are scripts whose +# top-level variables are the compared outputs, so "unused" names are the point. +# They mirror the .m side line by line, so a ternary (SIM108), a named +# lambda for a function handle (E731) or enumerate() for a counter (SIM113) +# would hide the correspondence. +"rules/**/cases/*.py" = ["F841", "B007", "E731", "SIM108", "SIM113"] + +[tool.ruff.lint.isort] +known-first-party = ["dualect"] + +# --- mypy ------------------------------------------------------------------- +[tool.mypy] +python_version = "3.11" +packages = ["dualect"] +warn_unused_ignores = true +disallow_untyped_defs = true +disallow_incomplete_defs = true +strict_optional = true + +# oct2py and ruff's launcher ship no type information. +[[tool.mypy.overrides]] +module = ["oct2py", "oct2py.*", "ruff", "ruff.*"] +ignore_missing_imports = true diff --git a/rules/builtins/constants/cases/basic.m b/rules/builtins/constants/cases/basic.m new file mode 100644 index 0000000..7f4a753 --- /dev/null +++ b/rules/builtins/constants/cases/basic.m @@ -0,0 +1,8 @@ +p = pi; +big = Inf; +missing = NaN; +tiny = eps; +yes = true; +no = false; +unit = i; +never = NaN == NaN; % false in both languages diff --git a/rules/builtins/constants/cases/basic.py b/rules/builtins/constants/cases/basic.py new file mode 100644 index 0000000..f217257 --- /dev/null +++ b/rules/builtins/constants/cases/basic.py @@ -0,0 +1,10 @@ +import numpy as np + +p = np.pi +big = np.inf +missing = np.nan +tiny = np.finfo(float).eps +yes = True +no = False +unit = 1j +never = np.nan == np.nan # false in both languages diff --git a/rules/builtins/constants/rule.yaml b/rules/builtins/constants/rule.yaml new file mode 100644 index 0000000..52d9f6e --- /dev/null +++ b/rules/builtins/constants/rule.yaml @@ -0,0 +1,38 @@ +id: builtins/constants +title: "Constants: `pi`, `Inf`, `NaN`, `eps`, `true`, `false`, `i`" +status: mechanical +dialects: [octave, matlab] +match: [call:pi, call:e, call:Inf, call:inf, call:NaN, call:nan, call:eps, call:true, call:false, call:i, call:j] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:const:np.pi + - py:const:np.e + - py:const:np.inf + - py:const:np.nan + - py:call:np.finfo + - py:attr:eps + - py:complex +octave: | + c = 2 * pi * r; + m = NaN; + ok = true; +python: | + c = 2 * np.pi * r + m = np.nan + ok = True +why: > + These are functions in `.m` code that take no arguments; in Python they are + module constants (`np.pi`, `np.inf`, `np.nan`) or keywords (`True`, `False`). + `eps` is the spacing of doubles at 1, `np.finfo(float).eps`. The imaginary + unit `i` (or `j`) is `1j`. +pitfalls: + - >- + `i`, `j` and `e` are often loop variables or data; a variable of that name + hides the constant, and then it is just a variable. + - >- + `NaN == NaN` is false in both languages; test with `isnan` / `np.isnan`. + - >- + `eps(x)` with an argument is the spacing at `x`: `np.spacing(x)`. +related: [builtins/elementwise-math] +python_imports: [import numpy as np] diff --git a/rules/builtins/constants/translate.py b/rules/builtins/constants/translate.py new file mode 100644 index 0000000..43a46de --- /dev/null +++ b/rules/builtins/constants/translate.py @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for builtins/constants: ``pi``, ``Inf``, ``NaN``, ``eps``, ``true``, ... + +Only the argument-free forms are constants; ``eps(x)``, ``Inf(2, 3)`` and +``true(n)`` build arrays and are declined. +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.lift import LiftContext + +_NUMPY = {"pi": "pi", "e": "e", "Inf": "inf", "inf": "inf", "NaN": "nan", "nan": "nan"} + + +def translate(node: ir.Call, ctx: Context) -> ast.expr: + """One constant.""" + if node.args: + ctx.decline(f"{node.func} with arguments") + name = node.func + if name in _NUMPY: + return ctx.np(_NUMPY[name]) + if name == "eps": + return ast.Attribute(value=ctx.call(ctx.np("finfo"), ast.Name("float")), attr="eps") + if name in ("true", "false"): + return ast.Constant(name == "true") + if name in ("i", "j"): + return ast.Constant(1j) + ctx.decline(f"constant {name}") + + +# --- Python -> .m ------------------------------------------------------------ +# +# np.pi is pi, np.inf Inf, np.nan NaN, np.finfo(float).eps eps, 2j is 2i. +# np.e is exp(1): a variable named e (common) would hide the function e. + + +_FROM_NUMPY = {"np.pi": "pi", "np.inf": "Inf", "np.nan": "NaN"} + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """A NumPy constant, machine epsilon or an imaginary literal.""" + loc = ctx.loc(node) + if isinstance(node, ast.Constant) and isinstance(node.value, complex): + return ir.Num(loc=loc, text="", value=node.value) + tag = ctx.tag(node) + if tag is not None and tag.startswith("py:const:"): + name = tag[len("py:const:") :] + if name in _FROM_NUMPY: + return ctx.call(_FROM_NUMPY[name], loc=loc) + if name == "np.e": + return ctx.call("exp", ctx.num(1), loc=loc) + ctx.decline(f"the NumPy name {name}") + if ( + isinstance(node, ast.Attribute) + and node.attr == "eps" + and isinstance(node.value, ast.Call) + and ctx.tag(node.value) == "py:call:np.finfo" + and [ast.unparse(a) for a in node.value.args] in (["float"], ["np.float64"]) + ): + return ctx.call("eps", loc=loc) + ctx.decline(f"{ast.unparse(node)}") diff --git a/rules/builtins/elementwise-math/cases/basic.m b/rules/builtins/elementwise-math/cases/basic.m new file mode 100644 index 0000000..23733e8 --- /dev/null +++ b/rules/builtins/elementwise-math/cases/basic.m @@ -0,0 +1,13 @@ +x = [-2.5 -1 0 1.5 4]; +a = abs(x); +r = sqrt(abs(x)); +e = exp(-x); +f = floor(x); +c = ceil(x); +t = fix(x); % toward zero +m = mod(-7, 3); % 2: the sign of the divisor +k = rem(-7, 3); % -1: the sign of the dividend +s = sin(pi * x); +nan_mask = isnan([1 NaN 3]); +h = abs(-3); % a scalar +ang = atan2(1, -1); diff --git a/rules/builtins/elementwise-math/cases/basic.py b/rules/builtins/elementwise-math/cases/basic.py new file mode 100644 index 0000000..ca26294 --- /dev/null +++ b/rules/builtins/elementwise-math/cases/basic.py @@ -0,0 +1,15 @@ +import numpy as np + +x = np.array([-2.5, -1, 0, 1.5, 4]) +a = np.abs(x) +r = np.sqrt(np.abs(x)) +e = np.exp(-x) +f = np.floor(x) +c = np.ceil(x) +t = np.trunc(x) # toward zero +m = np.mod(-7, 3) # 2: the sign of the divisor +k = np.fmod(-7, 3) # -1: the sign of the dividend +s = np.sin(np.pi * x) +nan_mask = np.isnan([1, np.nan, 3]) +h = abs(-3) # a scalar +ang = np.arctan2(1, -1) diff --git a/rules/builtins/elementwise-math/cases/half-away.m b/rules/builtins/elementwise-math/cases/half-away.m new file mode 100644 index 0000000..6d29bb5 --- /dev/null +++ b/rules/builtins/elementwise-math/cases/half-away.m @@ -0,0 +1,3 @@ +% round() rounds halves away from zero. +x = [2.5 -2.5 0.4]; +r = round(x); diff --git a/rules/builtins/elementwise-math/cases/half-away.py b/rules/builtins/elementwise-math/cases/half-away.py new file mode 100644 index 0000000..ed6597b --- /dev/null +++ b/rules/builtins/elementwise-math/cases/half-away.py @@ -0,0 +1,5 @@ +# round() rounds halves away from zero. +import numpy as np + +x = np.array([2.5, -2.5, 0.4]) +r = np.sign(x) * np.floor(np.abs(x) + 0.5) # np.round(x) would give 2, -2, 0 diff --git a/rules/builtins/elementwise-math/rule.yaml b/rules/builtins/elementwise-math/rule.yaml new file mode 100644 index 0000000..82cc6e1 --- /dev/null +++ b/rules/builtins/elementwise-math/rule.yaml @@ -0,0 +1,98 @@ +id: builtins/elementwise-math +title: "Element-wise math: `abs`, `sqrt`, `exp`, `floor`, `mod`, `rem`, `isnan`, ..." +status: mechanical +dialects: [octave, matlab] +match: + - call:abs + - call:sqrt + - call:exp + - call:log + - call:log2 + - call:log10 + - call:sin + - call:cos + - call:tan + - call:asin + - call:acos + - call:atan + - call:atan2 + - call:sinh + - call:cosh + - call:tanh + - call:hypot + - call:floor + - call:ceil + - call:fix + - call:round + - call:sign + - call:mod + - call:rem + - call:isnan + - call:isinf + - call:isfinite +from_python: # the Python -> .m direction + status: mechanical + match: + - py:call:np.abs + - py:call:np.sqrt + - py:call:np.exp + - py:call:np.log + - py:call:np.log2 + - py:call:np.log10 + - py:call:np.sin + - py:call:np.cos + - py:call:np.tan + - py:call:np.arcsin + - py:call:np.arccos + - py:call:np.arctan + - py:call:np.arctan2 + - py:call:np.sinh + - py:call:np.cosh + - py:call:np.tanh + - py:call:np.floor + - py:call:np.ceil + - py:call:np.trunc + - py:call:np.sign + - py:call:np.isnan + - py:call:np.isinf + - py:call:np.isfinite + - py:call:np.mod + - py:call:np.fmod + - py:call:np.hypot + - py:call:np.round + - py:call:abs + - py:op:mod +octave: | + a = abs(x); + f = fix(x); % toward zero + m = mod(-7, 3); % 2 + k = rem(-7, 3); % -1 +python: | + a = np.abs(x) + f = np.trunc(x) + m = np.mod(-7, 3) + k = np.fmod(-7, 3) +why: > + These apply to every element and keep the shape, like their `np.` namesakes. + Most map one to one (`exp` -> `np.exp`, `isnan` -> `np.isnan`); the + differences are in the names and the edge cases: `fix` is `np.trunc`, `mod` + takes the sign of the divisor (`np.mod`, Python's `%`), `rem` the sign of the + dividend (`np.fmod`). On a plain scalar, Python's built-in `abs` is enough. +pitfalls: + - >- + `mod(x, 0)` and `rem(x, 0)` return `x`; `np.mod(x, 0)` is 0 (integers) or + NaN (floats). A zero divisor is not translated; an unknown one is assumed + nonzero, out loud. + - >- + `round` rounds halves away from zero (`round(2.5)` is 3); `np.round` and + Python's `round` round halves to even (2). Use + `np.sign(x) * np.floor(np.abs(x) + 0.5)`. + - >- + `sqrt`, `log` and `asin` of out-of-domain values return complex numbers in + `.m` code but NaN (with a warning) in NumPy; use `np.emath.sqrt` / + `np.emath.log` when negative inputs are possible. + - >- + `atan2(y, x)` keeps its argument order in `np.arctan2(y, x)`; the inverse + trigonometric names gain an `arc` prefix (`asin` -> `np.arcsin`). +related: [builtins/sum-mean-max, builtins/constants] +python_imports: [import numpy as np] diff --git a/rules/builtins/elementwise-math/translate.py b/rules/builtins/elementwise-math/translate.py new file mode 100644 index 0000000..a9f5147 --- /dev/null +++ b/rules/builtins/elementwise-math/translate.py @@ -0,0 +1,119 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for builtins/elementwise-math. + +Most names map to their NumPy function; the renamed ones are listed in +:data:`_NUMPY`. ``abs`` of a known scalar is Python's ``abs``. ``round`` rounds +halves away from zero, written out from ``np.sign`` and ``np.floor``. +``sqrt``/``log`` of a value not known to be non-negative is assumed to be in +the real domain (docs/design.md section 5.2): NumPy returns NaN where the +source returns a complex number, and verification catches that. ``mod(x, 0)`` +and ``rem(x, 0)`` are ``x`` in the source but 0 or NaN in NumPy, so a zero +divisor is declined and an unknown one assumed nonzero, out loud. +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.lift import LiftContext + +_NUMPY = { + "asin": "arcsin", + "acos": "arccos", + "atan": "arctan", + "atan2": "arctan2", + "fix": "trunc", + "rem": "fmod", +} +_DOMAIN = frozenset({"sqrt", "log", "log2", "log10", "asin", "acos"}) +_SAME = frozenset( + {"abs", "sqrt", "exp", "log", "log2", "log10", "sin", "cos", "tan", "sinh", "cosh", + "tanh", "hypot", "floor", "ceil", "sign", "isnan", "isinf", "isfinite", "mod"} +) # fmt: skip + + +def translate(node: ir.Call, ctx: Context) -> ast.expr: + """One element-wise function call.""" + name = node.func + if not node.args: + ctx.decline(f"{name} without arguments") + first = ctx.info(node.args[0]) + if name == "round": + if len(node.args) != 1 or not isinstance(node.args[0], ir.Name): + ctx.decline("round of an expression (half away from zero repeats it)") + x = ctx.expr(node.args[0]) + floor = ctx.call( + ctx.np("floor"), + ast.BinOp(left=ctx.call(ctx.np("abs"), x), op=ast.Add(), right=ast.Constant(0.5)), + ) + return ast.BinOp(left=ctx.call(ctx.np("sign"), x), op=ast.Mult(), right=floor) + if name == "abs" and first.is_scalar and len(node.args) == 1: + return ctx.call(ast.Name("abs"), ctx.expr(node.args[0])) + if name not in _SAME and name not in _NUMPY: + ctx.decline(f"function {name}") + if name in ("mod", "rem") and len(node.args) == 2: + divisor = ctx.info(node.args[1]).value + if divisor == 0: + # mod(x, 0) and rem(x, 0) are x in the source; NumPy gives 0 or NaN. + ctx.decline(f"{name} by zero") + if divisor is None: + ctx.assume(f"nonzero divisor in {name}") + if name in _DOMAIN and not first.nonneg: + ctx.assume(f"{name} argument in the real domain") + args = [ctx.arg(arg) for arg in node.args] + return ctx.call(ctx.np(_NUMPY.get(name, name)), *args) + + +# --- Python -> .m ------------------------------------------------------------ +# +# The same functions under their .m names (np.arcsin is asin, np.trunc fix, +# np.fmod rem, Python's % mod). np.round rounds halves to even and the .m +# round away from zero, so it is only translated for integer data. sqrt/log +# of a negative number is NaN in NumPy but complex on the .m side: assumed +# out loud unless the argument is known to be non-negative. + +_TO_M = { + "abs": "abs", "sqrt": "sqrt", "exp": "exp", "log": "log", "log2": "log2", + "log10": "log10", "sin": "sin", "cos": "cos", "tan": "tan", "arcsin": "asin", + "arccos": "acos", "arctan": "atan", "arctan2": "atan2", "sinh": "sinh", + "cosh": "cosh", "tanh": "tanh", "floor": "floor", "ceil": "ceil", "trunc": "fix", + "sign": "sign", "isnan": "isnan", "isinf": "isinf", "isfinite": "isfinite", + "mod": "mod", "fmod": "rem", "hypot": "hypot", "round": "round", +} # fmt: skip +_REAL_DOMAIN = frozenset({"sqrt", "log", "log2", "log10", "arcsin", "arccos"}) + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``np.(x)``, ``abs(x)`` or ``a % b``.""" + loc = ctx.loc(node) + literals = ctx.module_for("syntax/array-literals") + if isinstance(node, ast.BinOp): # a % b + divisor = ctx.info(node.right).value + if divisor == 0: + ctx.decline("% by zero") + if divisor is None: + ctx.assume("nonzero divisor in %") + return ctx.call("mod", ctx.expr(node.left), ctx.expr(node.right), loc=loc) + assert isinstance(node, ast.Call) + tag = ctx.tag(node) or "" + name = tag.split(":")[-1].removeprefix("np.") + if node.keywords or name not in _TO_M: + ctx.decline(f"{tag} with these arguments") + if not node.args: + ctx.decline(f"{name} without arguments") + first = ctx.info(node.args[0]) + if name == "round" and (len(node.args) != 1 or first.dtype.value not in ("int", "bool")): + ctx.decline( + "np.round of fractions (NumPy rounds halves to even, the .m round away from zero)" + ) + if name in ("mod", "fmod") and len(node.args) == 2: + divisor = ctx.info(node.args[1]).value + if divisor == 0: + ctx.decline(f"{name} by zero (the .m side returns the dividend)") + if divisor is None: + ctx.assume(f"nonzero divisor in {name}") + if name in _REAL_DOMAIN and not first.nonneg: + ctx.assume(f"{name} argument in the real domain") + return ctx.call(_TO_M[name], *(literals.lift_items(a, ctx) for a in node.args), loc=loc) diff --git a/rules/builtins/find/cases/basic.m b/rules/builtins/find/cases/basic.m new file mode 100644 index 0000000..b642059 --- /dev/null +++ b/rules/builtins/find/cases/basic.m @@ -0,0 +1,9 @@ +x = [3 0 7 1 9]; +idx = find(x > 2); +first = find(x > 2, 1); +none = find(x > 100); +vals = x(find(x > 2)); +A = [0 2; 3 0; 0 4]; +lin = find(A); % column-major: 2, 4, 6 +[r, c] = find(A); +% dualect: index idx first none lin r c diff --git a/rules/builtins/find/cases/basic.py b/rules/builtins/find/cases/basic.py new file mode 100644 index 0000000..f063a8b --- /dev/null +++ b/rules/builtins/find/cases/basic.py @@ -0,0 +1,10 @@ +import numpy as np + +x = np.array([3, 0, 7, 1, 9]) +idx = np.flatnonzero(x > 2) +first = np.flatnonzero(x > 2)[:1] +none = np.flatnonzero(x > 100) +vals = x[x > 2] # no find needed to index with a mask +A = np.array([[0, 2], [3, 0], [0, 4]]) +lin = np.flatnonzero(A.ravel(order="F")) # column-major, like find +c, r = np.nonzero(A.T) diff --git a/rules/builtins/find/rule.yaml b/rules/builtins/find/rule.yaml new file mode 100644 index 0000000..1a4ec6f --- /dev/null +++ b/rules/builtins/find/rule.yaml @@ -0,0 +1,36 @@ +id: builtins/find +title: "`find`: 1-based, column-major indices" +status: mechanical +dialects: [octave, matlab] +match: [call:find] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:call:np.flatnonzero + - py:call:np.nonzero +octave: | + idx = find(x > 2); % 1-based + first = find(x > 2, 1); + [r, c] = find(A); +python: | + idx = np.flatnonzero(x > 2) # 0-based + first = np.flatnonzero(x > 2)[:1] + c, r = np.nonzero(A.T) # column-major order +why: > + `find` returns 1-based linear indices in column-major order; + `np.flatnonzero` returns 0-based indices in row-major order. For vectors only + the base differs. For a matrix, `np.flatnonzero(A.ravel(order="F"))` gives + the same order, and `[r, c] = find(A)`, which lists nonzeros column by + column, is `np.nonzero(A.T)` with its two outputs swapped. +pitfalls: + - >- + When the indices are only used to index again, `x(find(m))`, drop `find` + and use the mask: `x[m]`. + - >- + `find(x, k)` returns at most k indices: `np.flatnonzero(x)[:k]`, which is an + array, possibly empty, not a scalar. + - >- + No match gives an empty array (`zeros(1, 0)`); test with `.size == 0`, not + `is None`. +related: [indexing/logical, indexing/one-based, builtins/sum-mean-max] +python_imports: [import numpy as np] diff --git a/rules/builtins/find/translate.py b/rules/builtins/find/translate.py new file mode 100644 index 0000000..dbfc58b --- /dev/null +++ b/rules/builtins/find/translate.py @@ -0,0 +1,162 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for builtins/find: positions of nonzero elements. + +``find`` returns 1-based positions in column-major order. A variable that only +holds positions is stored 0-based by the emitter (see +:func:`dualect.emit.index_variables`); then ``find(x)`` is +``np.flatnonzero(x)``, and ``find(x, k)`` keeps the first ``k``. Elsewhere the +1-based value is ``np.flatnonzero(x) + 1``. A matrix is read column by column, +``ravel(order="F")``, and ``[r, c] = find(A)`` is ``c, r = np.nonzero(A.T)``. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.lift import LiftContext + + +def position_outputs(call: ir.Call, nargout: int) -> set[int]: + """Every output of ``find`` (up to two) is a position.""" + return set(range(min(nargout, 2))) + + +def _flat(node: ir.Expr, ctx: Context) -> ast.expr: + info = ctx.info(node) + expr = ctx.arg(node) + if info.is_matrix: + return ctx.method(expr, "ravel", order=ast.Constant("F")) + if not (info.is_vector or info.is_scalar): + ctx.decline("find on a value whose shape is unknown") + return expr + + +def translate_positions(call: ir.Call, ctx: Context) -> ast.expr: + """``find(x)`` / ``find(x, k)`` as 0-based positions.""" + if len(call.args) not in (1, 2): + ctx.decline("find with these arguments") + result = ctx.call(ctx.np("flatnonzero"), _flat(call.args[0], ctx)) + if len(call.args) == 2: + result = ast.Subscript(value=result, slice=ast.Slice(upper=ctx.expr(call.args[1]))) + return result + + +def translate(node: ir.Call, ctx: Context) -> ast.expr: + """``find`` where its 1-based values are needed.""" + return ast.BinOp(left=translate_positions(node, ctx), op=ast.Add(), right=ast.Constant(1)) + + +def translate_multi(stmt: ir.Assign, ctx: Context) -> list[Line]: + """``[r, c] = find(A)``: row and column positions in column-major order.""" + call = stmt.value + assert isinstance(call, ir.Call) + names = [t.id if isinstance(t, ir.Name) else "_" for t in stmt.targets] + if len(names) != 2 or len(call.args) != 1: + ctx.decline("find with these outputs") + if not all(ctx.is_index_var(n) or n == "_" for n in names): + ctx.decline("find positions used as values") + if not ctx.info(call.args[0]).is_matrix: + ctx.decline("[r, c] = find(x) of a vector") + lines: list[Line] = [] + for n in names: + if n != "_": + lines.extend(ctx.index_directive(n)) + transposed = ast.Attribute(value=ctx.expr(call.args[0]), attr="T") + rows, cols = names + lines.append( + ctx.line(f"{cols}, {rows} = {ast.unparse(ctx.call(ctx.np('nonzero'), transposed))}") + ) + return lines + + +# --- Python -> .m ------------------------------------------------------------ +# +# np.flatnonzero(x) of a 1-D array is find(x) - 1: the same positions, kept +# 0-based so the value equals the Python one. Of a 2-D array NumPy walks the +# rows, so it is find(A.').' - 1 (row order, as a row); np.flatnonzero(x)[:k] +# is find(x, k) - 1. r, c = np.nonzero(M) is [c, r] = find(M.') (find walks +# columns, NumPy rows), then each made a 0-based row. + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``np.flatnonzero``.""" + assert isinstance(node, ast.Call) + loc = ctx.loc(node) + if ctx.tag(node) != "py:call:np.flatnonzero" or len(node.args) != 1 or node.keywords: + ctx.decline("np.nonzero (a tuple of position arrays)") + arg = node.args[0] + info = ctx.info(arg) + value = ctx.module_for("syntax/array-literals").lift_items(arg, ctx) + if info.is_vector or isinstance(arg, ast.List): + found: ir.Expr = ctx.call("find", value, loc=loc) + elif info.is_matrix: + found = ctx.transpose(ctx.call("find", ctx.transpose(value), loc=loc)) + else: + ctx.decline("np.flatnonzero of a value whose dimensions are unknown") + return ctx.binop("minus", found, ctx.num(1), loc=loc) + + +def lift_subscript(node: ast.Subscript, ctx: LiftContext) -> ir.Expr: + """``np.flatnonzero(x)[:k]``: the first ``k`` positions, ``find(x, k) - 1``.""" + call = node.value + part = node.slice + if not ( + isinstance(call, ast.Call) + and ctx.tag(call) == "py:call:np.flatnonzero" + and len(call.args) == 1 + and isinstance(part, ast.Slice) + and part.lower is None + and part.step is None + and part.upper is not None + and ctx.info(call.args[0]).is_vector + ): + ctx.decline("indexing the result of np.flatnonzero") + if not ctx.info(part.upper).nonneg: + ctx.decline("a count that may be negative") + loc = ctx.loc(node) + value = ctx.expr(call.args[0]) + found = ctx.call("find", value, ctx.expr(part.upper), loc=loc) + return ctx.binop("minus", found, ctx.num(1), loc=loc) + + +def lift_multi(stmt: ast.Assign, ctx: LiftContext) -> list[ir.Stmt]: + """``r, c = np.nonzero(M)``: row and column positions, 0-based, as rows. + + NumPy walks ``M`` in row order. ``find`` walks columns, so it is applied to + ``M.'`` (or to ``X`` itself for ``M = X.T``), whose columns are ``M``'s + rows; its first output then holds ``M``'s columns and its second ``M``'s rows. + """ + target = stmt.targets[0] + call = stmt.value + assert isinstance(target, ast.Tuple | ast.List) and isinstance(call, ast.Call) + if len(call.args) != 1 or call.keywords or len(target.elts) != 2: + ctx.decline("np.nonzero with these arguments or outputs") + names = [e.id if isinstance(e, ast.Name) else None for e in target.elts] + if None in names: + ctx.decline("unpacking into an element") + rows, cols = (n for n in names if n is not None) + if rows == cols: + ctx.decline("the same name for both outputs") + matrix = call.args[0] + loc = ctx.loc(stmt) + if ( + isinstance(matrix, ast.Attribute) + and matrix.attr == "T" + and ctx.info(matrix.value).is_matrix + ): + walked = ctx.expr(matrix.value) + elif ctx.info(matrix).is_matrix: + walked = ctx.transpose(ctx.expr(matrix)) + else: + ctx.decline("np.nonzero of a value that is not 2-D") + outputs: list[ir.Expr] = [ir.Name(loc=loc, id=cols), ir.Name(loc=loc, id=rows)] + lifted: list[ir.Stmt] = [ + ir.Assign(loc=loc, targets=outputs, value=ctx.call("find", walked, loc=loc)) + ] + for name in (rows, cols): + variable = ir.Name(loc=loc, id=name) + shifted = ctx.binop("minus", ctx.transpose(variable), ctx.num(1)) + lifted.append(ir.Assign(loc=loc, targets=[ir.Name(loc=loc, id=name)], value=shifted)) + return lifted diff --git a/rules/builtins/isempty/cases/basic.m b/rules/builtins/isempty/cases/basic.m new file mode 100644 index 0000000..704b1b5 --- /dev/null +++ b/rules/builtins/isempty/cases/basic.m @@ -0,0 +1,8 @@ +a = []; +b = zeros(0, 3); +c = 5; +s = ''; +ea = isempty(a); +eb = isempty(b); +ec = isempty(c); +es = isempty(s); diff --git a/rules/builtins/isempty/cases/basic.py b/rules/builtins/isempty/cases/basic.py new file mode 100644 index 0000000..0daca59 --- /dev/null +++ b/rules/builtins/isempty/cases/basic.py @@ -0,0 +1,10 @@ +import numpy as np + +a = np.array([]) +b = np.zeros((0, 3)) +c = 5 +s = "" +ea = a.size == 0 +eb = b.size == 0 +ec = np.size(c) == 0 +es = len(s) == 0 diff --git a/rules/builtins/isempty/rule.yaml b/rules/builtins/isempty/rule.yaml new file mode 100644 index 0000000..17e76d9 --- /dev/null +++ b/rules/builtins/isempty/rule.yaml @@ -0,0 +1,21 @@ +id: builtins/isempty +title: "`isempty`" +status: mechanical +dialects: [octave, matlab] +match: [call:isempty] +octave: | + if isempty(x), ... end +python: | + if x.size == 0: ... +why: > + `isempty` is true when any dimension is zero (`[]`, `zeros(0, 3)`, `''`). + For a NumPy array that is `x.size == 0`; for a Python string `len(s) == 0`. + A Python number has no `.size`; `np.size(x) == 0` works for numbers and arrays. +pitfalls: + - >- + Truthiness is not emptiness: `if not x:` raises for a multi-element array + and is True for the number 0. + - >- + `np.size("")` is 1 (a 0-d array of one string), so do not use it on strings. +related: [builtins/size-numel-length, control-flow/if-elseif] +python_imports: [import numpy as np] diff --git a/rules/builtins/isempty/translate.py b/rules/builtins/isempty/translate.py new file mode 100644 index 0000000..9c90df4 --- /dev/null +++ b/rules/builtins/isempty/translate.py @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for builtins/isempty: ``x.size == 0``, ``len(s) == 0`` for strings.""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.infer import Kind + + +def translate(node: ir.Call, ctx: Context) -> ast.expr: + """``isempty(x)``.""" + if len(node.args) != 1: + ctx.decline("isempty with this many arguments") + info = ctx.info(node.args[0]) + expr = ctx.expr(node.args[0]) + if info.kind is Kind.STRING: + size = ctx.call(ast.Name("len"), expr) + elif info.is_array: + size = ast.Attribute(value=expr, attr="size") + elif info.is_scalar: + size = ctx.call(ctx.np("size"), expr) + else: + ctx.decline("isempty of a value of unknown type") + return ast.Compare(left=size, ops=[ast.Eq()], comparators=[ast.Constant(0)]) diff --git a/rules/builtins/linspace/cases/basic.m b/rules/builtins/linspace/cases/basic.m new file mode 100644 index 0000000..8cb3681 --- /dev/null +++ b/rules/builtins/linspace/cases/basic.m @@ -0,0 +1,4 @@ +x = linspace(0, 1, 5); +y = linspace(0, 1); % default: 100 points +n = numel(y); +step = y(2) - y(1); diff --git a/rules/builtins/linspace/cases/basic.py b/rules/builtins/linspace/cases/basic.py new file mode 100644 index 0000000..5ec8df8 --- /dev/null +++ b/rules/builtins/linspace/cases/basic.py @@ -0,0 +1,6 @@ +import numpy as np + +x = np.linspace(0, 1, 5) +y = np.linspace(0, 1, 100) # NumPy's default would be 50 +n = y.size +step = y[1] - y[0] diff --git a/rules/builtins/linspace/cases/edge-counts.m b/rules/builtins/linspace/cases/edge-counts.m new file mode 100644 index 0000000..cfd213f --- /dev/null +++ b/rules/builtins/linspace/cases/edge-counts.m @@ -0,0 +1,2 @@ +one = linspace(0, 1, 1); % the END point, not the start +none = linspace(0, 1, 0); diff --git a/rules/builtins/linspace/cases/edge-counts.py b/rules/builtins/linspace/cases/edge-counts.py new file mode 100644 index 0000000..0ab10a6 --- /dev/null +++ b/rules/builtins/linspace/cases/edge-counts.py @@ -0,0 +1,4 @@ +import numpy as np + +one = np.array([1.0]) # np.linspace(0, 1, 1) would give the start point, 0 +none = np.linspace(0, 1, 0) diff --git a/rules/builtins/linspace/rule.yaml b/rules/builtins/linspace/rule.yaml new file mode 100644 index 0000000..c600035 --- /dev/null +++ b/rules/builtins/linspace/rule.yaml @@ -0,0 +1,30 @@ +id: builtins/linspace +title: "`linspace` default count and edge cases" +status: mechanical +dialects: [octave, matlab] +match: [call:linspace] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:call:np.linspace +octave: | + x = linspace(0, 1, 5); + y = linspace(0, 1); % 100 points +python: | + x = np.linspace(0, 1, 5) + y = np.linspace(0, 1, 100) +why: > + Both include both end points. The default count differs: 100 in Octave and + MATLAB, 50 in NumPy, so always pass the count explicitly. The result is a + 1xN row in Octave and a 1-D array in NumPy. +pitfalls: + - >- + `linspace(a, b, 1)` returns `b` in Octave and MATLAB but `a` in NumPy; + translate it as `np.array([b])`. + - >- + `linspace(a, b, 0)` is empty in both. + - >- + For colon ranges with a fractional step, prefer `np.linspace` with a + computed count; see indexing/ranges. +related: [indexing/ranges] +python_imports: [import numpy as np] diff --git a/rules/builtins/linspace/translate.py b/rules/builtins/linspace/translate.py new file mode 100644 index 0000000..f98ef69 --- /dev/null +++ b/rules/builtins/linspace/translate.py @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for builtins/linspace. + +The count is always written out (the default is 100 here, 50 in NumPy), and a +count of 1 gives the *end* point, which NumPy does not. +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.lift import LiftContext + + +def translate(node: ir.Call, ctx: Context) -> ast.expr: + """``linspace(a, b)`` or ``linspace(a, b, n)``.""" + if len(node.args) not in (2, 3): + ctx.decline("linspace with this many arguments") + start, stop = (ctx.expr(a) for a in node.args[:2]) + if len(node.args) == 2: + return ctx.call(ctx.np("linspace"), start, stop, ast.Constant(100)) + count = ctx.info(node.args[2]).value + if count == 1: + end = ctx.info(node.args[1]).value + if isinstance(end, int | float): + return ctx.call(ctx.np("array"), ast.List(elts=[ctx.const(float(end))])) + return ctx.call(ctx.np("array"), ast.List(elts=[stop]), dtype=ast.Name("float")) + if count is None: + ctx.assume("a point count other than 1") + return ctx.call(ctx.np("linspace"), start, stop, ctx.expr(node.args[2])) + + +# --- Python -> .m ------------------------------------------------------------ +# +# np.linspace(a, b, n) is linspace(a, b, n). NumPy's default count is 50 (the +# .m default is 100), so it is always written out; a count of 1 gives the +# start in NumPy and the end on the .m side, so it is declined. + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``np.linspace``.""" + assert isinstance(node, ast.Call) + loc = ctx.loc(node) + args = list(node.args) + for keyword in node.keywords: + if keyword.arg == "num" and len(args) == 2: + args.append(keyword.value) + else: + ctx.decline(f"np.linspace with {keyword.arg}=") + if len(args) == 2: + count: ir.Expr = ctx.num(50) + value: object = 50 + elif len(args) == 3: + count = ctx.expr(args[2]) + value = ctx.info(args[2]).value + else: + ctx.decline("np.linspace with these arguments") + if value == 1: + ctx.decline("a count of 1 (NumPy gives the start point, the .m side the end point)") + if value is None: + ctx.assume("a point count other than 1") + return ctx.call("linspace", ctx.expr(args[0]), ctx.expr(args[1]), count, loc=loc) diff --git a/rules/builtins/size-numel-length/cases/basic.m b/rules/builtins/size-numel-length/cases/basic.m new file mode 100644 index 0000000..52f3370 --- /dev/null +++ b/rules/builtins/size-numel-length/cases/basic.m @@ -0,0 +1,12 @@ +A = [1 2 3 4 5; 6 7 8 9 10]; +[r, c] = size(A); +rows = size(A, 1); +cols = size(A, 2); +n = numel(A); +L = length(A); % 5: the largest dimension, not the row count +sz = size(A); +v = [4 5 6]; +nv = numel(v); +e = []; +Le = length(e); +ne = numel(e); diff --git a/rules/builtins/size-numel-length/cases/basic.py b/rules/builtins/size-numel-length/cases/basic.py new file mode 100644 index 0000000..7552c47 --- /dev/null +++ b/rules/builtins/size-numel-length/cases/basic.py @@ -0,0 +1,14 @@ +import numpy as np + +A = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) +r, c = A.shape +rows = A.shape[0] +cols = A.shape[1] +n = A.size +L = max(A.shape) # len(A) would be 2 +sz = A.shape +v = np.array([4, 5, 6]) +nv = v.size +e = np.array([]) +Le = max(e.shape) +ne = e.size diff --git a/rules/builtins/size-numel-length/rule.yaml b/rules/builtins/size-numel-length/rule.yaml new file mode 100644 index 0000000..a878df2 --- /dev/null +++ b/rules/builtins/size-numel-length/rule.yaml @@ -0,0 +1,40 @@ +id: builtins/size-numel-length +title: "`size`, `numel`, `length`" +status: mechanical +dialects: [octave, matlab] +match: [call:size, call:numel, call:length] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:attr:size + - py:attr:shape + - py:call:len + - py:call:np.size +octave: | + [r, c] = size(A); + r = size(A, 1); + n = numel(A); + L = length(A); % largest dimension +python: | + r, c = A.shape + r = A.shape[0] + n = A.size + L = max(A.shape) +why: > + `size` is `A.shape` and `size(A, d)` is `A.shape[d - 1]`; `numel` is + `A.size`. `length` is the *largest* dimension (0 for empty), not the number + of rows: Python's `len(A)` is the number of rows, which differs for wide + matrices. +pitfalls: + - >- + `length` of a 2x5 matrix is 5, while `len(A)` is 2. + - >- + Octave arrays are at least 2-D: for a row vector `size(v)` is `[1 n]` and + `size(v, 1)` is 1, but a 1-D NumPy array has shape `(n,)` and + `v.shape[0]` is n. Translate vector sizes as `v.size`. + - >- + `size(A, 3)` is 1 for a matrix, but `A.shape[2]` raises IndexError. + - >- + `numel(A)` is `A.size` (an attribute), not `A.size()`. +related: [builtins/zeros-ones-eye] +python_imports: [import numpy as np] diff --git a/rules/builtins/size-numel-length/translate.py b/rules/builtins/size-numel-length/translate.py new file mode 100644 index 0000000..bcaafc0 --- /dev/null +++ b/rules/builtins/size-numel-length/translate.py @@ -0,0 +1,178 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for builtins/size-numel-length. + +``numel`` is ``x.size`` (``len`` for a string); ``size(A)`` and ``size(A, d)`` +read ``A.shape`` for a matrix. A vector is 1-D in NumPy, so its sizes are +spelled out from its known orientation (``size(v, 1)`` of a row is 1). +``length`` is the largest dimension. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.infer import Info, Kind +from dualect.lift import LiftContext + + +def _count(expr: ast.expr, info: Info, ctx: Context) -> ast.expr: + if info.kind is Kind.STRING: + return ctx.call(ast.Name("len"), expr) + if info.is_array: + return ast.Attribute(value=expr, attr="size") + if info.is_scalar: + return ast.Constant(1) + ctx.assume(f"{ast.unparse(expr)} is numeric") + return ctx.call(ctx.np("size"), expr) + + +def _dims(info: Info, expr: ast.expr, ctx: Context) -> list[ast.expr]: + """Rows and columns of a value, as source sizes.""" + if info.is_matrix or info.kind is Kind.EMPTY: + shape = ast.Attribute(value=expr, attr="shape") + if info.kind is Kind.EMPTY: + return [ast.Constant(0), ast.Constant(0)] + return [ast.Subscript(value=shape, slice=ast.Constant(k)) for k in (0, 1)] + if info.kind is Kind.ROW or info.kind is Kind.STRING: + return [ast.Constant(1), _count(expr, info, ctx)] + if info.kind is Kind.COL: + return [_count(expr, info, ctx), ast.Constant(1)] + if info.is_scalar: + return [ast.Constant(1), ast.Constant(1)] + ctx.decline("size of a value whose shape is unknown") + + +def translate(node: ir.Call, ctx: Context) -> ast.expr: + """``size``, ``numel`` or ``length``.""" + if not node.args: + ctx.decline(f"{node.func} without arguments") + info = ctx.info(node.args[0]) + expr = ctx.expr(node.args[0]) + if node.func == "numel" and len(node.args) == 1: + return _count(expr, info, ctx) + if node.func == "length" and len(node.args) == 1: + if info.is_matrix or info.kind is Kind.EMPTY: + return ctx.call(ast.Name("max"), ast.Attribute(value=expr, attr="shape")) + if info.is_vector or info.kind is Kind.STRING or info.is_scalar: + return _count(expr, info, ctx) + ctx.decline("length of a value whose shape is unknown") + if node.func == "size": + if len(node.args) == 1: + if info.is_matrix: + return ast.Attribute(value=expr, attr="shape") + return ast.Tuple(elts=_dims(info, expr, ctx)) + if len(node.args) == 2: + dim = ctx.info(node.args[1]).value + if not isinstance(dim, int | float) or not float(dim).is_integer() or dim < 1: + ctx.decline("size with a computed dimension") + if dim > 2: + return ast.Constant(1) + if info.is_matrix: + shape = ast.Attribute(value=expr, attr="shape") + return ast.Subscript(value=shape, slice=ast.Constant(int(dim) - 1)) + return _dims(info, expr, ctx)[int(dim) - 1] + ctx.decline(f"{node.func} with these arguments") + + +def translate_multi(stmt: ir.Assign, ctx: Context) -> list[Line]: + """``[r, c] = size(A)``.""" + call = stmt.value + assert isinstance(call, ir.Call) + if call.func != "size" or len(call.args) != 1 or len(stmt.targets) != 2: + ctx.decline(f"{call.func} with several outputs") + info = ctx.info(call.args[0]) + expr = ctx.expr(call.args[0]) + names = [t.id if isinstance(t, ir.Name) else "_" for t in stmt.targets] + if info.is_matrix: + rhs: ast.expr = ast.Attribute(value=expr, attr="shape") + else: + rhs = ast.Tuple(elts=_dims(info, expr, ctx)) + return [ctx.line(f"{', '.join(names)} = {ast.unparse(rhs)}")] + + +# --- Python -> .m ------------------------------------------------------------ +# +# x.size and np.size(x) are numel(x). A.shape of a 2-D array is size(A) and +# A.shape[k] is size(A, k + 1); a 1-D array is a row on the .m side, so its +# only dimension is numel(x). len() is the length of the first axis: +# size(A, 1) for a 2-D array, numel for a 1-D array or a string. + + +def lift_shape(node: ast.Attribute, ctx: LiftContext) -> ir.Expr: + """``A.shape`` as a value.""" + loc = ctx.loc(node) + info = ctx.info(node.value) + value = ctx.expr(node.value) + if info.is_matrix: + return ctx.call("size", value, loc=loc) + if info.is_vector: + return ctx.call("numel", value, loc=loc) + ctx.decline(".shape of a value whose dimensions are unknown") + + +def lift_shape_index(node: ast.Subscript, ctx: LiftContext) -> ir.Expr: + """``A.shape[k]`` with a literal ``k``.""" + shape = node.value + assert isinstance(shape, ast.Attribute) + loc = ctx.loc(node) + info = ctx.info(shape.value) + k = node.slice + axis = None + if isinstance(k, ast.Constant) and type(k.value) is int: + axis = k.value + elif ( + isinstance(k, ast.UnaryOp) + and isinstance(k.op, ast.USub) + and isinstance(k.operand, ast.Constant) + ): + axis = -k.operand.value if type(k.operand.value) is int else None + if axis is None: + ctx.decline("a computed axis of .shape") + value = ctx.expr(shape.value) + if info.is_vector and axis in (0, -1): + return ctx.call("numel", value, loc=loc) + if info.is_matrix and axis in (0, 1, -1, -2): + return ctx.call("size", value, ctx.num(axis % 2 + 1), loc=loc) + ctx.decline(".shape[k] of a value whose dimensions are unknown") + + +def lift_multi(stmt: ast.Assign, ctx: LiftContext) -> list[ir.Stmt]: + """``r, c = A.shape``.""" + target = stmt.targets[0] + value = stmt.value + assert isinstance(target, ast.Tuple | ast.List) and isinstance(value, ast.Attribute) + if not ctx.info(value.value).is_matrix or len(target.elts) != 2: + ctx.decline("unpacking the shape of a value that is not 2-D") + names: list[ir.Expr] = [] + for element in target.elts: + if not isinstance(element, ast.Name): + ctx.decline("unpacking into an element") + names.append(ir.Name(loc=ctx.loc(element), id=element.id)) + call = ctx.call("size", ctx.expr(value.value), loc=ctx.loc(value)) + return [ir.Assign(loc=ctx.loc(stmt), targets=names, value=call)] + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``x.size``, ``A.shape``, ``len(x)``, ``np.size(x)``.""" + loc = ctx.loc(node) + if isinstance(node, ast.Attribute): + if node.attr == "shape": + return lift_shape(node, ctx) + info = ctx.info(node.value) + if not (info.is_array or info.is_scalar): + ctx.assume(f"{ast.unparse(node.value)} is an array") + return ctx.call("numel", ctx.expr(node.value), loc=loc) + assert isinstance(node, ast.Call) + if len(node.args) != 1 or node.keywords: + ctx.decline("this size query") + arg = node.args[0] + info = ctx.info(arg) + if ctx.tag(node) == "py:call:np.size": + return ctx.call("numel", ctx.expr(arg), loc=loc) + if info.is_matrix: + return ctx.call("size", ctx.expr(arg), ctx.num(1), loc=loc) + if info.is_vector or info.kind.value == "string": + return ctx.call("numel", ctx.expr(arg), loc=loc) + ctx.decline("len() of a value that is not a known array or string") diff --git a/rules/builtins/sum-mean-max/cases/basic.m b/rules/builtins/sum-mean-max/cases/basic.m new file mode 100644 index 0000000..7acf78d --- /dev/null +++ b/rules/builtins/sum-mean-max/cases/basic.m @@ -0,0 +1,13 @@ +A = [1 2 3; 4 5 6]; +col_sums = sum(A); +row_sums = sum(A, 2); +total = sum(A(:)); +col_means = mean(A); +row_means = mean(A, 2); +v = [4 9 2 9]; +[mx, i] = max(v); % first occurrence of the maximum +[mn, j] = min(v); +col_max = max(A); +row_max = max(A, [], 2); +pairwise = max([1 5 3], [4 2 6]); +% dualect: index i j diff --git a/rules/builtins/sum-mean-max/cases/basic.py b/rules/builtins/sum-mean-max/cases/basic.py new file mode 100644 index 0000000..ee770ba --- /dev/null +++ b/rules/builtins/sum-mean-max/cases/basic.py @@ -0,0 +1,16 @@ +import numpy as np + +A = np.array([[1, 2, 3], [4, 5, 6]]) +col_sums = A.sum(axis=0) +row_sums = A.sum(axis=1) +total = A.sum() +col_means = A.mean(axis=0) +row_means = A.mean(axis=1) +v = np.array([4, 9, 2, 9]) +i = np.argmax(v) # first occurrence, 0-based +mx = v[i] +j = np.argmin(v) +mn = v[j] +col_max = A.max(axis=0) +row_max = A.max(axis=1) +pairwise = np.maximum([1, 5, 3], [4, 2, 6]) diff --git a/rules/builtins/sum-mean-max/cases/nan.m b/rules/builtins/sum-mean-max/cases/nan.m new file mode 100644 index 0000000..db80bb1 --- /dev/null +++ b/rules/builtins/sum-mean-max/cases/nan.m @@ -0,0 +1,6 @@ +w = [1 NaN 3]; +m = max(w); % NaN is skipped: 3 +[m2, k] = max(w); +s = sum(w); % NaN propagates +s_valid = sum(w(~isnan(w))); +% dualect: index k diff --git a/rules/builtins/sum-mean-max/cases/nan.py b/rules/builtins/sum-mean-max/cases/nan.py new file mode 100644 index 0000000..7f55200 --- /dev/null +++ b/rules/builtins/sum-mean-max/cases/nan.py @@ -0,0 +1,8 @@ +import numpy as np + +w = np.array([1, np.nan, 3]) +m = np.nanmax(w) # w.max() would be nan +k = np.nanargmax(w) +m2 = w[k] +s = w.sum() # NaN propagates +s_valid = w[~np.isnan(w)].sum() diff --git a/rules/builtins/sum-mean-max/rule.yaml b/rules/builtins/sum-mean-max/rule.yaml new file mode 100644 index 0000000..0e6aff1 --- /dev/null +++ b/rules/builtins/sum-mean-max/rule.yaml @@ -0,0 +1,70 @@ +id: builtins/sum-mean-max +title: "`sum`, `mean`, `max`, `min`: dimensions and index outputs" +status: mechanical +dialects: [octave, matlab] +match: [call:sum, call:mean, call:max, call:min, call:prod] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:method:sum + - py:method:mean + - py:method:max + - py:method:min + - py:method:prod + - py:method:all + - py:method:any + - py:method:argmax + - py:method:argmin + - py:call:np.sum + - py:call:np.mean + - py:call:np.max + - py:call:np.min + - py:call:np.prod + - py:call:np.nanmax + - py:call:np.nanmin + - py:call:np.argmax + - py:call:np.argmin + - py:call:np.nanargmax + - py:call:np.nanargmin + - py:call:np.maximum + - py:call:np.minimum + - py:call:np.fmax + - py:call:np.fmin + - py:call:np.clip + - py:call:np.count_nonzero + - py:call:np.all + - py:call:np.any + - py:call:max + - py:call:min +octave: | + s = sum(A); % down each column + m = mean(A, 2); % along each row + [mx, i] = max(v); % i is 1-based + t = sum(A(:)); +python: | + s = A.sum(axis=0) + m = A.mean(axis=1) + i = np.argmax(v) + mx = v[i] + t = A.sum() +why: > + On a matrix these reduce down the columns (dimension 1) by default, which is + `axis=0`; NumPy with no axis reduces *all* elements. Dimension `d` is + `axis=d - 1`. The second output of `max`/`min` is a 1-based position; + `np.argmax`/`np.argmin` return 0-based positions (both take the first + occurrence on ties). +pitfalls: + - >- + `prod` of a NumPy integer array wraps around on overflow + (`np.prod([10**5] * 4)` is negative); write `x.prod(dtype=float)`. + - >- + On a row vector `sum(v)` sums along the row (the first non-singleton + dimension); for a 1-D array `v.sum()` is right. + - >- + `max(A, [], 2)` is the row-wise maximum `A.max(axis=1)`; `max(a, b)` with two + arrays is element-wise, `np.maximum(a, b)`. + - >- + `max` and `min` skip NaN (`max([1 NaN 3])` is 3), while NumPy's propagate + it: use `np.nanmax`/`np.nanargmax`. `sum` and `mean` propagate NaN in both. +related: [functions/multiple-returns, indexing/colon-all, builtins/find] +python_imports: [import numpy as np] diff --git a/rules/builtins/sum-mean-max/translate.py b/rules/builtins/sum-mean-max/translate.py new file mode 100644 index 0000000..5b59e03 --- /dev/null +++ b/rules/builtins/sum-mean-max/translate.py @@ -0,0 +1,315 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for builtins/sum-mean-max: ``sum``, ``mean``, ``prod``, ``max``, ``min``. + +A vector reduces to a scalar (``x.sum()``); a matrix reduces down its columns +(``axis=0``) unless a dimension is given (``d`` is ``axis=d - 1``). ``sum(A(:))`` +is ``A.sum()``. ``max``/``min`` skip NaN, so data not known to be NaN-free uses +``np.nanmax``/``np.nanmin``; the two-argument form is ``np.maximum`` (or +``np.fmax``, which also skips NaN), and ``min(max(x, lo), hi)`` is +``np.clip(x, lo, hi)``. The position output of ``[m, i] = max(v)`` is +``np.argmax``, 0-based when the emitter stores ``i`` 0-based. ``prod`` of +an integer array is taken in floating point (``dtype=float``): NumPy integers +wrap around on overflow where the source computes in doubles. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.infer import Info, Kind +from dualect.lift import LiftContext + +_NAN_SKIPPING = {"max": "nanmax", "min": "nanmin"} +_PAIRWISE = {"max": ("maximum", "fmax"), "min": ("minimum", "fmin")} + + +def position_outputs(call: ir.Call, nargout: int) -> set[int]: + """The second output of ``max``/``min`` of one argument is a position.""" + if call.func in ("max", "min") and len(call.args) == 1 and nargout >= 2: + return {1} + return set() + + +def _colon_all(node: ir.Expr) -> ir.Expr | None: + """``A`` when ``node`` is ``A(:)``.""" + if isinstance(node, ir.Index) and len(node.args) == 1 and isinstance(node.args[0], ir.Colon): + return node.target + return None + + +def _dim(node: ir.Call, position: int, ctx: Context) -> int | None: + if len(node.args) <= position: + return None + value = ctx.info(node.args[position]).value + if not isinstance(value, int | float) or not float(value).is_integer(): + ctx.decline(f"{node.func} along a computed dimension") + return int(value) + + +def _reduce(func: str, data: ir.Expr, info: Info, dim: int | None, ctx: Context) -> ast.expr: + """``func`` of ``data`` over ``dim`` (``None``: the default dimension).""" + expr = ctx.expr(data) + nan_name = _NAN_SKIPPING.get(func) if not info.finite else None + # A product of integers wraps around in NumPy; the source multiplies doubles. + keywords = {"dtype": ast.Name("float")} if func == "prod" and info.int_dtype else {} + if info.is_matrix: + axis = 0 if dim in (None, 1) else 1 if dim == 2 else None + if axis is None: + ctx.decline(f"{func} along dimension {dim}") + if nan_name: + return ctx.call(ctx.np(nan_name), expr, axis=ast.Constant(axis)) + return ctx.method(expr, func, axis=ast.Constant(axis), **keywords) + reduces = ( + dim is None or (dim == 2 and info.kind is Kind.ROW) or (dim == 1 and info.kind is Kind.COL) + ) + if info.is_vector and reduces: + if func == "sum" and info.is_logical: + return ctx.call(ctx.np("count_nonzero"), expr) + if nan_name: + return ctx.call(ctx.np(nan_name), expr) + return ctx.method(expr, func, **keywords) + ctx.decline(f"{func} of a value whose shape is unknown or along a singleton dimension") + + +def translate(node: ir.Call, ctx: Context) -> ast.expr: + """One reduction, or a two-argument ``max``/``min``.""" + func, args = node.func, node.args + if not args: + ctx.decline(f"{func} without arguments") + if func in _PAIRWISE and len(args) == 2: + return _pairwise(node, ctx) + if func in ("max", "min"): + if len(args) == 3 and not (isinstance(args[1], ir.Matrix) and not args[1].rows): + ctx.decline(f"{func} with a second argument and a dimension") + dim = _dim(node, 2, ctx) + else: + dim = _dim(node, 1, ctx) + data = args[0] + whole = _colon_all(data) + if whole is not None and dim is None: + info = ctx.info(whole) + if not (info.is_array or info.kind is Kind.UNKNOWN): + ctx.decline(f"{func}(x(:)) of a non-array") + nan_name = _NAN_SKIPPING.get(func) if not info.finite else None + if nan_name: + return ctx.call(ctx.np(nan_name), ctx.expr(whole)) + if func == "prod" and info.int_dtype: + return ctx.method(ctx.expr(whole), func, dtype=ast.Name("float")) + return ctx.method(ctx.expr(whole), func) + return _reduce(func, data, ctx.info(data), dim, ctx) + + +def _pairwise(node: ir.Call, ctx: Context) -> ast.expr: + a, b = node.args + finite = ctx.info(a).finite and ctx.info(b).finite + # min(max(x, lo), hi) clamps x: np.clip, when no NaN can change the meaning. + inner = a if node.func == "min" else None + if ( + isinstance(inner, ir.Call) + and inner.func == "max" + and len(inner.args) == 2 + and all(ctx.info(arg).finite for arg in [*inner.args, b]) + ): + x, lo = inner.args + return ctx.call(ctx.np("clip"), ctx.arg(x), ctx.arg(lo), ctx.arg(b)) + plain, nan_skipping = _PAIRWISE[node.func] + return ctx.call(ctx.np(plain if finite else nan_skipping), ctx.arg(a), ctx.arg(b)) + + +def translate_multi(stmt: ir.Assign, ctx: Context) -> list[Line]: + """``[m, i] = max(v)``: the value and its first position.""" + call = stmt.value + assert isinstance(call, ir.Call) + if call.func not in ("max", "min") or len(call.args) != 1 or len(stmt.targets) != 2: + ctx.decline(f"{call.func} with these outputs") + data = call.args[0] + info = ctx.info(data) + if not info.is_vector: + ctx.decline(f"[m, i] = {call.func}(x) of a matrix or unknown shape") + value_target, position_target = stmt.targets + expr = ctx.expr(data) + arg_func = ("nanarg" if not info.finite else "arg") + call.func + position = ctx.call(ctx.np(arg_func), expr) + lines: list[Line] = [] + position_name = position_target.id if isinstance(position_target, ir.Name) else None + stored_zero_based = position_name is not None and ctx.is_index_var(position_name) + if position_name is not None: + if stored_zero_based: + lines.extend(ctx.index_directive(position_name)) + lines.append(ctx.line(f"{position_name} = {ast.unparse(position)}")) + else: + lines.append(ctx.line(f"{position_name} = {ast.unparse(position)} + 1")) + if isinstance(value_target, ir.Name): + value: ast.expr + if stored_zero_based and position_name is not None: + value = ast.Subscript(value=expr, slice=ast.Name(position_name)) + else: + value = _reduce(call.func, data, info, None, ctx) + lines.append(ctx.line(f"{value_target.id} = {ast.unparse(value)}")) + elif not isinstance(value_target, ir.Ignore): + ctx.decline("assigning a reduction into an element") + if isinstance(position_target, ir.Index): + ctx.decline("assigning a position into an element") + return lines + + +# --- Python -> .m ------------------------------------------------------------ +# +# x.sum() of a 1-D array is sum(x); of a 2-D array (all elements) sum(A(:)). +# axis=0 reduces down the columns, sum(A, 1), a row; axis=1 is sum(A, 2), a +# column on the .m side and 1-D in NumPy, so it is turned into a row. The +# .m max/min skip NaN where NumPy's max propagates it, so .max() of data not +# known to be NaN-free is declined and np.nanmax is plain max. np.argmax has no +# expression form: i = np.argmax(v) becomes [~, i] = max(v); i = i - 1, kept +# 0-based so the value equals Python's. np.fmax (NaN-skipping) is max(a, b); +# np.maximum is too when no NaN can occur; np.clip(x, lo, hi) is +# min(max(x, lo), hi); np.count_nonzero is nnz. + +_SKIPS_NAN = {"nanmax": "max", "nanmin": "min", "fmax": "max", "fmin": "min"} +_ARG = {"argmax": "max", "argmin": "min", "nanargmax": "max", "nanargmin": "min"} + + +def _name(node: ast.Call, ctx: LiftContext) -> tuple[str, ast.expr | None, list[ast.expr]]: + """``(function, receiver or first argument, remaining arguments)`` of a call.""" + tag = ctx.tag(node) or "" + if tag.startswith("py:method:"): + assert isinstance(node.func, ast.Attribute) + return tag.removeprefix("py:method:"), node.func.value, list(node.args) + name = tag.split(":")[-1].removeprefix("np.") + if not node.args: + return name, None, [] + return name, node.args[0], list(node.args[1:]) + + +def _axis(node: ast.Call, rest: list[ast.expr], ctx: LiftContext) -> int | None: + axis_node = rest[0] if rest else None + for keyword in node.keywords: + if keyword.arg == "axis": + axis_node = keyword.value + else: + ctx.decline(f"{keyword.arg}= in a reduction") + if axis_node is None: + return None + value = ctx.info(axis_node).value + if value not in (0, 1, -1, -2) or isinstance(value, bool): + ctx.decline("a reduction along a computed axis") + assert isinstance(value, int) + return value % 2 + + +def reduce(func: str, data: ast.expr, axis: int | None, ctx: LiftContext, loc: ir.Loc) -> ir.Expr: + """``func`` of ``data`` (over ``axis``) as the ``.m`` reduction of the same values.""" + info = ctx.info(data) + value = ctx.module_for("syntax/array-literals").lift_items(data, ctx) + if info.is_vector or isinstance(data, ast.List): + if axis not in (None, 0): + ctx.decline("a reduction of a 1-D array along axis 1") + return ctx.call(func, value, loc=loc) + if not info.is_matrix: + ctx.decline(f"{func} of a value whose dimensions are unknown") + if axis is None: + return ctx.call(func, ir.Index(loc=loc, target=value, args=[ir.Colon(loc=loc)]), loc=loc) + if func in ("max", "min"): + result = ctx.call(func, value, ir.Matrix(loc=loc, rows=[]), ctx.num(axis + 1), loc=loc) + else: + result = ctx.call(func, value, ctx.num(axis + 1), loc=loc) + return result if axis == 0 else ctx.transpose(result) + + +def _finite(node: ast.expr, ctx: LiftContext) -> bool: + if isinstance(node, ast.List): + return all(_finite(e, ctx) for e in node.elts) + return ctx.info(node).finite + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """A reduction, a pairwise max/min, ``np.clip`` or ``np.count_nonzero``.""" + assert isinstance(node, ast.Call) + loc = ctx.loc(node) + literals = ctx.module_for("syntax/array-literals") + func, data, rest = _name(node, ctx) + tag = ctx.tag(node) or "" + if func in _ARG: + ctx.decline(f"np.{func} inside an expression (it needs its own statement)") + if tag in ("py:call:max", "py:call:min"): + return _builtin(node, func, ctx) + if data is None: + ctx.decline(f"{func} without arguments") + if func in ("maximum", "minimum", "fmax", "fmin"): + if len(rest) != 1 or node.keywords: + ctx.decline(f"np.{func} with these arguments") + if func in ("maximum", "minimum") and not (_finite(data, ctx) and _finite(rest[0], ctx)): + ctx.decline(f"np.{func} of data that may hold NaN (the .m {func[:3]} skips NaN)") + name = func[:3] if func in ("maximum", "minimum") else _SKIPS_NAN[func] + return ctx.call( + name, literals.lift_items(data, ctx), literals.lift_items(rest[0], ctx), loc=loc + ) + if func == "clip": + if len(rest) != 2 or node.keywords or not _finite(data, ctx): + ctx.decline("np.clip of data that may hold NaN, or with these arguments") + if any(isinstance(b, ast.Constant) and b.value is None for b in rest): + ctx.decline("np.clip with an open bound") + low = ctx.call("max", literals.lift_items(data, ctx), ctx.expr(rest[0]), loc=loc) + return ctx.call("min", low, ctx.expr(rest[1]), loc=loc) + if func == "count_nonzero": + if rest or node.keywords: + ctx.decline("np.count_nonzero along an axis") + return ctx.call("nnz", literals.lift_items(data, ctx), loc=loc) + axis = _axis(node, rest, ctx) + if func in ("max", "min") and not _finite(data, ctx): + ctx.decline( + f"{func} of data that may hold NaN (NumPy propagates it, the .m {func} skips it)" + ) + return reduce(_SKIPS_NAN.get(func, func), data, axis, ctx, loc) + + +def _builtin(node: ast.Call, func: str, ctx: LiftContext) -> ir.Expr: + """Python's own ``max``/``min``: of ``A.shape``, of a list, or of scalars.""" + loc = ctx.loc(node) + if node.keywords or not node.args: + ctx.decline(f"{func}() with these arguments") + if len(node.args) == 1: + arg = node.args[0] + if isinstance(arg, ast.Attribute) and arg.attr == "shape": + shape = ctx.module_for("builtins/size-numel-length").lift_shape(arg, ctx) + return ctx.call(func, shape, loc=loc) + if not _finite(arg, ctx): + ctx.decline(f"{func}() of data that may hold NaN") + return reduce(func, arg, None, ctx, loc) + if not all(ctx.info(a).is_scalar and ctx.info(a).finite for a in node.args): + ctx.decline(f"{func}() of values that are not finite scalars") + result = ctx.expr(node.args[0]) + for arg in node.args[1:]: + result = ctx.call(func, result, ctx.expr(arg), loc=loc) + return result + + +def lift_assign(stmt: ast.Assign, ctx: LiftContext) -> list[ir.Stmt] | None: + """``i = np.argmax(v)``: ``[~, i] = max(v); i = i - 1`` (0-based, as in Python).""" + value = stmt.value + target = stmt.targets[0] + assert isinstance(value, ast.Call) + func, data, rest = _name(value, ctx) + if func not in _ARG: + return None + if data is None or rest or value.keywords or not isinstance(target, ast.Name): + ctx.decline(f"{func} with these arguments") + info = ctx.info(data) + if not (info.is_vector or isinstance(data, ast.List)): + ctx.decline(f"{func} of a value that is not 1-D (NumPy flattens it in row order)") + if not func.startswith("nan") and not _finite(data, ctx): + ctx.decline(f"{func} of data that may hold NaN (NumPy stops at the first NaN)") + loc = ctx.loc(stmt) + name = ir.Name(loc=ctx.loc(target), id=target.id) + values = ctx.module_for("syntax/array-literals").lift_items(data, ctx) + found = ir.Assign( + loc=loc, targets=[ir.Ignore(loc=loc), name], value=ctx.call(_ARG[func], values, loc=loc) + ) + shifted = ir.Assign( + loc=loc, + targets=[ir.Name(loc=loc, id=target.id)], + value=ctx.binop("minus", ir.Name(loc=loc, id=target.id), ctx.num(1)), + ) + return [found, shifted] diff --git a/rules/builtins/zeros-ones-eye/cases/basic.m b/rules/builtins/zeros-ones-eye/cases/basic.m new file mode 100644 index 0000000..7fcbf74 --- /dev/null +++ b/rules/builtins/zeros-ones-eye/cases/basic.m @@ -0,0 +1,9 @@ +Z = zeros(3); % one argument: square +W = ones(2, 4); +Id = eye(3); +R = eye(2, 3); +z = zeros(1, 5); +c = ones(3, 1); +A = [1 2; 3 4]; +Zl = zeros(size(A)); +E = zeros(0, 3); diff --git a/rules/builtins/zeros-ones-eye/cases/basic.py b/rules/builtins/zeros-ones-eye/cases/basic.py new file mode 100644 index 0000000..f63e117 --- /dev/null +++ b/rules/builtins/zeros-ones-eye/cases/basic.py @@ -0,0 +1,11 @@ +import numpy as np + +Z = np.zeros((3, 3)) # np.zeros(3) would be 1-D +W = np.ones((2, 4)) +Id = np.eye(3) +R = np.eye(2, 3) +z = np.zeros(5) +c = np.ones(3) +A = np.array([[1, 2], [3, 4]]) +Zl = np.zeros(A.shape) +E = np.zeros((0, 3)) diff --git a/rules/builtins/zeros-ones-eye/rule.yaml b/rules/builtins/zeros-ones-eye/rule.yaml new file mode 100644 index 0000000..fde2f31 --- /dev/null +++ b/rules/builtins/zeros-ones-eye/rule.yaml @@ -0,0 +1,37 @@ +id: builtins/zeros-ones-eye +title: "`zeros`, `ones`, `eye`" +status: mechanical +dialects: [octave, matlab] +match: [call:zeros, call:ones, call:eye] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:call:np.zeros + - py:call:np.ones + - py:call:np.eye +octave: | + Z = zeros(3); % 3x3! + W = ones(2, 4); + Id = eye(3); + z = zeros(1, 5); +python: | + Z = np.zeros((3, 3)) + W = np.ones((2, 4)) + Id = np.eye(3) + z = np.zeros(5) +why: > + With a single argument `n`, `zeros(n)` and `ones(n)` make an n-by-n matrix, + while `np.zeros(n)` makes a 1-D array of length n. Pass the shape as a tuple. + `eye(n)` and `eye(m, n)` match `np.eye(n)` and `np.eye(m, n)`. A 1xN or Nx1 + result is idiomatically a 1-D array. +pitfalls: + - >- + `zeros(size(A))` is `np.zeros(A.shape)`; `np.zeros_like(A)` would copy an + integer dtype from `A`, while Octave's result is always double. + - >- + `zeros(0, 3)` is an empty array of shape `(0, 3)`; keep the tuple. + - >- + A class argument maps to `dtype`: `zeros(2, 'int32')` is + `np.zeros((2, 2), dtype=np.int32)`. +related: [indexing/grow-on-assign, builtins/size-numel-length] +python_imports: [import numpy as np] diff --git a/rules/builtins/zeros-ones-eye/translate.py b/rules/builtins/zeros-ones-eye/translate.py new file mode 100644 index 0000000..f8838ce --- /dev/null +++ b/rules/builtins/zeros-ones-eye/translate.py @@ -0,0 +1,94 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for builtins/zeros-ones-eye. + +``zeros(n)`` is square: ``np.zeros((n, n))``. A ``1xN`` or ``Nx1`` shape is a +1-D vector, ``np.zeros(n)``; ``zeros(size(A))`` is ``np.zeros(A.shape)``. +``eye`` keeps its arguments. Class arguments (``'int32'``) are declined. +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.lift import LiftContext + + +def _is_one(node: ir.Expr, ctx: Context) -> bool: + return ctx.info(node).value == 1 + + +def translate(node: ir.Call, ctx: Context) -> ast.expr: + """``zeros``, ``ones`` or ``eye``.""" + args = node.args + if any(isinstance(a, ir.Str) for a in args): + ctx.decline(f"{node.func} with a class argument") + func = ctx.np(node.func) + if node.func == "eye": + if len(args) == 2 and (_is_one(args[0], ctx) or _is_one(args[1], ctx)): + ctx.decline("eye with a dimension of 1") + if len(args) in (1, 2): + return ctx.call(func, *(ctx.expr(a) for a in args)) + ctx.decline("eye with this many arguments") + if len(args) == 1: + arg = args[0] + if isinstance(arg, ir.Call) and arg.func == "size" and len(arg.args) == 1: + source = ctx.info(arg.args[0]) + if not (source.is_array or source.is_scalar): + ctx.decline("zeros(size(x)) of an unknown x") + return ctx.call(func, ast.Attribute(value=ctx.expr(arg.args[0]), attr="shape")) + if not ctx.info(arg).is_scalar: + ctx.decline(f"{node.func} with a size vector") + n = ctx.expr(arg) + return ctx.call(func, ast.Tuple(elts=[n, n])) + if len(args) == 2: + rows, cols = args + if _is_one(rows, ctx): + return ctx.call(func, ctx.expr(cols)) + if _is_one(cols, ctx): + return ctx.call(func, ctx.expr(rows)) + if ctx.info(rows).value is None or ctx.info(cols).value is None: + ctx.assume("neither dimension is 1") + return ctx.call(func, ast.Tuple(elts=[ctx.expr(rows), ctx.expr(cols)])) + ctx.decline(f"{node.func} with this many arguments") + + +# --- Python -> .m ------------------------------------------------------------ +# +# np.zeros(n) is 1-D: a 1xN row, zeros(1, n) (zeros(n) would be n x n). +# np.zeros((m, n)) is zeros(m, n), np.zeros(A.shape) zeros(size(A)). +# np.eye keeps its arguments. A dtype is declined (bool and int arrays have +# no plain .m constructor here). + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``np.zeros``, ``np.ones`` or ``np.eye``.""" + assert isinstance(node, ast.Call) + loc = ctx.loc(node) + func = (ctx.tag(node) or "").removeprefix("py:call:np.") + if node.keywords: + ctx.decline(f"np.{func} with a dtype or other options") + args = node.args + if func == "eye": + if len(args) not in (1, 2): + ctx.decline("np.eye with these arguments") + return ctx.call("eye", *(ctx.expr(a) for a in args), loc=loc) + if len(args) != 1: + ctx.decline(f"np.{func} with these arguments") + shape = args[0] + info = ctx.info(shape) + if isinstance(shape, ast.Attribute) and shape.attr == "shape": + source = ctx.info(shape.value) + if not (source.is_matrix or source.is_vector): + ctx.decline(f"np.{func} of the shape of an unknown value") + return ctx.call(func, ctx.call("size", ctx.expr(shape.value), loc=loc), loc=loc) + if isinstance(shape, ast.Tuple): + if len(shape.elts) == 1: + return ctx.call(func, ctx.num(1), ctx.expr(shape.elts[0]), loc=loc) + if len(shape.elts) == 2: + return ctx.call(func, *(ctx.expr(e) for e in shape.elts), loc=loc) + ctx.decline(f"np.{func} with more than two dimensions") + if info.is_scalar: + return ctx.call(func, ctx.num(1), ctx.expr(shape), loc=loc) + ctx.decline(f"np.{func} with a shape of unknown form") diff --git a/rules/control-flow/for-columns/cases/basic.m b/rules/control-flow/for-columns/cases/basic.m new file mode 100644 index 0000000..a87ad31 --- /dev/null +++ b/rules/control-flow/for-columns/cases/basic.m @@ -0,0 +1,11 @@ +A = [1 2 3; 4 5 6]; +total = zeros(2, 1); +count = 0; +for c = A + total = total + c; + count = count + 1; +end +s = 0; +for k = 1:4 + s = s + k; +end diff --git a/rules/control-flow/for-columns/cases/basic.py b/rules/control-flow/for-columns/cases/basic.py new file mode 100644 index 0000000..44bb42a --- /dev/null +++ b/rules/control-flow/for-columns/cases/basic.py @@ -0,0 +1,11 @@ +import numpy as np + +A = np.array([[1, 2, 3], [4, 5, 6]]) +total = np.zeros(2) +count = 0 +for c in A.T: # the rows of A.T are the columns of A + total = total + c + count += 1 +s = 0 +for k in range(1, 5): + s += k diff --git a/rules/control-flow/for-columns/cases/column-vector.m b/rules/control-flow/for-columns/cases/column-vector.m new file mode 100644 index 0000000..3e370f6 --- /dev/null +++ b/rules/control-flow/for-columns/cases/column-vector.m @@ -0,0 +1,6 @@ +% A column vector is one column, so the loop body runs once. +v = [1; 2; 3]; +iterations = 0; +for x = v + iterations = iterations + 1; +end diff --git a/rules/control-flow/for-columns/cases/column-vector.py b/rules/control-flow/for-columns/cases/column-vector.py new file mode 100644 index 0000000..8ef984f --- /dev/null +++ b/rules/control-flow/for-columns/cases/column-vector.py @@ -0,0 +1,7 @@ +# A column vector is one column, so the loop body runs once. +import numpy as np + +v = np.array([1, 2, 3]) +iterations = 0 +for x in [v]: # not `for x in v`, which would run three times + iterations += 1 diff --git a/rules/control-flow/for-columns/rule.yaml b/rules/control-flow/for-columns/rule.yaml new file mode 100644 index 0000000..8918534 --- /dev/null +++ b/rules/control-flow/for-columns/rule.yaml @@ -0,0 +1,47 @@ +id: control-flow/for-columns +title: "`for` loops iterate over columns" +status: mechanical +dialects: [octave, matlab] +match: [stmt:for] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:for + - py:call:range +octave: | + for c = A % c is each column of A + total = total + c; + end + for k = 1:n + s = s + k; + end +python: | + for c in A.T: # rows of A.T are the columns of A + total = total + c + for k in range(1, n + 1): + s += k +why: > + `for v = M` assigns each *column* of `M` to `v` in turn: a row vector gives + scalars, a matrix gives column vectors. Python iterates over the first axis + (rows), so loop over `A.T` to get columns. A counting loop `for k = 1:n` is + `range(1, n + 1)` when `k` is a value, or `range(n)` when it is used only as + an index (then shift the indexing too). +pitfalls: + - >- + `for c in A.T` gives views of `A`: `c[0] = 0` in the body changes `A`, + while the source modified a copy of the column. Iterate `A.T.copy()` + when the body writes into the loop variable. + - >- + After `for k = 1:0` the source leaves `k` as an empty 1x0 array; Python + never binds `k`. + - >- + Looping over a column vector `for v = [1; 2; 3]` runs *once*, with `v` the + whole column; iterating a 1-D NumPy array runs three times. + - >- + After `for k = 1:n`, `k` is `n`; after `for k in range(n)` it is `n - 1` + (and unbound when `n` is 0). + - >- + Assigning to the loop variable inside the body does not affect the next + iteration, in either language. +related: [indexing/ranges, control-flow/while] +python_imports: [import numpy as np] diff --git a/rules/control-flow/for-columns/translate.py b/rules/control-flow/for-columns/translate.py new file mode 100644 index 0000000..e3a8bb7 --- /dev/null +++ b/rules/control-flow/for-columns/translate.py @@ -0,0 +1,163 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for control-flow/for-columns. + +A ``for`` loop takes one *column* of its iterable per pass. An integer range +is a Python ``range`` (shifted to 0-based when the loop variable only serves as +a position, see :func:`dualect.emit.index_variables`); a row vector iterates +its elements; a matrix iterates ``A.T`` (``A.T.copy()`` when the body writes +into the loop variable, since each row of ``A.T`` is a view of ``A``); a column +or a scalar runs once. A range known to be empty is declined: the source then +leaves the variable as an empty array, Python leaves it unbound. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line, offset +from dualect.infer import Kind +from dualect.lift import LiftContext + + +def _range(stmt: ir.For, it: ir.Range, ctx: Context) -> ast.expr | None: + ranges = ctx.module("indexing/ranges") + step = ranges.literal_int(it.step) if it.step is not None else 1 + start = ctx.info(it.start) + if step is None or step == 0 or not start.integer: + return None + first = ctx.expr(it.start) + stop = ctx.expr(it.stop) + if ctx.is_index_var(stmt.var.id): + if step != 1: + return None + args = [offset(first, -1), stop] + else: + args = [first, offset(stop, 1 if step > 0 else -1)] + if step != 1: + args.append(ctx.const(step)) + if len(args) == 2 and ast.unparse(args[0]) == "0": + args = args[1:] + return ctx.call(ast.Name("range"), *args) + + +def translate(stmt: ir.For, ctx: Context) -> list[Line]: + """One ``for`` loop.""" + var = stmt.var.id + it = stmt.iterable + info = ctx.info(it) + lines: list[Line] = [] + iterable: ast.expr | None = None + if isinstance(it, ir.Range): + iterable = _range(stmt, it, ctx) + if iterable is not None and ctx.is_index_var(var): + lines.extend(ctx.index_directive(var)) + if iterable is None: + if ctx.is_index_var(var): + ctx.decline("a position loop over something other than a range") + expr = ctx.expr(it) + if info.kind in (Kind.ROW, Kind.EMPTY) or isinstance(it, ir.Range): + iterable = expr + elif info.is_matrix: + iterable = ast.Attribute(value=expr, attr="T") + elif info.kind is Kind.COL or info.is_scalar: + iterable = ast.List(elts=[expr]) + else: + ctx.decline("a loop over a value whose shape is unknown") + if isinstance(it, ir.Range) and info.numel == 0: + # The source leaves the variable as an empty 1x0 array; Python leaves + # it unbound. + ctx.decline("a loop over a range that is known to be empty") + if info.is_matrix and var in ctx.scope.mutated: + # Each column of A.T is a view: writing into the loop variable would + # change A, while the source works on a copy of the column. + iterable = ctx.method(iterable, "copy") + lines.append(ctx.line(f"for {var} in {ast.unparse(iterable)}:")) + with ctx.loop(stmt): + lines.extend(ctx.block(stmt.body)) + return lines + + +# --- Python -> .m ------------------------------------------------------------ +# +# for k in range(a, b) is for k = a:b-1 (the values stay 0-based, as in +# Python). for x in v (1-D) takes each element: for x = v. A 2-D array yields +# its rows in Python but a .m loop takes columns, and a 1-D row is a row on +# the .m side: for c in A.T is for c = A with c = c.' first in the body, and +# for r in A is for r = A.' likewise. A list of arrays, for x in [v, w], loops +# over the cell {v, w} with x = x{1} first. Writing into such a row would write into +# A in NumPy (it is a view), which is declined. An empty range is declined: +# Python leaves the variable unbound, the .m side makes it an empty array. + + +def lift(stmt: ast.stmt, ctx: LiftContext) -> list[ir.Stmt]: + """One ``for`` loop (``range`` anywhere else is declined).""" + if not isinstance(stmt, ast.For): + ctx.decline("range() outside a for loop") + loc = ctx.loc(stmt) + target = stmt.target + if not isinstance(target, ast.Name): + ctx.decline("unpacking in a for loop") + var = ir.Name(loc=ctx.loc(target), id=target.id) + it = stmt.iter + prologue: list[ir.Stmt] = [] + iterable: ir.Expr + if isinstance(it, ast.Call) and isinstance(it.func, ast.Name) and it.func.id == "range": + iterable = _lift_range(it, ctx) + else: + info = ctx.info(it) + rows_of: ast.expr | None = None + if isinstance(it, ast.Attribute) and it.attr == "T" and ctx.info(it.value).is_matrix: + rows_of = it.value # rows of A.T: the columns of A + iterable = ctx.expr(rows_of) + elif info.is_matrix: + rows_of = it + iterable = ctx.transpose(ctx.expr(it)) + elif info.is_vector or ( + isinstance(it, ast.List) and all(ctx.info(e).is_scalar for e in it.elts) + ): + iterable = ctx.module_for("syntax/array-literals").lift_items(it, ctx) + elif isinstance(it, ast.List) and it.elts and all(ctx.info(e).is_array for e in it.elts): + # A list of arrays: loop over a cell, one array per pass. + if target.id in ctx.scope.mutated: + ctx.decline(f"writing into {target.id}, which shares memory with a list item") + iterable = ir.CellLit(loc=ctx.loc(it), items=[ctx.expr(e) for e in it.elts]) + unwrap = ir.Index(loc=loc, target=var, args=[ctx.num(1)]) + prologue.append(ir.Assign(loc=loc, targets=[var], value=_cell_item(unwrap))) + else: + ctx.decline("a loop over a value that is not a range or a known array") + if rows_of is not None: + if target.id in ctx.scope.mutated: + ctx.decline(f"writing into {target.id}, a view of the array being looped over") + prologue.append(ir.Assign(loc=loc, targets=[var], value=ctx.transpose(var))) + with ctx.loop(): + body = prologue + ctx.block(stmt.body) + return [ir.For(loc=loc, var=var, iterable=iterable, body=body)] + + +def _lift_range(call: ast.Call, ctx: LiftContext) -> ir.Expr: + """``range(...)`` as the ``.m`` range of the same values.""" + loc = ctx.loc(call) + args = call.args + if call.keywords or not 1 <= len(args) <= 3: + ctx.decline("range with these arguments") + ranges = ctx.module_for("indexing/ranges") + step = ranges._step(args[2] if len(args) == 3 else None, ctx) + start = ctx.num(0) if len(args) == 1 else ctx.expr(args[0]) + stop_node = args[0] if len(args) == 1 else args[1] + stop = ctx.shift(ctx.expr(stop_node), -1 if step > 0 else 1) + values = [ctx.info(a).value for a in args] + if all(isinstance(v, int) for v in values): + count = len(range(*values)) # type: ignore[arg-type] + if count == 0: + ctx.decline("a loop over an empty range (the loop variable would differ)") + if step == 1: + return ir.Range(loc=loc, start=start, stop=stop) + return ir.Range(loc=loc, start=start, stop=stop, step=ctx.num(step)) + + +def _cell_item(index: ir.Index) -> ir.Expr: + """``c{1}``: the IR has no brace index, so it is carried as verbatim ``.m`` text.""" + target = index.target + assert isinstance(target, ir.Name) + return ir.Opaque(loc=index.loc, construct="expr:cell-index", text=f"{target.id}{{1}}") diff --git a/rules/control-flow/if-elseif/cases/array-condition.m b/rules/control-flow/if-elseif/cases/array-condition.m new file mode 100644 index 0000000..d9d0721 --- /dev/null +++ b/rules/control-flow/if-elseif/cases/array-condition.m @@ -0,0 +1,12 @@ +v = [1 2 0]; +if v + all_nonzero = true; +else + all_nonzero = false; +end +e = []; +if e + empty_is_true = true; +else + empty_is_true = false; +end diff --git a/rules/control-flow/if-elseif/cases/array-condition.py b/rules/control-flow/if-elseif/cases/array-condition.py new file mode 100644 index 0000000..0c3990e --- /dev/null +++ b/rules/control-flow/if-elseif/cases/array-condition.py @@ -0,0 +1,12 @@ +import numpy as np + +v = np.array([1, 2, 0]) +if v.size > 0 and v.all(): + all_nonzero = True +else: + all_nonzero = False +e = np.array([]) +if e.size > 0 and e.all(): # e.all() alone is True for an empty array + empty_is_true = True +else: + empty_is_true = False diff --git a/rules/control-flow/if-elseif/cases/basic.m b/rules/control-flow/if-elseif/cases/basic.m new file mode 100644 index 0000000..e75dad0 --- /dev/null +++ b/rules/control-flow/if-elseif/cases/basic.m @@ -0,0 +1,13 @@ +1; +function s = sign_of(x) + if x > 0 + s = 1; + elseif x < 0 + s = -1; + else + s = 0; + end +end +s_pos = sign_of(3); +s_neg = sign_of(-2); +s_zero = sign_of(0); diff --git a/rules/control-flow/if-elseif/cases/basic.py b/rules/control-flow/if-elseif/cases/basic.py new file mode 100644 index 0000000..d18222a --- /dev/null +++ b/rules/control-flow/if-elseif/cases/basic.py @@ -0,0 +1,13 @@ +def sign_of(x): + if x > 0: + s = 1 + elif x < 0: + s = -1 + else: + s = 0 + return s + + +s_pos = sign_of(3) +s_neg = sign_of(-2) +s_zero = sign_of(0) diff --git a/rules/control-flow/if-elseif/rule.yaml b/rules/control-flow/if-elseif/rule.yaml new file mode 100644 index 0000000..221b4f8 --- /dev/null +++ b/rules/control-flow/if-elseif/rule.yaml @@ -0,0 +1,41 @@ +id: control-flow/if-elseif +title: "`if` / `elseif` / `else` and array conditions" +status: mechanical +dialects: [octave, matlab] +match: [stmt:if] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:if +octave: | + if x > 0 + s = 1; + elseif x < 0 + s = -1; + else + s = 0; + end +python: | + if x > 0: + s = 1 + elif x < 0: + s = -1 + else: + s = 0 +why: > + Same structure; `elseif` becomes `elif` and `end` disappears. A condition + that is an array is true only if it is non-empty and all its elements are + nonzero. NumPy refuses to guess (multi-element and empty arrays raise), so + write `cond.size > 0 and cond.all()` explicitly. +pitfalls: + - >- + `if []` is false and `if [1 1 0]` is false; `bool(np.array([]))` raises in + current NumPy and `np.array([]).all()` is True. + - >- + `else if` (two words) opens a *nested* `if` that needs its own `end`; it is + not `elif`. + - >- + `if a == b` on strings of different lengths is an error in Octave; string + comparison is `strcmp(a, b)`, which is `a == b` for Python strings. +related: [control-flow/switch, control-flow/while, operators/short-circuit] +python_imports: [import numpy as np] diff --git a/rules/control-flow/if-elseif/translate.py b/rules/control-flow/if-elseif/translate.py new file mode 100644 index 0000000..2d674e8 --- /dev/null +++ b/rules/control-flow/if-elseif/translate.py @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for control-flow/if-elseif. + +The structure maps directly. Conditions are where the languages differ: an +array condition holds only when it is non-empty and all its elements are +nonzero, which NumPy will not guess, so :func:`condition` (shared with the +loops) spells it out as ``x.size > 0 and x.all()``. A condition of unknown +shape is left as is: Python raises for a multi-element array, so a wrong guess +fails loudly. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.infer import Kind +from dualect.lift import LiftContext + + +def condition(node: ir.Expr, ctx: Context) -> ast.expr: + """A condition with the source's truth rule for arrays.""" + info = ctx.info(node) + expr = ctx.expr(node) + if info.kind is Kind.STRING: + ctx.decline("a char array as a condition") + if not info.is_array: + return expr + if isinstance(expr, ast.Name): + size = ast.Attribute(value=expr, attr="size") + nonempty = ast.Compare(left=size, ops=[ast.Gt()], comparators=[ast.Constant(0)]) + return ast.BoolOp(op=ast.And(), values=[nonempty, ctx.method(expr, "all")]) + if info.numel is not None and info.numel > 0: + return ctx.method(expr, "all") + ctx.decline("an array condition that is neither a variable nor known to be non-empty") + + +def translate(stmt: ir.If, ctx: Context) -> list[Line]: + """``if`` / ``elseif`` / ``else``.""" + lines: list[Line] = [] + for k, (cond, body) in enumerate(stmt.branches): + keyword = "if" if k == 0 else "elif" + lines.append(ctx.line(f"{keyword} {ast.unparse(condition(cond, ctx))}:")) + lines.extend(ctx.block(body)) + if stmt.orelse is not None: + lines.append(ctx.line("else:")) + lines.extend(ctx.block(stmt.orelse)) + return lines + + +# --- Python -> .m ------------------------------------------------------------ +# +# if / elif / else map to if / elseif / else. Tests are lifted as conditions +# (dualect.lift.LiftContext.condition): only their truth is used, so `and`/`or` +# of numbers may become && / ||. Python raises on the truth of an array with +# several elements, so an array test fails loudly in the source already. + + +def lift(stmt: ast.stmt, ctx: LiftContext) -> list[ir.Stmt]: + """``if`` / ``elif`` / ``else``.""" + assert isinstance(stmt, ast.If) + loc = ctx.loc(stmt) + branches: list[tuple[ir.Expr, list[ir.Stmt]]] = [] + node: ast.If = stmt + while True: + branches.append((ctx.condition(node.test), ctx.block(node.body))) + if len(node.orelse) == 1 and isinstance(node.orelse[0], ast.If): + node = node.orelse[0] + continue + orelse = ctx.block(node.orelse) if node.orelse else None + break + return [ir.If(loc=loc, branches=branches, orelse=orelse)] diff --git a/rules/control-flow/switch/cases/basic.m b/rules/control-flow/switch/cases/basic.m new file mode 100644 index 0000000..d0b821b --- /dev/null +++ b/rules/control-flow/switch/cases/basic.m @@ -0,0 +1,14 @@ +1; +function k = order_of(method) + switch method + case 'linear' + k = 1; + case {'cubic', 'spline'} + k = 3; + otherwise + k = 0; + end +end +k_lin = order_of('linear'); +k_spl = order_of('spline'); +k_other = order_of('nearest'); diff --git a/rules/control-flow/switch/cases/basic.py b/rules/control-flow/switch/cases/basic.py new file mode 100644 index 0000000..94b1093 --- /dev/null +++ b/rules/control-flow/switch/cases/basic.py @@ -0,0 +1,14 @@ +def order_of(method): + match method: + case "linear": + k = 1 + case "cubic" | "spline": + k = 3 + case _: + k = 0 + return k + + +k_lin = order_of("linear") +k_spl = order_of("spline") +k_other = order_of("nearest") diff --git a/rules/control-flow/switch/cases/numeric.m b/rules/control-flow/switch/cases/numeric.m new file mode 100644 index 0000000..35f04a8 --- /dev/null +++ b/rules/control-flow/switch/cases/numeric.m @@ -0,0 +1,9 @@ +n = 2; +switch n + case 1 + label = 'one'; + case {2, 3} + label = 'few'; + otherwise + label = 'many'; +end diff --git a/rules/control-flow/switch/cases/numeric.py b/rules/control-flow/switch/cases/numeric.py new file mode 100644 index 0000000..0816803 --- /dev/null +++ b/rules/control-flow/switch/cases/numeric.py @@ -0,0 +1,8 @@ +n = 2 +match n: + case 1: + label = "one" + case 2 | 3: + label = "few" + case _: + label = "many" diff --git a/rules/control-flow/switch/rule.yaml b/rules/control-flow/switch/rule.yaml new file mode 100644 index 0000000..04b693e --- /dev/null +++ b/rules/control-flow/switch/rule.yaml @@ -0,0 +1,45 @@ +id: control-flow/switch +title: "`switch` / `case` / `otherwise`" +status: mechanical +dialects: [octave, matlab] +match: [stmt:switch] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:match +octave: | + switch method + case 'linear' + k = 1; + case {'cubic', 'spline'} + k = 3; + otherwise + k = 0; + end +python: | + match method: + case "linear": + k = 1 + case "cubic" | "spline": + k = 3 + case _: + k = 0 +why: > + `switch` compares the value with each `case` in order (strings as whole, + case-sensitive strings; numbers with `==`) and runs only the first match: + there is no fall-through and no `break`. A cell array in a `case` matches any + of its elements. Python's `match` with literal patterns joined by `|` + expresses this directly; an `if`/`elif` chain is equally correct. +pitfalls: + - >- + A bare name in a `match` case is a capture pattern that matches anything: + `case limit:` does not compare with `limit`. Use literals, dotted names, or + a guard `case v if v == limit:`. + - >- + `otherwise` is `case _:`; without it, an unmatched value runs nothing in + both languages. + - >- + A numeric `case 1` also matches `1.0` in both languages (equality, not + type). +related: [control-flow/if-elseif] +python_imports: [] diff --git a/rules/control-flow/switch/translate.py b/rules/control-flow/switch/translate.py new file mode 100644 index 0000000..c136046 --- /dev/null +++ b/rules/control-flow/switch/translate.py @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for control-flow/switch: ``match`` with literal patterns. + +Each ``case`` value must be a literal (a number or a string); a cell of +values becomes alternatives joined by ``|``; ``otherwise`` is ``case _``. +Non-literal case values are declined: a bare name in a ``match`` pattern +captures instead of comparing. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.lift import LiftContext + + +def _pattern(value: ir.Expr, ctx: Context) -> str: + if isinstance(value, ir.Num | ir.Str): + return ast.unparse(ctx.expr(value)) + if isinstance(value, ir.UnOp) and value.op == "uminus" and isinstance(value.operand, ir.Num): + return ast.unparse(ctx.expr(value)) + ctx.decline("a case value that is not a literal") + + +def translate(stmt: ir.Switch, ctx: Context) -> list[Line]: + """One ``switch``.""" + if ctx.info(stmt.subject).is_array: + ctx.decline("switching on an array") + lines = [ctx.line(f"match {ast.unparse(ctx.expr(stmt.subject))}:")] + ctx.indent += 1 + try: + for values, body in stmt.cases: + patterns = " | ".join(_pattern(value, ctx) for value in values) + lines.append(ctx.line(f"case {patterns}:")) + lines.extend(ctx.block(body)) + if stmt.otherwise is not None: + lines.append(ctx.line("case _:")) + lines.extend(ctx.block(stmt.otherwise)) + finally: + ctx.indent -= 1 + return lines + + +# --- Python -> .m ------------------------------------------------------------ +# +# match with literal patterns is switch: case 1 | 2 is case {1, 2}, a string +# pattern compares the whole text (as switch does), case _ is otherwise and +# must come last. Other patterns (captures, guards, classes) are declined. + + +def _values(pattern: ast.pattern, ctx: LiftContext) -> list[ir.Expr] | None: + """The literal values of a pattern; ``None`` for the wildcard ``_``.""" + if isinstance(pattern, ast.MatchAs) and pattern.pattern is None and pattern.name is None: + return None + if isinstance(pattern, ast.MatchValue): + value = pattern.value + info = ctx.info(value) + if not (info.is_scalar or info.kind.value == "string") or info.is_bool: + ctx.decline("a case value that is not a number or a string") + return [ctx.expr(value)] + if isinstance(pattern, ast.MatchOr): + found: list[ir.Expr] = [] + for inner in pattern.patterns: + values = _values(inner, ctx) + if values is None: + ctx.decline("a wildcard inside an or-pattern") + found.extend(values) + return found + ctx.decline("a case pattern that is not a literal") + + +def lift(stmt: ast.stmt, ctx: LiftContext) -> list[ir.Stmt]: + """One ``match``.""" + assert isinstance(stmt, ast.Match) + subject = ctx.info(stmt.subject) + if not (subject.is_scalar or subject.kind.value == "string"): + ctx.decline("matching a value that is not a number or a string") + cases: list[tuple[list[ir.Expr], list[ir.Stmt]]] = [] + otherwise: list[ir.Stmt] | None = None + for k, case in enumerate(stmt.cases): + if case.guard is not None: + ctx.decline("a case guard") + values = _values(case.pattern, ctx) + if values is None: + if k != len(stmt.cases) - 1: + ctx.decline("a wildcard case that is not last") + otherwise = ctx.block(case.body) + else: + cases.append((values, ctx.block(case.body))) + return [ + ir.Switch( + loc=ctx.loc(stmt), subject=ctx.expr(stmt.subject), cases=cases, otherwise=otherwise + ) + ] diff --git a/rules/control-flow/while/cases/array-condition.m b/rules/control-flow/while/cases/array-condition.m new file mode 100644 index 0000000..4ce107f --- /dev/null +++ b/rules/control-flow/while/cases/array-condition.m @@ -0,0 +1,12 @@ +% An array condition holds only while every element is nonzero. +v = [3 2 1]; +steps = 0; +while v + v = v - 1; + steps = steps + 1; +end +e = []; +empty_runs = 0; +while e % an empty condition is false + empty_runs = empty_runs + 1; +end diff --git a/rules/control-flow/while/cases/array-condition.py b/rules/control-flow/while/cases/array-condition.py new file mode 100644 index 0000000..c99bf54 --- /dev/null +++ b/rules/control-flow/while/cases/array-condition.py @@ -0,0 +1,12 @@ +# An array condition holds only while every element is nonzero. +import numpy as np + +v = np.array([3, 2, 1]) +steps = 0 +while v.size > 0 and v.all(): + v = v - 1 + steps += 1 +e = np.array([]) +empty_runs = 0 +while e.size > 0 and e.all(): # e.all() alone is True for an empty array + empty_runs += 1 diff --git a/rules/control-flow/while/cases/basic.m b/rules/control-flow/while/cases/basic.m new file mode 100644 index 0000000..b98f456 --- /dev/null +++ b/rules/control-flow/while/cases/basic.m @@ -0,0 +1,12 @@ +% Newton's method for sqrt(2), then a do-until counter. +a = 2; +x = 1; +iterations = 0; +while abs(x^2 - a) > 1e-12 + x = x - (x^2 - a) / (2*x); + iterations = iterations + 1; +end +n = 0; +do % Octave only + n++; +until n >= 3 diff --git a/rules/control-flow/while/cases/basic.py b/rules/control-flow/while/cases/basic.py new file mode 100644 index 0000000..e34b81b --- /dev/null +++ b/rules/control-flow/while/cases/basic.py @@ -0,0 +1,12 @@ +# Newton's method for sqrt(2), then a do-until counter. +a = 2 +x = 1 +iterations = 0 +while abs(x**2 - a) > 1e-12: + x = x - (x**2 - a) / (2 * x) + iterations += 1 +n = 0 +while True: # do ... until: the body runs at least once + n += 1 + if n >= 3: + break diff --git a/rules/control-flow/while/rule.yaml b/rules/control-flow/while/rule.yaml new file mode 100644 index 0000000..31fc0f4 --- /dev/null +++ b/rules/control-flow/while/rule.yaml @@ -0,0 +1,41 @@ +id: control-flow/while +title: "`while` loops and Octave's `do ... until`" +status: mechanical +dialects: [octave, matlab] +match: [stmt:while, stmt:do-until, stmt:break, stmt:continue] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:while + - py:break + - py:continue +octave: | + while err > tol + ... + end + do % Octave only + ... + until done +python: | + while err > tol: + ... + while True: + ... + if done: + break +why: > + For a scalar condition the loops are identical. An array condition is true + only when it is non-empty and every element is nonzero; Python raises for a + multi-element array, so spell it out as `x.size > 0 and x.all()`. Octave's + `do ... until cond` runs the body at least once: `while True:` with a final + `if cond: break`. +pitfalls: + - >- + `while x` with an empty `x` is false in Octave, but `x.all()` on an empty + array is True in NumPy: check `x.size` too. + - >- + `k++` and `k += 1` are Octave only (MATLAB has neither); Python has `+=`. + - >- + `break` and `continue` translate directly. +related: [control-flow/if-elseif, control-flow/for-columns] +python_imports: [import numpy as np] diff --git a/rules/control-flow/while/translate.py b/rules/control-flow/while/translate.py new file mode 100644 index 0000000..3ec28ed --- /dev/null +++ b/rules/control-flow/while/translate.py @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for control-flow/while: ``while``, ``do ... until``, ``break``, ``continue``. + +Conditions follow control-flow/if-elseif. ``do ... until c`` becomes +``while True:`` with ``if c: break`` at the end of the body. A ``continue`` +inside ``do ... until`` would skip that test in Python, so it is declined. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.lift import LiftContext + + +def translate(stmt: ir.While | ir.DoUntil | ir.Break | ir.Continue, ctx: Context) -> list[Line]: + """One loop or loop jump.""" + condition = ctx.module("control-flow/if-elseif").condition + if isinstance(stmt, ir.Break): + return [ctx.line("break")] + if isinstance(stmt, ir.Continue): + if ctx.loop_stack and isinstance(ctx.loop_stack[-1], ir.DoUntil): + ctx.decline("continue inside do ... until") + return [ctx.line("continue")] + if isinstance(stmt, ir.While): + header = ctx.line(f"while {ast.unparse(condition(stmt.cond, ctx))}:") + with ctx.loop(stmt): + body = ctx.block(stmt.body) + return [header, *body] + with ctx.loop(stmt): + body = ctx.block(stmt.body) + exit_test = ast.unparse(condition(stmt.cond, ctx)) + body = [line for line in body if line.text != "pass"] + return [ + ctx.line("while True:"), + *body, + ctx.line(f"if {exit_test}:", extra=1), + ctx.line("break", extra=2), + ] + + +# --- Python -> .m ------------------------------------------------------------ +# +# while / break / continue map directly; `while True:` is `while true`. + + +def lift(stmt: ast.stmt, ctx: LiftContext) -> list[ir.Stmt]: + """``while``, ``break`` or ``continue``.""" + loc = ctx.loc(stmt) + if isinstance(stmt, ast.Break): + return [ir.Break(loc=loc)] + if isinstance(stmt, ast.Continue): + return [ir.Continue(loc=loc)] + assert isinstance(stmt, ast.While) + cond = ctx.condition(stmt.test) + with ctx.loop(): + body = ctx.block(stmt.body) + return [ir.While(loc=loc, cond=cond, body=body)] diff --git a/rules/functions/definition/cases/basic.m b/rules/functions/definition/cases/basic.m new file mode 100644 index 0000000..c9ba129 --- /dev/null +++ b/rules/functions/definition/cases/basic.m @@ -0,0 +1,14 @@ +1; +function y = area(r) + y = pi * r.^2; +end +function x = zero_first(x) + x(1) = 0; % changes a copy: the caller's array is untouched +end +a1 = area(2); +radii = [1 2 3]; +areas = area(radii); +v = [5 6 7]; +w = zero_first(v); +sq = @(t) t.^2; +nine = sq(3); diff --git a/rules/functions/definition/cases/basic.py b/rules/functions/definition/cases/basic.py new file mode 100644 index 0000000..45a74e5 --- /dev/null +++ b/rules/functions/definition/cases/basic.py @@ -0,0 +1,20 @@ +import numpy as np + + +def area(r): + return np.pi * r**2 + + +def zero_first(x): + x = x.copy() # Octave works on a copy; NumPy would change the caller's array + x[0] = 0 + return x + + +a1 = area(2) +radii = np.array([1, 2, 3]) +areas = area(radii) +v = np.array([5, 6, 7]) +w = zero_first(v) +sq = lambda t: t**2 +nine = sq(3) diff --git a/rules/functions/definition/cases/captured-value.m b/rules/functions/definition/cases/captured-value.m new file mode 100644 index 0000000..05315a8 --- /dev/null +++ b/rules/functions/definition/cases/captured-value.m @@ -0,0 +1,5 @@ +% An anonymous function keeps the value k had when it was created. +k = 2; +f = @(t) k * t; +k = 10; +y = f(3); % 6, not 30 diff --git a/rules/functions/definition/cases/captured-value.py b/rules/functions/definition/cases/captured-value.py new file mode 100644 index 0000000..96a521c --- /dev/null +++ b/rules/functions/definition/cases/captured-value.py @@ -0,0 +1,5 @@ +# An anonymous function keeps the value k had when it was created. +k = 2 +f = lambda t, k=k: k * t # bind k now; a plain lambda would see k = 10 +k = 10 +y = f(3) # 6, not 30 diff --git a/rules/functions/definition/rule.yaml b/rules/functions/definition/rule.yaml new file mode 100644 index 0000000..09883fd --- /dev/null +++ b/rules/functions/definition/rule.yaml @@ -0,0 +1,45 @@ +id: functions/definition +title: "Function definitions and argument copy semantics" +status: mechanical +dialects: [octave, matlab] +match: [func:definition, func:handle, func:call-local, func:call-handle, stmt:return, syntax:script-marker] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:def + - py:return + - py:lambda + - py:call-local + - py:call-handle +octave: | + function y = area(r) + y = pi * r.^2; + end + sq = @(t) t.^2; +python: | + def area(r): + return np.pi * r**2 + + sq = lambda t: t**2 +why: > + The output variable named in the header is returned when the function ends; + in Python, `return` it explicitly. Octave passes arguments by value (copy on + write), so a function can never change the caller's array; NumPy passes a + reference, so copy an argument before modifying it in place. An anonymous + function `@(t) expr` is a `lambda` (or a small `def`). +pitfalls: + - >- + `x(1) = 0` inside a function leaves the caller's `x` untouched in Octave, + while `x[0] = 0` in Python changes the caller's array: write + `x = x.copy()` first. + - >- + In a script, Octave needs a leading `1;` and functions defined before use, + while MATLAB (R2016b+) wants local functions at the end of the file. + - >- + In a function file the first function is the public one and later ones are + local helpers; `end`/`endfunction` may be omitted in Octave. + - >- + An anonymous function captures variable *values* when it is created; + a Python lambda looks names up when it is called. +related: [functions/multiple-returns, functions/nargin] +python_imports: [import numpy as np] diff --git a/rules/functions/definition/translate.py b/rules/functions/definition/translate.py new file mode 100644 index 0000000..368f0ea --- /dev/null +++ b/rules/functions/definition/translate.py @@ -0,0 +1,425 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for functions/definition: ``function``, ``@(x) ...``, calls, ``return``. + +A function becomes a ``def`` that returns its outputs; when the body ends by +assigning the single output, that assignment becomes the ``return``. Octave +passes arguments by value, so a parameter the body modifies in place is +copied first. Defaults filled in with ``if nargin < k`` become parameter +defaults (functions/nargin). An anonymous function becomes a ``lambda`` whose +captured variables are bound when it is created (``k=k``), because the source +captures values while a Python lambda looks names up when called. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.infer import Kind +from dualect.lift import LiftContext + + +def translate(node: ir.Node, ctx: Context) -> ast.expr | list[Line]: + """Dispatch on the node kind.""" + if isinstance(node, ir.FunctionDef): + return _function(node, ctx) + if isinstance(node, ir.Lambda): + return _lambda(node, ctx) + if isinstance(node, ir.Call): + return _call(node, ctx) + if isinstance(node, ir.Return): + outputs = ctx.scope.outputs + if not outputs: + return [ctx.line("return")] + return [ctx.line(f"return {', '.join(outputs)}")] + ctx.decline(f"{type(node).__name__}") + + +def _uses_nargin(fdef: ir.FunctionDef) -> bool: + """Whether the function body reads ``nargin``.""" + for stmt in ir.walk_stmts(fdef.body): + for expr in ir.stmt_exprs(stmt): + for node in ir.walk_expr(expr): + if isinstance(node, ir.Call) and node.func == "nargin": + return True + return False + + +def _reads(name: str, body: list[ir.Stmt]) -> bool: + """Whether ``name`` is read anywhere in ``body``.""" + for stmt in ir.walk_stmts(body): + for expr in ir.stmt_exprs(stmt): + if isinstance(stmt, ir.Assign) and expr in stmt.targets and isinstance(expr, ir.Name): + continue + for node in ir.walk_expr(expr): + if isinstance(node, ir.Name) and node.id == name: + return True + if ( + isinstance(node, ir.Index) + and isinstance(node.target, ir.Name) + and node.target.id == name + ): + return True + return False + + +def _assignments(name: str, body: list[ir.Stmt]) -> int: + count = 0 + for stmt in ir.walk_stmts(body): + if isinstance(stmt, ir.Assign): + count += sum(1 for t in stmt.targets if isinstance(t, ir.Name) and t.id == name) + count += sum( + 1 + for t in stmt.targets + if isinstance(t, ir.Index) and isinstance(t.target, ir.Name) and t.target.id == name + ) + elif isinstance(stmt, ir.AugAssign | ir.For): + target = stmt.target if isinstance(stmt, ir.AugAssign) else stmt.var + if isinstance(target, ir.Name) and target.id == name: + count += 1 + return count + + +def _function(fdef: ir.FunctionDef, ctx: Context) -> list[Line]: + if "varargin" in fdef.params or "varargout" in fdef.outputs or "~" in fdef.params: + ctx.decline("varargin, varargout or ignored parameters") + if fdef.name in ctx.scope.variables: + ctx.decline("a function named like a variable") + defaults: dict[str, str] = {} + body = fdef.body + nargin_rule = None + if _uses_nargin(fdef) and ctx.has_mechanical("functions/nargin"): + nargin_rule = ctx.module("functions/nargin") + with ctx.function_scope(fdef) as scope: + if nargin_rule is not None: + defaults, body = nargin_rule.extract_defaults(fdef, ctx) + params = [f"{p}={defaults[p]}" if p in defaults else p for p in fdef.params] + header = ctx.line(f"def {fdef.name}({', '.join(params)}):") + copies: list[Line] = [] + facts = ctx.analysis.functions.get(fdef.name) + for k, param in enumerate(fdef.params): + if param not in scope.mutated: + continue + info = facts.params[k] if facts is not None and k < len(facts.params) else None + if info is not None and (info.is_scalar or info.kind is Kind.STRING): + continue + # The source works on a private copy; NumPy would change the caller's array. + copies.append(ctx.line(f"{param} = {param}.copy()", extra=1)) + outputs = fdef.outputs + tail: ir.Assign | None = None + last = body[-1] if body else None + if ( + len(outputs) == 1 + and isinstance(last, ir.Assign) + and len(last.targets) == 1 + and isinstance(last.targets[0], ir.Name) + and last.targets[0].id == outputs[0] + and outputs[0] not in fdef.params + and _assignments(outputs[0], body) == 1 + and not _reads(outputs[0], body[:-1]) + ): + tail = last + body = body[:-1] + lines = [header, *copies] + ctx.indent += 1 + try: + inner = ctx.statements(body) + if tail is not None: + tail_lines = ctx.statement(tail) + code = [t for t in tail_lines if not t.text.startswith("#")] + prefix = f"{outputs[0]} = " + if ( + len(code) == 1 + and code[0].text.startswith(prefix) + and "raise" not in code[0].text + ): + position = tail_lines.index(code[0]) + tail_lines[position] = Line( + code[0].indent, "return " + code[0].text[len(prefix) :] + ) + inner.extend(tail_lines) + else: + inner.extend(tail_lines) + inner.append(ctx.line(f"return {outputs[0]}")) + elif outputs: + inner.append(ctx.line(f"return {', '.join(outputs)}")) + finally: + ctx.indent -= 1 + if not any(not line.text.startswith("#") for line in inner): + inner.append(ctx.line("pass", extra=1)) + lines.extend(inner) + return lines + + +def _lambda(node: ir.Lambda, ctx: Context) -> ast.expr: + captured: list[str] = [] + for inner in ir.walk_expr(node.body): + name = None + if isinstance(inner, ir.Name): + name = inner.id + elif isinstance(inner, ir.Index) and isinstance(inner.target, ir.Name): + name = inner.target.id + if name is None or name in node.params or name in captured: + continue + if name in ctx.scope.variables: + if name in ctx.scope.mutated or ctx.is_index_var(name): + ctx.decline(f"a lambda capturing {name}, which is modified in place") + captured.append(name) + args = ast.arguments( + posonlyargs=[], + args=[ast.arg(arg=p) for p in [*node.params, *captured]], + vararg=None, + kwonlyargs=[], + kw_defaults=[], + kwarg=None, + defaults=[ast.Name(id=c) for c in captured], + ) + return ast.Lambda(args=args, body=ctx.expr(node.body)) + + +def _call(node: ir.Call, ctx: Context) -> ast.expr: + if node.handle: + return ctx.call(ast.Name(node.func), *(ctx.expr(a) for a in node.args)) + fdef = ctx.functions.get(node.func) + if fdef is None: + ctx.decline(f"call to {node.func}") + defaults: dict[str, str] = {} + if _uses_nargin(fdef) and ctx.has_mechanical("functions/nargin"): + defaults = ctx.module("functions/nargin").defaults_of(fdef, ctx) + args: list[ast.expr] = [] + for k, arg in enumerate(node.args): + param = fdef.params[k] if k < len(fdef.params) else None + is_empty = isinstance(arg, ir.Matrix) and not arg.rows + if param is not None and is_empty and defaults.get(param) == "None": + args.append(ast.Constant(None)) + else: + args.append(ctx.expr(arg)) + call = ctx.call(ast.Name(node.func), *args) + if len(fdef.outputs) > 1: + # Only the first output is used here; Python returns them all as a tuple. + return ast.Subscript(value=call, slice=ast.Constant(0)) + return call + + +# --- Python -> .m ------------------------------------------------------------ +# +# A def becomes a function whose output is the returned variable (or `out`). +# Three Python behaviours have no .m counterpart and are declined rather than +# translated as if they did not exist: a function that writes into an array +# argument changes the caller's array (unless it copies it first); a function +# that reads a module-level variable sees it, where a .m function does not; +# and a lambda looks its free variables up when called, where an .m handle +# captures their values when created (a lambda is translated when each free +# variable is assigned once, or captured with a `k=k` default). + + +def _returns(body: list[ast.stmt]) -> list[ast.Return]: + """Every ``return`` of a function body (nested functions and lambdas excluded).""" + found: list[ast.Return] = [] + for stmt in body: + if isinstance(stmt, ast.Return): + found.append(stmt) + elif not isinstance(stmt, ast.FunctionDef | ast.ClassDef): + for field in ("body", "orelse", "finalbody"): + found.extend(_returns(getattr(stmt, field, []) or [])) + for case in getattr(stmt, "cases", []) or []: + found.extend(_returns(case.body)) + return found + + +def _fresh(base: str, taken: set[str]) -> str: + name = base + while name in taken: + name += "_" + return name + + +def output_names(fdef: ast.FunctionDef, ctx: LiftContext) -> list[str]: + """The ``.m`` output variables of a ``def``, from its ``return`` statements.""" + returns = _returns(fdef.body) + values = [r.value for r in returns] + if not returns or all(v is None for v in values): + return [] + if any(v is None for v in values): + ctx.decline("a function that returns a value on some paths only") + if not isinstance(fdef.body[-1], ast.Return): + ctx.decline("a function whose last statement is not its return") + taken = {a.arg for a in fdef.args.args} | { + n.id for n in ast.walk(fdef) if isinstance(n, ast.Name) + } + tuples = [v for v in values if isinstance(v, ast.Tuple)] + if tuples: + ctx.module_for("functions/multiple-returns") + sizes = {len(v.elts) for v in values if isinstance(v, ast.Tuple)} + if len(tuples) != len(values) or len(sizes) != 1: + ctx.decline("returns of different arity") + first = tuples[0].elts + if all( + all(isinstance(e, ast.Name) for e in t.elts) + and [e.id for e in t.elts if isinstance(e, ast.Name)] + == [getattr(x, "id", None) for x in first] + for t in tuples + ): + return [getattr(x, "id", "") for x in first] + return [_fresh(f"out{k + 1}", taken) for k in range(sizes.pop())] + names = {v.id if isinstance(v, ast.Name) else None for v in values} + if len(names) == 1 and None not in names: + name = names.pop() + assert name is not None + return [name] + return [_fresh("out", taken)] + + +def _bindings(name: str, body: list[ast.stmt]) -> int: + """How many statements of a scope bind ``name``.""" + count = 0 + for node in ast.walk(ast.Module(body=body, type_ignores=[])): + if isinstance(node, ast.FunctionDef): + continue + if isinstance(node, ast.Name) and isinstance(node.ctx, ast.Store) and node.id == name: + count += 1 + return count + + +def _lift_def(fdef: ast.FunctionDef, ctx: LiftContext) -> list[ir.Stmt]: + if ctx.function is not None or fdef not in ctx.module.body: + ctx.decline("a function defined inside another statement") + params = [a.arg for a in fdef.args.args] + outputs = output_names(fdef, ctx) + with ctx.function_scope(fdef, outputs) as scope: + local = scope.variables + for node in ast.walk(fdef): + if ( + isinstance(node, ast.Name) + and isinstance(node.ctx, ast.Load) + and node.id not in local + and node.id in ctx.module_scope.variables + ): + ctx.decline(f"a function reading the module variable {node.id}") + facts = ctx.analysis.functions.get(fdef.name) + for k, param in enumerate(params): + if param not in scope.mutated: + continue + info = facts.params[k] if facts is not None else None + if info is not None and (info.is_scalar or info.kind.value == "string"): + continue + if not _copied_before_written(param, fdef.body, ctx): + ctx.decline(f"writing into the argument {param} (NumPy changes the caller's array)") + body = ctx.block(fdef.body) + return [ + ir.FunctionDef(loc=ctx.loc(fdef), name=fdef.name, params=params, outputs=outputs, body=body) + ] + + +def _writes(stmt: ast.stmt, name: str) -> bool: + """Whether a statement writes into the array ``name`` in place.""" + for node in ast.walk(stmt): + targets: list[ast.expr] = [] + if isinstance(node, ast.Assign): + targets = [t for t in node.targets if isinstance(t, ast.Subscript)] + elif isinstance(node, ast.AugAssign): + targets = [node.target] + for target in targets: + root = target.value if isinstance(target, ast.Subscript) else target + while isinstance(root, ast.Subscript | ast.Attribute): + root = root.value + if isinstance(root, ast.Name) and root.id == name: + return True + return False + + +def _copied_before_written(param: str, body: list[ast.stmt], ctx: LiftContext) -> bool: + """``param = param.copy()`` (or any fresh value) at the top, before the first write.""" + for stmt in body: + if ( + isinstance(stmt, ast.Assign) + and len(stmt.targets) == 1 + and isinstance(stmt.targets[0], ast.Name) + and stmt.targets[0].id == param + and not ctx.info(stmt.value).view + and not _writes(stmt, param) + ): + return True + if _writes(stmt, param): + return False + return True + + +def _lift_return(stmt: ast.Return, ctx: LiftContext) -> list[ir.Stmt]: + fdef = ctx.function + if fdef is None: + ctx.decline("return outside a function") + loc = ctx.loc(stmt) + lifted: list[ir.Stmt] = [] + values: list[ast.expr] = [] + if isinstance(stmt.value, ast.Tuple): + values = list(stmt.value.elts) + elif stmt.value is not None: + values = [stmt.value] + for output, value in zip(ctx.outputs, values, strict=True): + if isinstance(value, ast.Name) and value.id == output: + continue + lifted.append( + ir.Assign(loc=loc, targets=[ir.Name(loc=loc, id=output)], value=ctx.expr(value)) + ) + if fdef.body[-1] is not stmt: + lifted.append(ir.Return(loc=loc)) + return lifted + + +def _lift_lambda(node: ast.Lambda, ctx: LiftContext) -> ir.Expr: + args = node.args + if args.vararg or args.kwarg or args.kwonlyargs or args.posonlyargs: + ctx.decline("a lambda with variable or keyword-only arguments") + names = [a.arg for a in args.args] + first_default = len(names) - len(args.defaults) + captured: set[str] = set() + for name, default in zip(names[first_default:], args.defaults, strict=True): + if not (isinstance(default, ast.Name) and default.id == name): + ctx.decline("a lambda parameter with a default value") + captured.add(name) + params = names[:first_default] + body_scope: list[ast.stmt] = ctx.function.body if ctx.function is not None else ctx.module.body + for inner in ast.walk(node.body): + if not isinstance(inner, ast.Name) or inner.id in params: + continue + name = inner.id + if name in captured or name not in ctx.scope.variables: + continue + if name in ctx.scope.mutated or _bindings(name, body_scope) > 1: + ctx.decline( + f"a lambda reading {name}, which changes later (Python reads it when called)" + ) + return ir.Lambda(loc=ctx.loc(node), params=params, body=ctx.expr(node.body)) + + +def _lift_call(node: ast.Call, ctx: LiftContext) -> ir.Expr: + loc = ctx.loc(node) + if node.keywords: + ctx.decline("keyword arguments") + func = node.func + assert isinstance(func, ast.Name) + args = [ctx.module_for("syntax/array-literals").lift_items(a, ctx) for a in node.args] + fdef = ctx.functions.get(func.id) + if fdef is None or func.id in ctx.scope.variables: + return ir.Call(loc=loc, func=func.id, args=args, handle=True) + if len(node.args) != len(fdef.args.args): + ctx.decline("a call that relies on default arguments") + returns = _returns(fdef.body) + if any(isinstance(r.value, ast.Tuple) for r in returns): + ctx.decline("using the whole tuple a function returns") + return ir.Call(loc=loc, func=func.id, args=args, local=True) + + +def lift(node: ast.AST, ctx: LiftContext) -> ir.Expr | list[ir.Stmt]: + """A ``def``, ``return``, ``lambda`` or a call of a local function or a lambda.""" + if isinstance(node, ast.FunctionDef): + return _lift_def(node, ctx) + if isinstance(node, ast.Return): + return _lift_return(node, ctx) + if isinstance(node, ast.Lambda): + return _lift_lambda(node, ctx) + if isinstance(node, ast.Call): + return _lift_call(node, ctx) + ctx.decline(f"{type(node).__name__}") diff --git a/rules/functions/multiple-returns/cases/basic.m b/rules/functions/multiple-returns/cases/basic.m new file mode 100644 index 0000000..1bde48f --- /dev/null +++ b/rules/functions/multiple-returns/cases/basic.m @@ -0,0 +1,16 @@ +1; +function [s, p] = sum_prod(x) + s = sum(x); + p = prod(x); +end +function [lo, hi] = bounds_of(x) + lo = min(x); + if nargout > 1 + hi = max(x); + end +end +v = [2 3 4]; +[s, p] = sum_prod(v); +s_only = sum_prod(v); +lo_only = bounds_of(v); +[lo, hi] = bounds_of(v); diff --git a/rules/functions/multiple-returns/cases/basic.py b/rules/functions/multiple-returns/cases/basic.py new file mode 100644 index 0000000..3c195ca --- /dev/null +++ b/rules/functions/multiple-returns/cases/basic.py @@ -0,0 +1,16 @@ +import numpy as np + + +def sum_prod(x): + return x.sum(), x.prod() + + +def bounds_of(x): + return x.min(), x.max() + + +v = np.array([2, 3, 4]) +s, p = sum_prod(v) +s_only = sum_prod(v)[0] +lo_only = bounds_of(v)[0] +lo, hi = bounds_of(v) diff --git a/rules/functions/multiple-returns/rule.yaml b/rules/functions/multiple-returns/rule.yaml new file mode 100644 index 0000000..c86cc04 --- /dev/null +++ b/rules/functions/multiple-returns/rule.yaml @@ -0,0 +1,41 @@ +id: functions/multiple-returns +title: "Multiple return values and `nargout`" +status: guided +dialects: [octave, matlab] +match: [func:multi-output, func:nargout, assign:multi, assign:ignore-output] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:assign-multi + - py:return-multi +octave: | + function [s, p] = sum_prod(x) + s = sum(x); + p = prod(x); + end + [s, p] = sum_prod(v); + s_only = sum_prod(v); % first output only +python: | + def sum_prod(x): + return x.sum(), x.prod() + + s, p = sum_prod(v) + s_only = sum_prod(v)[0] +why: > + An Octave function names its outputs and the *caller* decides how many to + take; asking for one gets only the first. A Python function returns one + tuple: unpack it, and where Octave took fewer outputs, take the first element + explicitly. +pitfalls: + - >- + `y = f(x)` in Octave is the first output; in Python `y` would be the whole + tuple. + - >- + `[~, i] = max(x)` discards outputs: `_, i = ...`. Built-ins differ: Python's + reductions return one value, see builtins/sum-mean-max. + - >- + Functions that compute optional outputs only `if nargout > 1` always + compute everything in a Python tuple; add a flag argument if the extra work + is expensive. +related: [functions/definition, functions/nargin] +python_imports: [import numpy as np] diff --git a/rules/functions/multiple-returns/translate.py b/rules/functions/multiple-returns/translate.py new file mode 100644 index 0000000..55219c1 --- /dev/null +++ b/rules/functions/multiple-returns/translate.py @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for functions/multiple-returns (Python -> ``.m`` only, for now). + +``.m`` -> Python is still ``guided``: ``nargout``-dependent bodies would have to +be collapsed into one tuple return (docs/design.md section 11). + +Python -> ``.m``: ``return a, b`` gives the function the outputs ``[a, b]`` +(functions/definition picks the names); ``s, p = f(v)`` is +``[s, p] = f(v)``; ``f(v)[0]`` is ``f(v)``, the first output; ``r, c = +A.shape`` is ``[r, c] = size(A)`` (builtins/size-numel-length), and +``r, c = np.nonzero(A)`` goes to builtins/find. Unpacking a +tuple literal (``a, b = b, a``) evaluates every value before assigning, +which a sequence of ``.m`` assignments does not, so it is declined. +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.lift import LiftContext + + +def translate(node: ir.Node, ctx: Context) -> None: + """The ``.m`` -> Python direction is guided: never called for this rule.""" + ctx.decline("multiple returns are translated by an LLM in this direction") + + +def _outputs(name: str, ctx: LiftContext) -> int: + fdef = ctx.functions[name] + definition = ctx.module_for("functions/definition") + returns = definition._returns(fdef.body) + counts = {len(r.value.elts) if isinstance(r.value, ast.Tuple) else 1 for r in returns} + if len(counts) != 1: + ctx.decline(f"{name} returns different numbers of values") + return counts.pop() + + +def lift_multi(stmt: ast.Assign, ctx: LiftContext) -> list[ir.Stmt]: + """``a, b = f(x)`` or ``r, c = A.shape``.""" + target = stmt.targets[0] + value = stmt.value + assert isinstance(target, ast.Tuple | ast.List) + if isinstance(value, ast.Attribute) and value.attr == "shape": + return ctx.module_for("builtins/size-numel-length").lift_multi(stmt, ctx) + if isinstance(value, ast.Call) and ctx.tag(value) == "py:call:np.nonzero": + return ctx.module_for("builtins/find").lift_multi(stmt, ctx) + if not ( + isinstance(value, ast.Call) + and isinstance(value.func, ast.Name) + and value.func.id in ctx.functions + and value.func.id not in ctx.scope.variables + ): + ctx.decline("unpacking a value that is not a call of a local function") + if _outputs(value.func.id, ctx) != len(target.elts): + ctx.decline("unpacking a different number of values than the function returns") + names: list[ir.Expr] = [] + for element in target.elts: + if not isinstance(element, ast.Name): + ctx.decline("unpacking into an element") + names.append(ir.Name(loc=ctx.loc(element), id=element.id)) + if value.keywords: + ctx.decline("keyword arguments") + literals = ctx.module_for("syntax/array-literals") + call = ir.Call( + loc=ctx.loc(value), + func=value.func.id, + args=[literals.lift_items(a, ctx) for a in value.args], + local=True, + ) + return [ir.Assign(loc=ctx.loc(stmt), targets=names, value=call)] + + +def lift_item(node: ast.Subscript, ctx: LiftContext) -> ir.Expr: + """``f(x)[0]``: the first output, which a ``.m`` call returns by itself.""" + call = node.value + assert isinstance(call, ast.Call) and isinstance(call.func, ast.Name) + if not (isinstance(node.slice, ast.Constant) and node.slice.value == 0): + ctx.decline("an output other than the first") + if _outputs(call.func.id, ctx) < 2: + ctx.decline("indexing the value a function returns") + if call.keywords: + ctx.decline("keyword arguments") + literals = ctx.module_for("syntax/array-literals") + return ir.Call( + loc=ctx.loc(node), + func=call.func.id, + args=[literals.lift_items(a, ctx) for a in call.args], + local=True, + ) + + +def lift(node: ast.AST, ctx: LiftContext) -> ir.Expr: + """Never reached directly: the forms above are dispatched by the engine and rules.""" + ctx.decline("this use of several return values") diff --git a/rules/functions/nargin/cases/basic.m b/rules/functions/nargin/cases/basic.m new file mode 100644 index 0000000..2a6f72f --- /dev/null +++ b/rules/functions/nargin/cases/basic.m @@ -0,0 +1,22 @@ +1; +function y = scale(x, factor) + if nargin < 2 + factor = 10; + end + y = x * factor; +end +function y = clip_to(x, lo, hi) + if nargin < 2 || isempty(lo) + lo = 0; + end + if nargin < 3 + hi = max(x); % the default depends on another argument + end + y = min(max(x, lo), hi); +end +a = scale(2); +b = scale(2, 3); +x = [-1 5 12]; +c1 = clip_to(x); +c2 = clip_to(x, [], 4); +c3 = clip_to(x, 1, 6); diff --git a/rules/functions/nargin/cases/basic.py b/rules/functions/nargin/cases/basic.py new file mode 100644 index 0000000..304f074 --- /dev/null +++ b/rules/functions/nargin/cases/basic.py @@ -0,0 +1,21 @@ +import numpy as np + + +def scale(x, factor=10): + return x * factor + + +def clip_to(x, lo=None, hi=None): + if lo is None: + lo = 0 + if hi is None: + hi = x.max() # the default depends on another argument + return np.clip(x, lo, hi) + + +a = scale(2) +b = scale(2, 3) +x = np.array([-1, 5, 12]) +c1 = clip_to(x) +c2 = clip_to(x, None, 4) +c3 = clip_to(x, 1, 6) diff --git a/rules/functions/nargin/rule.yaml b/rules/functions/nargin/rule.yaml new file mode 100644 index 0000000..4286a3c --- /dev/null +++ b/rules/functions/nargin/rule.yaml @@ -0,0 +1,40 @@ +id: functions/nargin +title: "Optional arguments with `nargin`" +status: guided +dialects: [octave, matlab] +match: [func:nargin] +from_python: # the Python -> .m direction + status: guided + match: + - py:def-default + - py:none + - py:cmp:is + - py:cmp:isnot +octave: | + function y = scale(x, factor) + if nargin < 2 + factor = 10; + end + y = x * factor; + end +python: | + def scale(x, factor=10): + return x * factor +why: > + Octave has no default argument values: a function checks `nargin` (how many + inputs the caller passed) and fills in the rest. In Python a `nargin < k` + default becomes a parameter default. When the default depends on another + argument, or callers pass `[]` to mean "use the default", use `None` as the + default and fill it in the body. +pitfalls: + - >- + Never use a mutable default (a list or array): it is created once and + shared between calls. Use `None`. + - >- + `nargin < 2 || isempty(lo)` lets callers skip an argument with `[]`; map + that to `None` (`if lo is None`). + - >- + `varargin` collects extra inputs in a cell array: `*args`. `nargin` counts + them too. +related: [functions/definition, functions/multiple-returns] +python_imports: [import numpy as np] diff --git a/rules/indexing/colon-all/cases/basic.m b/rules/indexing/colon-all/cases/basic.m new file mode 100644 index 0000000..b0e2d17 --- /dev/null +++ b/rules/indexing/colon-all/cases/basic.m @@ -0,0 +1,7 @@ +A = [1 2 3; 4 5 6]; +v = A(:); % 1 4 2 5 3 6 +total = sum(A(:)); +B = A; +B(:) = 0; +C = A; +C(:) = 1:6; % fills column by column diff --git a/rules/indexing/colon-all/cases/basic.py b/rules/indexing/colon-all/cases/basic.py new file mode 100644 index 0000000..848e283 --- /dev/null +++ b/rules/indexing/colon-all/cases/basic.py @@ -0,0 +1,9 @@ +import numpy as np + +A = np.array([[1, 2, 3], [4, 5, 6]]) +v = A.ravel(order="F") # 1 4 2 5 3 6 +total = A.sum() +B = A.copy() +B[:] = 0 +C = A.copy() +C[:] = np.arange(1, 7).reshape(C.shape, order="F") # fills column by column diff --git a/rules/indexing/colon-all/rule.yaml b/rules/indexing/colon-all/rule.yaml new file mode 100644 index 0000000..c17368a --- /dev/null +++ b/rules/indexing/colon-all/rule.yaml @@ -0,0 +1,38 @@ +id: indexing/colon-all +title: "`A(:)`: all elements as one column" +status: mechanical +dialects: [octave, matlab] +match: [index:colon-all] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:method:ravel + - py:method:flatten + - py:method:reshape +octave: | + v = A(:); % column, column-major + A(:) = 0; +python: | + v = A.ravel(order="F") + A[:] = 0 +why: > + `A(:)` reshapes `A` into one column by walking down the columns first. + NumPy's `ravel`/`flatten` default to row-major order; pass `order="F"` to + match. As an assignment target, `A(:) = value` fills every element and keeps + the shape, which is `A[:] = value`. +pitfalls: + - >- + `A(:)` is an Nx1 column, `ravel` gives a 1-D array; reshape with + `.reshape(-1, 1, order="F")` only when a 2-D column is really needed. + - >- + `ravel` may return a view, so writing into it can change `A`; use + `flatten(order="F")` when a copy is intended. + - >- + `A(:) = 1:6` fills column by column: + `np.arange(1, 7).reshape(A.shape, order="F")`. + - >- + `A(:, 1)` is a different use: the colon there means all rows, `A[:, 0]`. + - >- + `sum(A(:))` is just `A.sum()`; the order does not matter for a sum. +related: [indexing/one-based, indexing/logical] +python_imports: [import numpy as np] diff --git a/rules/indexing/colon-all/translate.py b/rules/indexing/colon-all/translate.py new file mode 100644 index 0000000..58e7298 --- /dev/null +++ b/rules/indexing/colon-all/translate.py @@ -0,0 +1,115 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for indexing/colon-all: ``A(:)`` and ``A(:) = v``. + +Reading ``A(:)`` walks the columns first: ``A.ravel(order="F")`` (a vector is +already 1-D). Assigning ``A(:) = v`` keeps ``A``'s shape: a scalar fills it, +an array is laid out column by column with +``v.reshape(A.shape, order="F")``. ``sum(A(:))`` and friends are handled by +builtins/sum-mean-max as a plain ``A.sum()``. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.lift import LiftContext + + +def colon_all(target: ir.Expr, ctx: Context, *, store: bool) -> ast.expr: + """``A(:)`` as a value (or, with ``store``, as the target ``A[:]``).""" + info = ctx.info(target) + expr = ctx.expr(target) + if store: + return ast.Subscript(value=expr, slice=ast.Slice()) + if info.is_matrix: + return ctx.method(expr, "ravel", order=ast.Constant("F")) + if info.is_vector: + return expr + ctx.decline("x(:) of a value whose shape is unknown") + + +def translate(node: ir.Index, ctx: Context) -> ast.expr: + """``A(:)`` read as a value.""" + return colon_all(node.target, ctx, store=False) + + +def translate_store(stmt: ir.Assign, ctx: Context) -> list[Line]: + """``A(:) = v``: fill ``A`` in column-major order, keeping its shape.""" + target = stmt.targets[0] + assert isinstance(target, ir.Index) + info = ctx.info(target.target) + value = ctx.info(stmt.value) + name = ctx.expr(target.target) + lhs = colon_all(target.target, ctx, store=True) + if info.int_dtype and not (value.integer and value.is_real): + ctx.decline("storing possibly fractional values into an integer array") + rhs = ctx.expr(stmt.value) + if value.is_scalar or info.is_vector: + return [ctx.line(f"{ast.unparse(lhs)} = {ast.unparse(rhs)}")] + if info.is_matrix: + shape = ast.Attribute(value=name, attr="shape") + laid_out = ctx.method(rhs, "reshape", shape, order=ast.Constant("F")) + return [ctx.line(f"{ast.unparse(lhs)} = {ast.unparse(laid_out)}")] + ctx.decline("A(:) = v with A of unknown shape") + + +# --- Python -> .m ------------------------------------------------------------ +# +# A.ravel(order="F") walks the columns: A(:).', a row like every 1-D array. +# The default (row-major) A.ravel() is reshape(A.', 1, []). v.reshape(shape, +# order="F") fills column by column, as reshape does on the .m side; the +# default row-major order fills rows, which is declined. + + +def _order(node: ast.Call) -> str: + for keyword in node.keywords: + if keyword.arg == "order" and isinstance(keyword.value, ast.Constant): + return str(keyword.value.value) + return "C" + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``.ravel()``, ``.flatten()`` and ``.reshape(...)``.""" + assert isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute) + loc = ctx.loc(node) + method = node.func.attr + receiver = node.func.value + info = ctx.info(receiver) + if any(k.arg != "order" for k in node.keywords): + ctx.decline(f"{method} with these options") + order = _order(node) + if method in ("ravel", "flatten"): + if node.args: + ctx.decline(f"{method} with arguments") + if info.is_vector: + return ctx.expr(receiver) + if not info.is_matrix: + ctx.decline(f"{method} of a value whose dimensions are unknown") + value = ctx.expr(receiver) + if order == "F": + return ctx.transpose(ir.Index(loc=loc, target=value, args=[ir.Colon(loc=loc)])) + if order == "C": + empty = ir.Matrix(loc=loc, rows=[]) + return ctx.call("reshape", ctx.transpose(value), ctx.num(1), empty, loc=loc) + ctx.decline(f"order={order!r}") + if method == "reshape": + if order != "F": + ctx.decline("a row-major reshape (the .m reshape fills columns)") + if len(node.args) == 1: + shape = node.args[0] + if isinstance(shape, ast.Attribute) and shape.attr == "shape": + if not ctx.info(shape.value).is_matrix: + ctx.decline("reshaping to the shape of a value that is not 2-D") + dims: list[ir.Expr] = [ctx.call("size", ctx.expr(shape.value), loc=loc)] + elif isinstance(shape, ast.Tuple) and len(shape.elts) == 2: + dims = [ctx.expr(e) for e in shape.elts] + else: + ctx.decline("reshape to this shape") + elif len(node.args) == 2: + dims = [ctx.expr(e) for e in node.args] + else: + ctx.decline("reshape to this shape") + return ctx.call("reshape", ctx.expr(receiver), *dims, loc=loc) + ctx.decline(f"method {method}") diff --git a/rules/indexing/end-in-index/cases/basic.m b/rules/indexing/end-in-index/cases/basic.m new file mode 100644 index 0000000..9fed114 --- /dev/null +++ b/rules/indexing/end-in-index/cases/basic.m @@ -0,0 +1,8 @@ +x = [3 1 4 1 5 9 2 6]; +last = x(end); +tail = x(end-2:end); +before_last = x(end-1); +A = [1 2 3 4; 5 6 7 8; 9 10 11 12]; +corner = A(end, end); +last_col = A(:, end); +last_row_head = A(end, 1:2); diff --git a/rules/indexing/end-in-index/cases/basic.py b/rules/indexing/end-in-index/cases/basic.py new file mode 100644 index 0000000..149e47a --- /dev/null +++ b/rules/indexing/end-in-index/cases/basic.py @@ -0,0 +1,10 @@ +import numpy as np + +x = np.array([3, 1, 4, 1, 5, 9, 2, 6]) +last = x[-1] +tail = x[-3:] +before_last = x[-2] +A = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) +corner = A[-1, -1] +last_col = A[:, -1] +last_row_head = A[-1, :2] diff --git a/rules/indexing/end-in-index/cases/nested.m b/rules/indexing/end-in-index/cases/nested.m new file mode 100644 index 0000000..82c6cb7 --- /dev/null +++ b/rules/indexing/end-in-index/cases/nested.m @@ -0,0 +1,6 @@ +x = [10 20 30 40 50 60]; +idx = [2 4 6]; +v = x(idx(end)); % end is numel(idx) here, so this is x(6) +n = 2; +w = x(end - n); % end is numel(x): x(4) +% dualect: index idx diff --git a/rules/indexing/end-in-index/cases/nested.py b/rules/indexing/end-in-index/cases/nested.py new file mode 100644 index 0000000..807b11c --- /dev/null +++ b/rules/indexing/end-in-index/cases/nested.py @@ -0,0 +1,7 @@ +import numpy as np + +x = np.array([10, 20, 30, 40, 50, 60]) +idx = np.array([1, 3, 5]) # positions, 0-based +v = x[idx[-1]] # -1 refers to idx here +n = 2 +w = x[-1 - n] diff --git a/rules/indexing/end-in-index/rule.yaml b/rules/indexing/end-in-index/rule.yaml new file mode 100644 index 0000000..6c8f1d9 --- /dev/null +++ b/rules/indexing/end-in-index/rule.yaml @@ -0,0 +1,32 @@ +id: indexing/end-in-index +title: "`end` inside an index expression" +status: mechanical +dialects: [octave, matlab] +match: [index:end] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:index:negative +octave: | + last = x(end); + tail = x(end-2:end); +python: | + last = x[-1] + tail = x[-3:] +why: > + Inside an index, `end` is the length of the dimension being indexed and + ranges include their stop. Python uses negative indices and exclusive slice + stops: `x(end - k)` is `x[-1 - k]`, and `end-2:end` is three elements, so the + Python start is `-3`, not `-2`. +pitfalls: + - >- + `x(end+1) = v` grows the array in Octave; NumPy raises IndexError. See + indexing/grow-on-assign. + - >- + In nested indexing `end` binds to the innermost array being indexed: + in `x(idx(end))` it is the length of `idx`. + - >- + In `A(end, 1)` and `A(1, end)`, `end` is the size of that particular + dimension: `A[-1, 0]`, `A[0, -1]`. +related: [indexing/one-based, indexing/ranges, indexing/grow-on-assign] +python_imports: [] diff --git a/rules/indexing/end-in-index/translate.py b/rules/indexing/end-in-index/translate.py new file mode 100644 index 0000000..41c5113 --- /dev/null +++ b/rules/indexing/end-in-index/translate.py @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for indexing/end-in-index: ``end`` inside a subscript. + +At the top of a subscript, ``end`` and ``end - k`` become negative Python +indices (``-1``, ``-1 - k``); :func:`end_offset` recognizes those forms for the +indexing and range translators. Anywhere else inside a subscript +(``x(round(end / 2))``) ``end`` is a number: the length of the dimension being +indexed, which :func:`translate` gives as ``x.size`` or ``x.shape[d]``. +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.lift import LiftContext + + +def end_offset(node: ir.Expr) -> int | None: + """``k`` when ``node`` is ``end`` (0) or ``end - k`` with a literal ``k``.""" + if isinstance(node, ir.End): + return 0 + if ( + isinstance(node, ir.BinOp) + and node.op == "minus" + and isinstance(node.left, ir.End) + and isinstance(node.right, ir.Num) + and isinstance(node.right.value, int) + and node.right.value >= 0 + ): + return node.right.value + return None + + +def end_minus(node: ir.Expr) -> ir.Expr | None: + """The ``k`` expression of ``end - k`` (any ``k``), else ``None``.""" + if isinstance(node, ir.BinOp) and node.op == "minus" and isinstance(node.left, ir.End): + return node.right + return None + + +def translate(node: ir.End, ctx: Context) -> ast.expr: + """``end`` as a number: the extent of the dimension it indexes.""" + target = ctx.expr(node.target) + info = ctx.info(node.target) + if node.ndims == 1: + if info.kind.value == "string": + return ctx.call(ast.Name(id="len"), target) + return ast.Attribute(value=target, attr="size") + if node.ndims == 2 and info.is_matrix: + return ast.Subscript( + value=ast.Attribute(value=target, attr="shape"), slice=ast.Constant(node.dim) + ) + ctx.decline("end in a subscript of an array whose dimensions are unknown") + + +# --- Python -> .m ------------------------------------------------------------ +# +# A negative Python index counts from the end: x[-1] is x(end), x[-k] is +# x(end - k + 1), x[-1 - n] is x(end - n). + + +def from_end(node: ast.expr, target: ir.Expr, dim: int, ndims: int, ctx: LiftContext) -> ir.Expr: + """The 1-based position of a negative Python index: ``end + 1 + index``, folded.""" + end = ir.End(loc=ctx.loc(node), target=target, dim=dim, ndims=ndims) + if isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.USub): + inner = node.operand + if isinstance(inner, ast.Constant) and isinstance(inner.value, int): + return ctx.shift(end, 1 - inner.value) + return ctx.shift(ctx.binop("minus", end, ctx.expr(inner)), 1) + if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Add | ast.Sub): + head = from_end(node.left, target, dim, ndims, ctx) + op = "plus" if isinstance(node.op, ast.Add) else "minus" + right = node.right + if isinstance(right, ast.Constant) and isinstance(right.value, int): + return ctx.shift(head, right.value if op == "plus" else -right.value) + return ctx.binop(op, head, ctx.expr(right)) + ctx.decline("a negative index of this form") + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """Never reached directly: negative indices are part of a subscript.""" + ctx.decline("a negative index outside a subscript") diff --git a/rules/indexing/grow-on-assign/cases/basic.m b/rules/indexing/grow-on-assign/cases/basic.m new file mode 100644 index 0000000..6f780c4 --- /dev/null +++ b/rules/indexing/grow-on-assign/cases/basic.m @@ -0,0 +1,8 @@ +x = [1 2 3]; +x(end+1) = 4; +y = []; +for k = 1:4 + y(end+1) = k^2; +end +z = [1 2]; +z(5) = 9; % the gap is filled with zeros diff --git a/rules/indexing/grow-on-assign/cases/basic.py b/rules/indexing/grow-on-assign/cases/basic.py new file mode 100644 index 0000000..91a48c3 --- /dev/null +++ b/rules/indexing/grow-on-assign/cases/basic.py @@ -0,0 +1,11 @@ +import numpy as np + +x = np.array([1, 2, 3]) +x = np.append(x, 4) +squares = [] +for k in range(1, 5): + squares.append(k**2) +y = np.array(squares) +z = np.zeros(5) +z[:2] = [1, 2] +z[4] = 9 diff --git a/rules/indexing/grow-on-assign/cases/matrix.m b/rules/indexing/grow-on-assign/cases/matrix.m new file mode 100644 index 0000000..7395b8b --- /dev/null +++ b/rules/indexing/grow-on-assign/cases/matrix.m @@ -0,0 +1,2 @@ +A = eye(2); +A(2, 4) = 1; % A becomes 2x4; the new column 3 is zeros diff --git a/rules/indexing/grow-on-assign/cases/matrix.py b/rules/indexing/grow-on-assign/cases/matrix.py new file mode 100644 index 0000000..df9ebde --- /dev/null +++ b/rules/indexing/grow-on-assign/cases/matrix.py @@ -0,0 +1,4 @@ +import numpy as np + +A = np.pad(np.eye(2), ((0, 0), (0, 2))) # two zero columns on the right +A[1, 3] = 1 diff --git a/rules/indexing/grow-on-assign/rule.yaml b/rules/indexing/grow-on-assign/rule.yaml new file mode 100644 index 0000000..277bc74 --- /dev/null +++ b/rules/indexing/grow-on-assign/rule.yaml @@ -0,0 +1,36 @@ +id: indexing/grow-on-assign +title: "Growing an array by assigning past its end" +status: guided +dialects: [octave, matlab] +match: [assign:grow] +from_python: # the Python -> .m direction + status: guided + match: + - py:method:append + - py:call:np.append + - py:call:np.pad +octave: | + x(end+1) = v; + y(5) = 1; % pads with zeros +python: | + x = np.append(x, v) + y = np.zeros(5) + y[4] = 1 +why: > + Assigning past the end grows an Octave array, filling any gap with zeros. + NumPy arrays have a fixed size and raise IndexError instead. Collect values + in a Python list and convert once, or preallocate with `np.zeros` when the + final size is known; `np.append` copies the whole array on every call. +pitfalls: + - >- + `y = []` followed by `y(end+1) = v` in a loop becomes a list with + `.append(v)` and `np.array(values)` after the loop, not repeated + `np.append`. + - >- + Assigning past the edge of a matrix adds zero-filled rows/columns: + `A(2, 4) = 1` on a 2x2 makes it 2x4 (`np.pad`, or preallocate). + - >- + `x(end+1) = v` on `[]` creates a row; on a column vector it extends the + column. +related: [indexing/end-in-index, builtins/zeros-ones-eye] +python_imports: [import numpy as np] diff --git a/rules/indexing/logical/cases/basic.m b/rules/indexing/logical/cases/basic.m new file mode 100644 index 0000000..d5b260b --- /dev/null +++ b/rules/indexing/logical/cases/basic.m @@ -0,0 +1,8 @@ +x = [-2 5 0 3 -1 8]; +mask = x > 2; +big = x(mask); +y = x; +y(y < 0) = 0; % x is unchanged: y is a copy +z = x; +z(z < 0) = []; % deletion +n_big = sum(mask); diff --git a/rules/indexing/logical/cases/basic.py b/rules/indexing/logical/cases/basic.py new file mode 100644 index 0000000..f69e95a --- /dev/null +++ b/rules/indexing/logical/cases/basic.py @@ -0,0 +1,10 @@ +import numpy as np + +x = np.array([-2, 5, 0, 3, -1, 8]) +mask = x > 2 +big = x[mask] +y = x.copy() # without copy, the next line would also change x +y[y < 0] = 0 +z = x +z = z[~(z < 0)] # deletion keeps the complement +n_big = np.count_nonzero(mask) diff --git a/rules/indexing/logical/cases/matrix-order.m b/rules/indexing/logical/cases/matrix-order.m new file mode 100644 index 0000000..8818d37 --- /dev/null +++ b/rules/indexing/logical/cases/matrix-order.m @@ -0,0 +1,2 @@ +A = [1 5; 7 2; 3 9]; +B = A(A > 2); % a column, in column-major order: 7 3 5 9 diff --git a/rules/indexing/logical/cases/matrix-order.py b/rules/indexing/logical/cases/matrix-order.py new file mode 100644 index 0000000..6d15ebe --- /dev/null +++ b/rules/indexing/logical/cases/matrix-order.py @@ -0,0 +1,4 @@ +import numpy as np + +A = np.array([[1, 5], [7, 2], [3, 9]]) +B = A.T[A.T > 2] # column-major order: 7 3 5 9 (A[A > 2] gives 5 7 3 9) diff --git a/rules/indexing/logical/rule.yaml b/rules/indexing/logical/rule.yaml new file mode 100644 index 0000000..d480510 --- /dev/null +++ b/rules/indexing/logical/rule.yaml @@ -0,0 +1,36 @@ +id: indexing/logical +title: "Logical (mask) indexing" +status: mechanical +dialects: [octave, matlab] +match: [index:logical, index:delete] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:index:mask +octave: | + big = x(x > 2); + x(x < 0) = 0; + B = A(A > 2); % column, column-major order +python: | + big = x[x > 2] + x[x < 0] = 0 + B = A.T[A.T > 2] # column-major order, as in Octave +why: > + A logical mask selects the elements where it is true, in both languages. On + a matrix, Octave returns them as a column in column-major order; NumPy + returns a 1-D array in row-major order. The same elements then come out in a + different order unless you index the transpose (or `ravel(order="F")`). +pitfalls: + - >- + A mask of numbers is not a logical mask: `x([1 0 1])` is an index error in + Octave (index 0), while NumPy's `x[np.array([1, 0, 1])]` silently picks + positions 1, 0, 1. Masks must be `bool` arrays. + - >- + `x(mask) = []` deletes elements: `x = x[~mask]`. + - >- + `y = x; y(m) = 0` leaves `x` alone in Octave (copy on write); in NumPy write + `y = x.copy()` first or `x` changes too. + - >- + Combine masks with `&`/`|` and parenthesize comparisons: `(x > 1) & (x < 3)`. +related: [operators/short-circuit, builtins/find, indexing/colon-all] +python_imports: [import numpy as np] diff --git a/rules/indexing/logical/translate.py b/rules/indexing/logical/translate.py new file mode 100644 index 0000000..a627afb --- /dev/null +++ b/rules/indexing/logical/translate.py @@ -0,0 +1,116 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for indexing/logical: masks, mask assignment, deletion. + +On a vector a mask selects the same elements in the same order: +``x[mask]``. On a matrix the source walks columns first, so the selection is +taken from the transposes, ``A.T[M.T]`` (a comparison of ``A`` with a scalar +is transposed inside: ``A.T[A.T > 2]``). Deleting with ``x(m) = []`` keeps +the complement, ``x = x[~m]``; deleting positions uses ``np.delete``. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.lift import LiftContext + + +def _transposed_mask(mask: ir.Expr, target: ir.Expr, ctx: Context) -> ast.expr: + """``M.T``, pushed into ``A op scalar`` when ``A`` is the indexed matrix.""" + if ( + isinstance(mask, ir.BinOp) + and mask.op in ir.COMPARISONS + and isinstance(target, ir.Name) + and ctx.info(mask.right).is_scalar + and isinstance(mask.left, ir.Name) + and mask.left.id == target.id + ): + left = ast.Attribute(value=ctx.expr(mask.left), attr="T") + compared = ctx.expr(mask) + assert isinstance(compared, ast.Compare) + return ast.Compare(left=left, ops=compared.ops, comparators=compared.comparators) + return ast.Attribute(value=ctx.expr(mask), attr="T") + + +def select(target: ir.Expr, mask: ir.Expr, ctx: Context) -> ast.expr: + """``target(mask)`` for a single logical subscript, as a value or a store target.""" + info = ctx.info(target) + mask_info = ctx.info(mask) + base = ctx.expr(target) + if info.is_matrix: + if not mask_info.is_matrix: + ctx.decline("a matrix indexed with a mask that is not a matrix") + return ast.Subscript( + value=ast.Attribute(value=base, attr="T"), slice=_transposed_mask(mask, target, ctx) + ) + if not info.is_vector: + ctx.assume(f"{ast.unparse(base)} is a vector") + return ast.Subscript(value=base, slice=ctx.expr(mask)) + + +def translate(node: ir.Index, ctx: Context) -> ast.expr: + """``x(mask)`` read as a value.""" + if len(node.args) != 1: + ctx.decline("a mask in a two-subscript index") + return select(node.target, node.args[0], ctx) + + +def translate_delete(stmt: ir.Assign, ctx: Context) -> list[Line]: + """``x(m) = []``: keep everything else.""" + target = stmt.targets[0] + assert isinstance(target, ir.Index) + if not isinstance(target.target, ir.Name) or len(target.args) != 1: + ctx.decline("deleting from a matrix or with two subscripts") + name = target.target.id + info = ctx.info(target.target) + if not info.is_vector: + ctx.decline("deleting from a value that is not known to be a vector") + arg = target.args[0] + arg_info = ctx.info(arg) + if arg_info.is_logical: + keep = ast.UnaryOp(op=ast.Invert(), operand=ctx.expr(arg)) + return [ctx.line(f"{name} = {name}[{ast.unparse(keep)}]")] + positions = ctx.module("indexing/one-based").subscript(arg, ctx) + if isinstance(positions, ast.Slice): + ctx.decline("deleting a range") + deleted = ctx.call(ctx.np("delete"), ast.Name(name), positions) + return [ctx.line(f"{name} = {ast.unparse(deleted)}")] + + +# --- Python -> .m ------------------------------------------------------------ +# +# x[mask] on a 1-D array is x(mask). A 2-D mask selects in row order in NumPy +# and in column order on the .m side, so A[A > 2] is declined; the idiom +# A.T[A.T > 2] (column order, which dualect itself writes) is A(A > 2).'. + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """Never reached directly: a mask is part of a subscript (indexing/one-based).""" + ctx.decline("a mask outside a subscript") + + +def lift_transposed_mask(node: ast.Subscript, ctx: LiftContext) -> ir.Expr: + """``A.T[A.T op s]``: the column-order selection ``A(A op s).'``.""" + value = node.value + mask = node.slice + assert isinstance(value, ast.Attribute) + matrix = value.value + if ( + isinstance(matrix, ast.Name) + and ctx.info(matrix).is_matrix + and isinstance(mask, ast.Compare) + and len(mask.ops) == 1 + and isinstance(mask.left, ast.Attribute) + and mask.left.attr == "T" + and isinstance(mask.left.value, ast.Name) + and mask.left.value.id == matrix.id + and ctx.info(mask.comparators[0]).is_scalar + ): + compare = ast.Compare(left=mask.left.value, ops=mask.ops, comparators=mask.comparators) + ast.copy_location(compare, mask) + ctx.analysis.infos[id(compare)] = ctx.info(mask) + target = ir.Index(loc=ctx.loc(node), target=ctx.expr(matrix), args=[ctx.expr(compare)]) + return ctx.transpose(target) + ctx.decline("indexing a transposed array") diff --git a/rules/indexing/one-based/cases/basic.m b/rules/indexing/one-based/cases/basic.m new file mode 100644 index 0000000..0ea0b90 --- /dev/null +++ b/rules/indexing/one-based/cases/basic.m @@ -0,0 +1,9 @@ +x = [10 20 30 40]; +A = [1 2 3; 4 5 6]; +first = x(1); +last = x(4); +a23 = A(2, 3); +k4 = A(4); % linear index walks columns: this is A(2, 2) +i = 2; +nxt = x(i + 1); +% dualect: index i diff --git a/rules/indexing/one-based/cases/basic.py b/rules/indexing/one-based/cases/basic.py new file mode 100644 index 0000000..57393c3 --- /dev/null +++ b/rules/indexing/one-based/cases/basic.py @@ -0,0 +1,10 @@ +import numpy as np + +x = np.array([10, 20, 30, 40]) +A = np.array([[1, 2, 3], [4, 5, 6]]) +first = x[0] +last = x[3] +a23 = A[1, 2] +k4 = A.ravel(order="F")[3] # linear index walks columns: this is A[1, 1] +i = 1 +nxt = x[i + 1] diff --git a/rules/indexing/one-based/rule.yaml b/rules/indexing/one-based/rule.yaml new file mode 100644 index 0000000..c197b54 --- /dev/null +++ b/rules/indexing/one-based/rule.yaml @@ -0,0 +1,36 @@ +id: indexing/one-based +title: "One-based indexing and column-major linear indices" +status: mechanical +dialects: [octave, matlab] +match: [index:paren, index:colon] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:subscript + - py:assign-store +octave: | + first = x(1); + a23 = A(2, 3); + k4 = A(4); % linear index, column-major +python: | + first = x[0] + a23 = A[1, 2] + k4 = A.ravel(order="F")[3] +why: > + Octave counts from 1 and NumPy from 0, so every index drops by one. A single + (linear) index into a matrix walks down the columns first (column-major); + NumPy's default order is row-major, so use `ravel(order="F")` or + `np.unravel_index(k, A.shape, order="F")` to reach the same element. +pitfalls: + - >- + Shift computed indices once, where the index value is created, not at each + use: a loop counter that runs 1..n becomes 0..n-1, and `x(i + 1)` stays + `x[i + 1]`. + - >- + `x(0)` is an error in Octave, but `x[-1]` is valid NumPy (the last element), + so an off-by-one in translation can fail silently. + - >- + Indices returned by functions (`find`, `max`, `sort`) are 1-based too; see + builtins/find and builtins/sum-mean-max. +related: [indexing/ranges, indexing/end-in-index, builtins/find] +python_imports: [import numpy as np] diff --git a/rules/indexing/one-based/translate.py b/rules/indexing/one-based/translate.py new file mode 100644 index 0000000..b345b22 --- /dev/null +++ b/rules/indexing/one-based/translate.py @@ -0,0 +1,348 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for indexing/one-based: ``x(i)``, ``A(i, j)``, and stores into them. + +Every subscript drops by one, with constants folded (``x(i + 1)`` is +``x[i]``); variables the emitter stores 0-based (they only hold positions) need +no shift at all. A single subscript into a matrix is a column-major linear +index: ``A.ravel(order="F")[k]``. Ranges become slices +(:mod:`indexing/ranges`), ``end`` a negative index (:mod:`indexing/end-in-index`). +A row or column vector indexed with two subscripts drops its singleton one. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line, offset +from dualect.infer import Info, Kind +from dualect.lift import LiftContext + + +def position_value(node: ir.Expr, ctx: Context) -> ast.expr: + """The source (1-based) value of a subscript expression, in Python.""" + ends = ctx.module("indexing/end-in-index") + if ends.end_offset(node) is not None: + ctx.decline("end used as a number here") + return ctx.expr(node) + + +def zero_based(node: ir.Expr, ctx: Context) -> ast.expr: + """A 1-based scalar position as a 0-based Python index (``end - k`` is ``-1 - k``).""" + ends = ctx.module("indexing/end-in-index") + end_off = ends.end_offset(node) + if end_off is not None: + return ctx.const(-1 - end_off) + k = ends.end_minus(node) + if k is not None: + return ast.BinOp(left=ctx.const(-1), op=ast.Sub(), right=ctx.expr(k)) + if isinstance(node, ir.Name) and ctx.is_index_var(node.id): + return ast.Name(id=node.id) + if _holds_positions(node, ctx): + # An element of a 0-based position array is already a Python index. + assert isinstance(node, ir.Index) + return indexed(node.target, node.args, ctx, store=False) + return offset(ctx.expr(node), -1) + + +def _holds_positions(node: ir.Expr, ctx: Context) -> bool: + """``idx(k)`` where ``idx`` is stored 0-based.""" + return ( + isinstance(node, ir.Index) + and isinstance(node.target, ir.Name) + and ctx.is_index_var(node.target.id) + ) + + +def subscript(node: ir.Expr, ctx: Context) -> ast.expr: + """One subscript as a Python index: a slice, a 0-based position or positions.""" + if isinstance(node, ir.Colon): + return ast.Slice() + if isinstance(node, ir.Range): + return ctx.module("indexing/ranges").to_slice(node, ctx) + info = ctx.info(node) + if ( + isinstance(node, ir.Call) + and node.func == "find" + and len(node.args) == 1 + and ctx.info(node.args[0]).is_logical + and ctx.info(node.args[0]).is_vector + ): + # x(find(mask)) selects the same elements as the mask itself. + return ctx.expr(node.args[0]) + if info.is_logical and not info.is_scalar: + # A mask in a two-subscript index (`A(mask, :)`) is a NumPy boolean index. + ctx.module("indexing/logical") + return ctx.expr(node) + if isinstance(node, ir.Matrix) and info.is_array: + items = [item for row in node.rows for item in row] + if all(isinstance(i, ir.Num) and isinstance(i.value, int) for i in items): + return ast.List(elts=[ctx.const(i.value - 1) for i in items if isinstance(i, ir.Num)]) + if info.kind is Kind.UNKNOWN or (info.elem.value == "unknown" and not info.is_scalar): + ctx.assume(f"numeric positions in {ast.unparse(ctx.expr(node))}") + return zero_based(node, ctx) + + +def _is_mask(node: ir.Expr, ctx: Context) -> bool: + info = ctx.info(node) + return info.is_logical and not info.is_scalar + + +def _is_one(node: ir.Expr) -> bool: + return isinstance(node, ir.Num) and node.value == 1 + + +def _vector_subscript(node: ir.Expr, ctx: Context) -> bool: + """A subscript that selects several positions by value (fancy indexing).""" + if isinstance(node, ir.Colon | ir.Range): + return False + return not ctx.info(node).is_scalar + + +def indexed(target: ir.Expr, args: list[ir.Expr], ctx: Context, *, store: bool) -> ast.expr: + """``target(args)`` as a Python subscript expression.""" + info: Info = ctx.info(target) + if isinstance(target, ir.Name) and ctx.is_index_var(target.id): + base: ast.expr = ast.Name(id=target.id) # index the stored positions themselves + else: + base = ctx.expr(target) + name = ast.unparse(base) + if info.kind is Kind.STRING: + if store: + ctx.decline("assigning into a string (Python strings are immutable)") + if len(args) != 1: + ctx.decline("a string with two subscripts") + return ast.Subscript(value=base, slice=subscript(args[0], ctx)) + if info.kind in (Kind.FUNC, Kind.CELL): + ctx.decline("indexing a function handle or cell") + if len(args) == 1 and isinstance(args[0], ir.Colon): + return ctx.module("indexing/colon-all").colon_all(target, ctx, store=store) + if len(args) == 1 and _is_mask(args[0], ctx): + return ctx.module("indexing/logical").select(target, args[0], ctx) + if len(args) == 1: + if info.is_matrix: + if store: + ctx.decline("a linear-index assignment into a matrix") + base = ctx.method(base, "ravel", order=ast.Constant("F")) + elif info.kind in (Kind.UNKNOWN, Kind.ARRAY): + ctx.assume(f"{name} is a vector") + return ast.Subscript(value=base, slice=subscript(args[0], ctx)) + if len(args) == 2: + first, second = args + if info.kind is Kind.ROW and _is_one(first): + return ast.Subscript(value=base, slice=subscript(second, ctx)) + if info.kind is Kind.COL and _is_one(second): + return ast.Subscript(value=base, slice=subscript(first, ctx)) + if info.is_vector or info.is_scalar: + ctx.decline("two subscripts into a vector") + if not info.is_matrix: + ctx.assume(f"{name} is a matrix") + if _vector_subscript(first, ctx) and _vector_subscript(second, ctx): + ctx.decline("position vectors in both dimensions (needs np.ix_)") + return ast.Subscript( + value=base, slice=ast.Tuple(elts=[subscript(first, ctx), subscript(second, ctx)]) + ) + ctx.decline("more than two subscripts") + + +def translate(node: ir.Index, ctx: Context) -> ast.expr: + """``x(i)`` read as a value.""" + result = indexed(node.target, node.args, ctx, store=False) + if _holds_positions(node, ctx): + # The stored positions are 0-based; the source value is one more. + return ast.BinOp(left=result, op=ast.Add(), right=ast.Constant(1)) + return result + + +def translate_store(stmt: ir.Assign, ctx: Context) -> list[Line]: + """``x(i) = v``: an element (or slice) assignment.""" + target = stmt.targets[0] + assert isinstance(target, ir.Index) + if isinstance(stmt.value, ir.Matrix) and not stmt.value.rows: + return ctx.module("indexing/logical").translate_delete(stmt, ctx) + before = ctx.info(target.target) + value = ctx.info(stmt.value) + if before.int_dtype and not (value.integer and value.is_real): + ctx.decline("storing a possibly fractional value into an integer array would truncate") + if len(target.args) == 1 and isinstance(target.args[0], ir.Colon): + return ctx.module("indexing/colon-all").translate_store(stmt, ctx) + lhs = indexed(target.target, target.args, ctx, store=True) + rhs = ctx.arg(stmt.value) + return [ctx.line(f"{ast.unparse(lhs)} = {ast.unparse(rhs)}")] + + +# --- Python -> .m ------------------------------------------------------------ +# +# Every position rises by one: x[i] is x(i + 1), with constants folded +# (x[k - 1] is x(k)). A negative index counts from the end +# (indexing/end-in-index), a slice is a range (indexing/ranges), a boolean +# mask stays a mask (indexing/logical). A 1-D array is a row on the .m side, +# so a selection NumPy returns as 1-D from a column (A[:, j]) is transposed +# back into a row. A variable index that may be negative would count from +# the end in Python, so a non-negative index is assumed out loud unless known. + + +def _parts(node: ast.Subscript) -> list[ast.expr]: + return list(node.slice.elts) if isinstance(node.slice, ast.Tuple) else [node.slice] + + +def position(part: ast.expr, target: ir.Expr, dim: int, ndims: int, ctx: LiftContext) -> ir.Expr: + """One Python subscript as a 1-based ``.m`` subscript.""" + if isinstance(part, ast.Slice): + return ctx.module_for("indexing/ranges").slice_range(part, target, dim, ndims, ctx) + info = ctx.info(part) + if info.is_bool and not info.is_scalar: + ctx.module_for("indexing/logical") + return ctx.module_for("syntax/array-literals").lift_items(part, ctx) + if _negative(part): + return ctx.module_for("indexing/end-in-index").from_end(part, target, dim, ndims, ctx) + if isinstance(part, ast.List): + values = [e.value for e in part.elts if isinstance(e, ast.Constant)] + ints = [v for v in values if type(v) is int and v >= 0] + if len(ints) != len(part.elts): + ctx.decline("a list subscript that is not of non-negative integer literals") + return ir.Matrix(loc=ctx.loc(part), rows=[[ctx.num(v + 1) for v in ints]]) + if info.dtype.value not in ("int", "unknown") and not info.is_bool: + ctx.decline("a subscript that is not an integer") + if not info.nonneg: + ctx.assume(f"non-negative index {ast.unparse(part)}") + return ctx.shift(ctx.expr(part), 1) + + +def _negative(node: ast.expr) -> bool: + if isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.USub): + return True + if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Add | ast.Sub): + return _negative(node.left) + return False + + +def _is_whole(part: ast.expr) -> bool: + return ( + isinstance(part, ast.Slice) + and part.lower is None + and part.upper is None + and part.step is None + ) + + +def subscripted(node: ast.Subscript, ctx: LiftContext, *, store: bool) -> tuple[ir.Index, bool]: + """``node`` as an ``.m`` index, and whether the 1-D result must be turned back into a row.""" + loc = ctx.loc(node) + parts = _parts(node) + value = node.value + info = ctx.info(value) + if ( + isinstance(value, ast.Call) + and isinstance(value.func, ast.Attribute) + and value.func.attr == "ravel" + and not value.args + and [(k.arg, getattr(k.value, "value", None)) for k in value.keywords] == [("order", "F")] + and ctx.info(value.func.value).is_matrix + and len(parts) == 1 + and not isinstance(parts[0], ast.Slice) + and ctx.info(parts[0]).is_scalar + and not store + ): + # A.ravel(order="F")[k] walks the columns: the linear index A(k + 1). + matrix = ctx.expr(value.func.value) + index = ir.Index(loc=loc, target=matrix, args=[]) + index.args = [position(parts[0], matrix, 0, 1, ctx)] + return index, False + target = ctx.expr(value) + if not isinstance(target, ir.Name): + ctx.decline("indexing the result of an expression (needs a temporary)") + index = ir.Index(loc=loc, target=target, args=[]) + if info.kind.value == "string": + if len(parts) != 1 or store: + ctx.decline("this string subscript") + index.args = [position(parts[0], target, 0, 1, ctx)] + return index, False + if info.is_vector: + if len(parts) != 1: + ctx.decline("several subscripts into a 1-D array") + part = parts[0] + if _is_whole(part): + index.args = [ir.Colon(loc=ctx.loc(part))] + return index, not store # x(:) is a column + index.args = [position(part, target, 0, 1, ctx)] + return index, False + if not info.is_matrix: + ctx.decline("indexing a value whose dimensions are unknown") + if len(parts) == 1: + part = parts[0] + part_info = ctx.info(part) + if part_info.is_bool and part_info.is_matrix: + ctx.decline("a 2-D mask (NumPy selects in row order, the .m side in column order)") + parts = [part, ast.Slice()] + if len(parts) != 2: + ctx.decline("more than two subscripts") + kinds = [] + for part in parts: + part_info = ctx.info(part) + if isinstance(part, ast.Slice): + kinds.append("slice") + elif part_info.is_scalar: + kinds.append("int") + else: + kinds.append("array") + if kinds == ["array", "array"]: + ctx.decline("position arrays in both dimensions (NumPy pairs them up)") + index.args = [ + ir.Colon(loc=ctx.loc(p)) if _is_whole(p) else position(p, target, d, 2, ctx) + for d, p in enumerate(parts) + ] + # A[i, :] is 1-D in NumPy and a row on the .m side; A[:, j] is 1-D in NumPy + # but a column on the .m side, so it is transposed into the row it stands for. + column = kinds[1] == "int" and kinds[0] != "int" + return index, column and not store + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``x[i]``, ``A[i, j]`` and the other subscripts read as values.""" + assert isinstance(node, ast.Subscript) + parts = _parts(node) + value = node.value + alias = ctx.numpy + if any( + (isinstance(p, ast.Constant) and p.value is None) + or ( + isinstance(p, ast.Attribute) + and isinstance(p.value, ast.Name) + and p.value.id == alias + and p.attr == "newaxis" + ) + for p in parts + ): + return ctx.module_for("operators/arithmetic").lift_newaxis(node, ctx) + if isinstance(value, ast.Attribute) and value.attr == "shape": + return ctx.module_for("builtins/size-numel-length").lift_shape_index(node, ctx) + if ( + isinstance(value, ast.Call) + and isinstance(value.func, ast.Name) + and value.func.id in ctx.functions + ): + return ctx.module_for("functions/multiple-returns").lift_item(node, ctx) + if isinstance(value, ast.Call) and ctx.tag(value) == "py:call:np.flatnonzero": + return ctx.module_for("builtins/find").lift_subscript(node, ctx) + if isinstance(value, ast.Attribute) and value.attr == "T" and len(parts) == 1: + return ctx.module_for("indexing/logical").lift_transposed_mask(node, ctx) + index, transpose = subscripted(node, ctx, store=False) + return ctx.transpose(index) if transpose else index + + +def lift_store(stmt: ast.Assign, ctx: LiftContext) -> list[ir.Stmt]: + """``x[i] = v``: an element, slice or mask assignment.""" + target = stmt.targets[0] + assert isinstance(target, ast.Subscript) + base = ctx.info(target.value) + value = ctx.info(stmt.value) + if base.is_bool and not value.is_bool: + ctx.decline("storing numbers into a boolean array (NumPy converts them to True/False)") + if base.dtype.value == "int" and value.dtype.value not in ("int", "bool"): + ctx.decline("storing a possibly fractional value into an integer array (NumPy truncates)") + if value.dtype.value == "complex" and base.dtype.value != "complex": + ctx.decline("storing complex values into a real array (NumPy drops the imaginary part)") + index, _transpose = subscripted(target, ctx, store=True) + rhs = ctx.module_for("syntax/array-literals").lift_items(stmt.value, ctx) + return [ir.Assign(loc=ctx.loc(stmt), targets=[index], value=rhs)] diff --git a/rules/indexing/ranges/cases/basic.m b/rules/indexing/ranges/cases/basic.m new file mode 100644 index 0000000..75a847a --- /dev/null +++ b/rules/indexing/ranges/cases/basic.m @@ -0,0 +1,9 @@ +r = 1:5; +s = 0:0.25:1; +d = 5:-1:1; +e = 5:1; % empty +x = [10 20 30 40 50]; +part = x(2:4); +every_other = x(1:2:end); +rev = x(end:-1:1); +head = x(3:-1:1); diff --git a/rules/indexing/ranges/cases/basic.py b/rules/indexing/ranges/cases/basic.py new file mode 100644 index 0000000..4290cf0 --- /dev/null +++ b/rules/indexing/ranges/cases/basic.py @@ -0,0 +1,11 @@ +import numpy as np + +r = np.arange(1, 6) +s = np.linspace(0, 1, 5) +d = np.arange(5, 0, -1) +e = np.arange(5, 2) # empty +x = np.array([10, 20, 30, 40, 50]) +part = x[1:4] +every_other = x[::2] +rev = x[::-1] +head = x[2::-1] diff --git a/rules/indexing/ranges/cases/float-step.m b/rules/indexing/ranges/cases/float-step.m new file mode 100644 index 0000000..2ff9fa0 --- /dev/null +++ b/rules/indexing/ranges/cases/float-step.m @@ -0,0 +1,4 @@ +% A fractional step: count the points instead of trusting float arithmetic. +t = 0:0.1:1; +n = numel(t); +t_last = t(end); diff --git a/rules/indexing/ranges/cases/float-step.py b/rules/indexing/ranges/cases/float-step.py new file mode 100644 index 0000000..c77c1ea --- /dev/null +++ b/rules/indexing/ranges/cases/float-step.py @@ -0,0 +1,6 @@ +# A fractional step: count the points instead of trusting float arithmetic. +import numpy as np + +t = np.linspace(0, 1, 11) # floor((1 - 0) / 0.1) + 1 points +n = t.size +t_last = t[-1] diff --git a/rules/indexing/ranges/rule.yaml b/rules/indexing/ranges/rule.yaml new file mode 100644 index 0000000..c694731 --- /dev/null +++ b/rules/indexing/ranges/rule.yaml @@ -0,0 +1,39 @@ +id: indexing/ranges +title: "Colon ranges `a:b` and `a:step:b`" +status: mechanical +dialects: [octave, matlab] +match: [expr:range] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:index:slice + - py:call:np.arange +octave: | + r = 1:5; + s = 0:0.25:1; + d = 5:-1:1; + part = x(2:4); +python: | + r = np.arange(1, 6) + s = np.linspace(0, 1, 5) + d = np.arange(5, 0, -1) + part = x[1:4] +why: > + `a:b` includes `b`; `np.arange` and slices exclude their stop. As a value, + `a:b` is `np.arange(a, b + 1)`. As an index, `x(i:j)` is `x[i-1:j]`: the start + shifts by one and the stop does not. With a fractional step, use + `np.linspace(a, b, n)` with `n = floor((b - a) / step) + 1`, because + `np.arange` with a float step can gain or lose the end point to rounding. +pitfalls: + - >- + A descending range needs an explicit negative step in both languages: `5:1` + is empty, `5:-1:1` is not. As a value it is `np.arange(5, 0, -1)`; as an + index `x(5:-1:1)` is `x[4::-1]`, because a stop of `-1` would mean the last + element. + - >- + A range is a 1xN row in Octave and a 1-D array in NumPy; transposing a 1-D + array does nothing (see operators/transpose). + - >- + `x(1:2:end)` is `x[::2]` and `x(end:-1:1)` is `x[::-1]`. +related: [indexing/one-based, indexing/end-in-index, builtins/linspace] +python_imports: [import numpy as np] diff --git a/rules/indexing/ranges/translate.py b/rules/indexing/ranges/translate.py new file mode 100644 index 0000000..9bdffcd --- /dev/null +++ b/rules/indexing/ranges/translate.py @@ -0,0 +1,173 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for indexing/ranges: ``a:b`` and ``a:step:b``. + +As a value, an integer range is ``np.arange(a, b + 1)`` (the stop moves past +the inclusive end); a range with a fractional step is ``np.linspace`` with the +point count computed here, because ``np.arange`` with a float step can gain or +lose its end point. As a subscript, :func:`to_slice` gives the Python slice. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, offset +from dualect.infer import range_count +from dualect.lift import LiftContext + + +def literal_int(node: ir.Expr | None) -> int | None: + """The value of an integer literal, ``-k`` included.""" + if isinstance(node, ir.Num) and isinstance(node.value, int): + return node.value + if isinstance(node, ir.UnOp) and node.op == "uminus": + inner = literal_int(node.operand) + return -inner if inner is not None else None + return None + + +def translate(node: ir.Range, ctx: Context) -> ast.expr: + """A range used as a value.""" + start, stop = ctx.info(node.start), ctx.info(node.stop) + step_value = literal_int(node.step) if node.step is not None else 1 + if node.step is not None and step_value is None: + step_info = ctx.info(node.step) + if not (step_info.integer and step_info.is_scalar): + return _linspace(node, ctx) + ctx.decline("a range with a variable step") + if start.integer and step_value is not None: + if not stop.integer: + if stop.value is not None: + ctx.decline("a range whose bound is not an integer") + ctx.assume("integer range bound") + upper = offset(ctx.expr(node.stop), 1 if step_value > 0 else -1) + args = [ctx.expr(node.start), upper] + if step_value != 1: + args.append(ctx.const(step_value)) + return ctx.call(ctx.np("arange"), *args) + return _linspace(node, ctx) + + +def _linspace(node: ir.Range, ctx: Context) -> ast.expr: + start = ctx.info(node.start).value + stop = ctx.info(node.stop).value + step = ctx.info(node.step).value if node.step is not None else 1 + count = range_count(start, step, stop) + if count is None or not all(isinstance(v, int | float) for v in (start, step, stop)): + ctx.decline("a range with a fractional or unknown step and unknown bounds") + assert isinstance(start, int | float) and isinstance(step, int | float) + last = start + (count - 1) * step + if abs(last - float(stop)) > 1e-12 * max(1.0, abs(float(stop))): # type: ignore[arg-type] + ctx.decline("a fractional-step range that stops short of its bound") + return ctx.call( + ctx.np("linspace"), ctx.expr(node.start), ctx.expr(node.stop), ast.Constant(count) + ) + + +def to_slice(node: ir.Range, ctx: Context) -> ast.expr: + """A range used as a subscript: the Python slice with the same elements.""" + ends = ctx.module("indexing/end-in-index") + one_based = ctx.module("indexing/one-based") + step = literal_int(node.step) if node.step is not None else 1 + if step is None or step == 0: + ctx.decline("a subscript range with a variable step") + lower: ast.expr | None + upper: ast.expr | None + if step > 0: + lower = None if literal_int(node.start) == 1 else one_based.zero_based(node.start, ctx) + stop_end = ends.end_offset(node.stop) + if stop_end is not None: + upper = None if stop_end == 0 else ctx.const(-stop_end) + elif ends.end_minus(node.stop) is not None: + upper = ast.UnaryOp(op=ast.USub(), operand=ctx.expr(ends.end_minus(node.stop))) + else: + # A 1-based inclusive stop is the same number as a 0-based exclusive one. + upper = one_based.position_value(node.stop, ctx) + else: + lower = None if ends.end_offset(node.start) == 0 else one_based.zero_based(node.start, ctx) + stop = literal_int(node.stop) + if stop is None or stop < 1: + ctx.decline("a descending subscript range with a non-literal stop") + # Exclusive stop one below the 0-based inclusive stop; none when it is 0. + upper = None if stop == 1 else ctx.const(stop - 2) + return ast.Slice( + lower=lower, + upper=upper, + step=None if step == 1 else ctx.const(step), + ) + + +# --- Python -> .m ------------------------------------------------------------ +# +# np.arange(a, b) stops before b: a:b-1 (with a step s > 0, a:s:b-1; s < 0, +# a:s:b+1). np.arange with a float step can gain or lose its end point, so only +# integer arguments are translated. A slice x[a:b] is x(a+1:b): the 0-based +# start rises by one and the exclusive 0-based stop is the inclusive 1-based +# one. A missing stop is `end`; negative bounds count from the end. + + +def _step(node: ast.expr | None, ctx: LiftContext) -> int: + if node is None: + return 1 + value = node.value if isinstance(node, ast.Constant) else None + if isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.USub): + inner = node.operand + value = ( + -inner.value if isinstance(inner, ast.Constant) and type(inner.value) is int else None + ) + if type(value) is not int or value == 0: + ctx.decline("a step that is not a non-zero integer literal") + return value + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``np.arange`` with integer arguments.""" + assert isinstance(node, ast.Call) + loc = ctx.loc(node) + args = node.args + if node.keywords or not 1 <= len(args) <= 3: + ctx.decline("np.arange with these arguments") + if not all(ctx.info(a).dtype.value == "int" for a in args): + ctx.decline("np.arange with arguments not known to be integers") + if len(args) == 1: + start: ir.Expr = ctx.num(0) + stop_node = args[0] + else: + start = ctx.expr(args[0]) + stop_node = args[1] + step = _step(args[2] if len(args) == 3 else None, ctx) + stop = ctx.shift(ctx.expr(stop_node), -1 if step > 0 else 1) + if step == 1: + return ir.Range(loc=loc, start=start, stop=stop) + return ir.Range(loc=loc, start=start, stop=stop, step=ctx.num(step)) + + +def slice_range( + part: ast.Slice, target: ir.Expr, dim: int, ndims: int, ctx: LiftContext +) -> ir.Expr: + """A Python slice as the ``.m`` range of the same positions.""" + loc = ctx.loc(part) + step = _step(part.step, ctx) + one_based = ctx.module_for("indexing/one-based") + ends = ctx.module_for("indexing/end-in-index") + + def bound(node: ast.expr, adjust: int) -> ir.Expr: + """A 0-based (possibly negative) bound plus ``adjust``, as a 1-based value.""" + if one_based._negative(node): + return ctx.shift(ends.from_end(node, target, dim, ndims, ctx), adjust - 1) + info = ctx.info(node) + if not info.nonneg: + ctx.assume(f"non-negative slice bound {ast.unparse(node)}") + return ctx.shift(ctx.expr(node), adjust) + + end = ir.End(loc=loc, target=target, dim=dim, ndims=ndims) + if step > 0: + start = ctx.num(1) if part.lower is None else bound(part.lower, 1) + stop = end if part.upper is None else bound(part.upper, 0) + else: + start = end if part.lower is None else bound(part.lower, 1) + stop = ctx.num(1) if part.upper is None else bound(part.upper, 2) + if step == 1: + return ir.Range(loc=loc, start=start, stop=stop) + return ir.Range(loc=loc, start=start, stop=stop, step=ctx.num(step)) diff --git a/rules/io/display/cases/basic.m b/rules/io/display/cases/basic.m new file mode 100644 index 0000000..d8cdba0 --- /dev/null +++ b/rules/io/display/cases/basic.m @@ -0,0 +1,4 @@ +x = 3 % no semicolon: prints the value +disp(x) +fprintf('%d items\n', x); +y = x + 1; diff --git a/rules/io/display/cases/basic.py b/rules/io/display/cases/basic.py new file mode 100644 index 0000000..f217f03 --- /dev/null +++ b/rules/io/display/cases/basic.py @@ -0,0 +1,5 @@ +x = 3 +print(f"x = {x}") # what the missing semicolon printed +print(x) +print(f"{x} items") +y = x + 1 diff --git a/rules/io/display/rule.yaml b/rules/io/display/rule.yaml new file mode 100644 index 0000000..099f422 --- /dev/null +++ b/rules/io/display/rule.yaml @@ -0,0 +1,34 @@ +id: io/display +title: "Printing: missing `;`, `disp`, `printf` / `fprintf`" +status: guided +dialects: [octave, matlab] +match: [syntax:display, call:disp, call:display, call:printf, call:fprintf] +from_python: # the Python -> .m direction + status: guided + match: + - py:call:print + - py:fstring +octave: | + x = 3 % no semicolon: prints "x = 3" + disp(x) + fprintf('%d items\n', n); +python: | + print(f"x = {x}") + print(x) + print(f"{n} items") +why: > + A statement without a terminating semicolon prints its result, which is easy + to leave in by accident; decide whether the output was intended. `disp(x)` + is `print(x)`. `printf`/`fprintf` formats look like C's and map to f-strings, + but they cycle the format over all elements of array arguments. +pitfalls: + - >- + `fprintf('%d\n', [1 2 3])` prints three lines (the format repeats for + every element); Python needs an explicit loop or `"\n".join(...)`. + - >- + `fprintf(fid, ...)` with a file id writes to a file: `print(..., file=f)`. + - >- + Number formatting differs (`disp(0.1)` shows `0.1000`); compare values, not + printed text. +related: [syntax/command-syntax] +python_imports: [] diff --git a/rules/operators/arithmetic/cases/basic.m b/rules/operators/arithmetic/cases/basic.m new file mode 100644 index 0000000..707dbc5 --- /dev/null +++ b/rules/operators/arithmetic/cases/basic.m @@ -0,0 +1,10 @@ +a = 7; +b = 2; +s = a + b; +d = a - b; +n = -a; +v = [1 2 3]; +w = v + 10; +big = v > 1; +two = v == 2; +ok = a >= b; diff --git a/rules/operators/arithmetic/cases/basic.py b/rules/operators/arithmetic/cases/basic.py new file mode 100644 index 0000000..e16fe02 --- /dev/null +++ b/rules/operators/arithmetic/cases/basic.py @@ -0,0 +1,12 @@ +import numpy as np + +a = 7 +b = 2 +s = a + b +d = a - b +n = -a +v = np.array([1, 2, 3]) +w = v + 10 +big = v > 1 +two = v == 2 +ok = a >= b diff --git a/rules/operators/arithmetic/cases/expansion.m b/rules/operators/arithmetic/cases/expansion.m new file mode 100644 index 0000000..4b520db --- /dev/null +++ b/rules/operators/arithmetic/cases/expansion.m @@ -0,0 +1,7 @@ +% Implicit expansion: singleton dimensions stretch to match. +r = [1 2 3]; +c = [10; 20]; +grid = c + r; % 2x3: every pairing +A = [1 2 3; 4 5 6]; +centered = A - mean(A); % subtract each column's mean +shifted = A + c; % add c(i) to row i diff --git a/rules/operators/arithmetic/cases/expansion.py b/rules/operators/arithmetic/cases/expansion.py new file mode 100644 index 0000000..30ecb94 --- /dev/null +++ b/rules/operators/arithmetic/cases/expansion.py @@ -0,0 +1,9 @@ +# Implicit expansion: singleton dimensions stretch to match. +import numpy as np + +r = np.array([1, 2, 3]) +c = np.array([10, 20]) +grid = c[:, np.newaxis] + r # 1-D c + r would pair elements (or fail) +A = np.array([[1, 2, 3], [4, 5, 6]]) +centered = A - A.mean(axis=0) +shifted = A + c[:, np.newaxis] diff --git a/rules/operators/arithmetic/rule.yaml b/rules/operators/arithmetic/rule.yaml new file mode 100644 index 0000000..d7a8f2b --- /dev/null +++ b/rules/operators/arithmetic/rule.yaml @@ -0,0 +1,54 @@ +id: operators/arithmetic +title: "`+`, `-`, comparisons and implicit expansion" +status: mechanical +dialects: [octave, matlab] +match: [op:plus, op:minus, op:uminus, op:uplus, op:eq, op:lt, op:le, op:gt, op:ge] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:op:add + - py:op:sub + - py:op:usub + - py:op:uadd + - py:cmp:eq + - py:cmp:lt + - py:cmp:lte + - py:cmp:gt + - py:cmp:gte + - py:index:newaxis + - py:const:np.newaxis +octave: | + s = a + b; + big = v > 1; + grid = c + r; % column + row: a matrix +python: | + s = a + b + big = v > 1 + grid = c[:, np.newaxis] + r +why: > + Addition, subtraction, negation and comparisons are element-wise in both + languages, and a scalar combines with every element. Both also expand + singleton dimensions (implicit expansion, MATLAB R2016b+ and Octave): a + column plus a row gives a matrix. With 1-D NumPy vectors there is no column, + so the column side needs an explicit axis: `c[:, np.newaxis] + r`. A matrix + combined with a row is the same in both; with a column it needs the axis too. +pitfalls: + - >- + NumPy keeps `bool + bool` as bool (a logical OR) and `-mask` raises; the + source treats logical values as numbers, so `m + m` is + `m.astype(int) + m` and `t + t` of two logical scalars is `int(t) + t`. + - >- + A vector whose orientation differs between uses (a function called with a + row and with a column) broadcasts differently in each; such an + element-wise operation is declined. + - >- + Two 1-D arrays of equal length add element by element, so translating + `c + r` (column plus row) as `c + r` is silently wrong when the lengths + happen to match. + - >- + Comparisons give logical arrays (`bool` in NumPy); see indexing/logical for + using them as masks. + - >- + `a == b` on char arrays compares characters; see types/char-strings. +related: [operators/matrix-multiply, syntax/array-literals, operators/division] +python_imports: [import numpy as np] diff --git a/rules/operators/arithmetic/translate.py b/rules/operators/arithmetic/translate.py new file mode 100644 index 0000000..bcb5874 --- /dev/null +++ b/rules/operators/arithmetic/translate.py @@ -0,0 +1,175 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for operators/arithmetic: ``+``, ``-``, unary minus, comparisons. + +These are element-wise in both languages. The one difference is implicit +expansion against a *column*: NumPy vectors are 1-D, so a column operand that +must stretch across columns gets an explicit axis, ``c[:, np.newaxis]``. +:func:`expand` is shared with the other element-wise operators. + +Logical values are numbers in the source (``true + true`` is 2) but NumPy +keeps ``bool + bool`` as ``bool`` (a logical OR) and ``bool * bool`` as an +AND, so when both operands are logical :func:`numeric` turns the left one +into integers first (``m.astype(int) + m``). +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.infer import Info, Kind +from dualect.lift import LiftContext + +_BINARY: dict[str, ast.operator] = {"plus": ast.Add(), "minus": ast.Sub()} +_COMPARE: dict[str, ast.cmpop] = { + "eq": ast.Eq(), + "ne": ast.NotEq(), + "lt": ast.Lt(), + "le": ast.LtE(), + "gt": ast.Gt(), + "ge": ast.GtE(), +} + + +def _column(expr: ast.expr, ctx: Context) -> ast.expr: + """``expr[:, np.newaxis]``: a 1-D vector as a column that broadcasts across columns.""" + return ast.Subscript(value=expr, slice=ast.Tuple(elts=[ast.Slice(), ctx.np("newaxis")])) + + +def numeric(expr: ast.expr, left: Info, right: Info, ctx: Context) -> ast.expr: + """The left operand of an arithmetic operator, as numbers when both sides are logical. + + :param expr: the translated left operand. + :param left: facts about the left operand. + :param right: facts about the right operand. + """ + if not (left.is_logical and right.is_logical): + return expr + if left.is_array: + return ctx.method(expr, "astype", ast.Name("int")) + if left.is_scalar: + # A NumPy bool scalar (`m(1)`) adds like a bool array; int() is exact. + return ctx.call(ast.Name("int"), expr) + ctx.decline("arithmetic on logical values of unknown shape") + + +def expand(node: ir.BinOp, ctx: Context) -> tuple[ast.expr, ast.expr]: + """Both operands of an element-wise operator, with columns given their axis. + + A column against a row (or a matrix) needs ``[:, np.newaxis]``; two vectors + of unknown orientation are assumed to have the same one. + """ + left, right = ctx.info(node.left), ctx.info(node.right) + a, b = ctx.expr(node.left), ctx.expr(node.right) + if left.is_scalar or right.is_scalar: + return a, b + kinds = {left.kind, right.kind} + if kinds == {Kind.ROW, Kind.COL} or kinds == {Kind.MATRIX, Kind.COL}: + if left.kind is Kind.COL: + a = _column(a, ctx) + else: + b = _column(b, ctx) + return a, b + if left.kind is right.kind and left.kind in (Kind.ROW, Kind.COL, Kind.MATRIX, Kind.EMPTY): + return a, b + if kinds <= {Kind.MATRIX, Kind.ROW, Kind.EMPTY}: + return a, b + if Kind.VECTOR in kinds and kinds & {Kind.ROW, Kind.COL, Kind.MATRIX}: + # Orientation differs between uses; broadcasting would differ too. + ctx.decline("an element-wise operation on a vector whose orientation is not known") + if left.kind is Kind.STRING or right.kind is Kind.STRING: + ctx.decline("arithmetic or comparison on char arrays") + ctx.assume("operands of matching shape") + return a, b + + +def translate(node: ir.BinOp | ir.UnOp, ctx: Context) -> ast.expr: + """``a + b``, ``a - b``, ``-a``, ``+a`` and the comparisons.""" + if isinstance(node, ir.UnOp): + info = ctx.info(node.operand) + # `-m` and `+m` of a logical value are numbers in the source. + operand = numeric(ctx.expr(node.operand), info, info, ctx) + if node.op == "uplus": + return operand + if node.op == "uminus": + return ast.UnaryOp(op=ast.USub(), operand=operand) + ctx.decline(f"unary {node.op}") + a, b = expand(node, ctx) + if node.op in _BINARY: + a = numeric(a, ctx.info(node.left), ctx.info(node.right), ctx) + return ast.BinOp(left=a, op=_BINARY[node.op], right=b) + if node.op in _COMPARE: + return ast.Compare(left=a, ops=[_COMPARE[node.op]], comparators=[b]) + ctx.decline(f"operator {node.op}") + + +# --- Python -> .m ------------------------------------------------------------ +# +# The same operators. NumPy's bool + bool is a logical OR (and -mask raises), +# so arithmetic on two boolean arrays is declined. String + string is a +# concatenation and == on strings a comparison of the whole text: both go to +# types/char-strings. c[:, np.newaxis] is a 1-D vector stood up as a column. + +_FROM_PY = {ast.Add: "plus", ast.Sub: "minus"} +_FROM_PY_CMP = { + ast.Eq: "eq", ast.NotEq: "ne", ast.Lt: "lt", ast.LtE: "le", ast.Gt: "gt", ast.GtE: "ge", +} # fmt: skip + + +def both_bool_arrays(left: ast.expr, right: ast.expr, ctx: LiftContext) -> bool: + """Whether NumPy would combine two boolean values as booleans, not numbers.""" + a, b = ctx.info(left), ctx.info(right) + return a.is_bool and b.is_bool and (a.is_array or b.is_array) + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``+``, ``-``, unary ``-``/``+``, the comparisons and ``c[:, np.newaxis]``.""" + loc = ctx.loc(node) + if isinstance(node, ast.UnaryOp): + info = ctx.info(node.operand) + if info.is_bool and info.is_array: + ctx.decline("negating a boolean array") + operand = ctx.expr(node.operand) + if isinstance(node.op, ast.UAdd): + return operand + return ir.UnOp(loc=loc, op="uminus", operand=operand) + if isinstance(node, ast.BinOp): + a, b = ctx.info(node.left), ctx.info(node.right) + if a.kind.value == "string" or b.kind.value == "string": + return ctx.module_for("types/char-strings").lift_concat(node, ctx) + if both_bool_arrays(node.left, node.right, ctx): + ctx.decline("arithmetic on boolean arrays (NumPy keeps bool + bool as a logical OR)") + op = _FROM_PY.get(type(node.op)) + if op is None: + ctx.decline(f"operator {type(node.op).__name__}") + return ctx.binop(op, ctx.expr(node.left), ctx.expr(node.right), loc=loc) + if isinstance(node, ast.Compare): + if len(node.ops) != 1: + ctx.decline("a chained comparison") + left, right = node.left, node.comparators[0] + if ctx.info(left).kind.value == "string" or ctx.info(right).kind.value == "string": + return ctx.module_for("types/char-strings").lift_compare(node, ctx) + op = _FROM_PY_CMP.get(type(node.ops[0])) + if op is None: + ctx.decline(f"comparison {type(node.ops[0]).__name__}") + return ctx.binop(op, ctx.expr(left), ctx.expr(right), loc=loc) + if isinstance(node, ast.Attribute): # np.newaxis on its own + ctx.decline("np.newaxis outside a subscript") + ctx.decline(f"{type(node).__name__}") + + +def lift_newaxis(node: ast.Subscript, ctx: LiftContext) -> ir.Expr: + """``c[:, np.newaxis]`` is ``c.'`` (a column); ``c[np.newaxis, :]`` is ``c`` (a row).""" + parts = node.slice.elts if isinstance(node.slice, ast.Tuple) else [node.slice] + if not ctx.info(node.value).is_vector or len(parts) != 2: + ctx.decline("a new axis on a value that is not 1-D") + whole = [ + isinstance(p, ast.Slice) and p.lower is None and p.upper is None and p.step is None + for p in parts + ] + if whole[0] and not whole[1]: + return ctx.transpose(ctx.expr(node.value)) + if whole[1] and not whole[0]: + return ctx.expr(node.value) + ctx.decline("this new-axis subscript") diff --git a/rules/operators/augmented-assignment/cases/basic.m b/rules/operators/augmented-assignment/cases/basic.m new file mode 100644 index 0000000..47ae353 --- /dev/null +++ b/rules/operators/augmented-assignment/cases/basic.m @@ -0,0 +1,8 @@ +n = 0; +n++; +n += 4; +k = 10; +k -= 3; +k *= 2; +v = [1 2 3]; +v += 1; diff --git a/rules/operators/augmented-assignment/cases/basic.py b/rules/operators/augmented-assignment/cases/basic.py new file mode 100644 index 0000000..9c40fbd --- /dev/null +++ b/rules/operators/augmented-assignment/cases/basic.py @@ -0,0 +1,10 @@ +import numpy as np + +n = 0 +n += 1 +n += 4 +k = 10 +k -= 3 +k *= 2 +v = np.array([1, 2, 3]) +v = v + 1 # += would change the array in place, and every alias of it diff --git a/rules/operators/augmented-assignment/rule.yaml b/rules/operators/augmented-assignment/rule.yaml new file mode 100644 index 0000000..5e79dec --- /dev/null +++ b/rules/operators/augmented-assignment/rule.yaml @@ -0,0 +1,31 @@ +id: operators/augmented-assignment +title: "`x += e`, `x++` and friends (Octave only)" +status: mechanical +dialects: [octave] +match: [op:augassign] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:augassign +octave: | + n++; + k += 2; + v += 1; % v is an array +python: | + n += 1 + k += 2 + v = v + 1 +why: > + Octave accepts `+=`, `-=`, `*=`, `/=` and the statements `x++` / `x--`; + MATLAB has none of them. On numbers they are Python's augmented assignment. + On a NumPy array `v += 1` changes the array in place, which also changes + every other name bound to it; Octave's copy semantics never do, so write + `v = v + 1` unless the array is known to be unshared. +pitfalls: + - >- + `*=` and `/=` are the matrix operators: `A *= B` is `A = A * B` (a matrix + product), see operators/matrix-multiply. + - >- + `x++` inside an expression (`y = x++`) is not supported by Octave either. +related: [operators/arithmetic, control-flow/while] +python_imports: [import numpy as np] diff --git a/rules/operators/augmented-assignment/translate.py b/rules/operators/augmented-assignment/translate.py new file mode 100644 index 0000000..d29b21c --- /dev/null +++ b/rules/operators/augmented-assignment/translate.py @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for operators/augmented-assignment: ``x += e``, ``x++``, ... + +On a scalar this is Python's augmented assignment. On an array ``x += e`` +would modify the array in place (and every alias of it), so it is written +``x = x + e``, which matches the source's copy semantics. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.lift import LiftContext + +_AUGMENTED = {"plus": "+=", "minus": "-=", "mtimes": "*=", "mrdivide": "/="} + + +def translate(stmt: ir.AugAssign, ctx: Context) -> list[Line]: + """One augmented assignment.""" + target = stmt.target + if not isinstance(target, ir.Name): + ctx.decline("augmented assignment to an element") + if stmt.op not in _AUGMENTED: + ctx.decline(f"{stmt.op}= is not supported") + if ctx.is_index_var(target.id): + ctx.decline("augmented assignment to a position variable") + info = ctx.info(target) + combined = ir.BinOp(loc=stmt.loc, op=stmt.op, left=target, right=stmt.value) + if info.is_scalar and ctx.info(stmt.value).is_scalar: + return [ctx.line(f"{target.id} {_AUGMENTED[stmt.op]} {ast.unparse(ctx.expr(stmt.value))}")] + return [ctx.line(f"{target.id} = {ast.unparse(ctx.expr(combined))}")] + + +# --- Python -> .m ------------------------------------------------------------ +# +# x += e becomes x = x + e (the .m form both dialects read). On an array, +# Python's += changes the array in place, so every alias sees it; the engine +# declines aliases of arrays that are written (dualect.lift.check_alias), and +# the operator itself is lifted by its own rule. + + +def lift(stmt: ast.stmt, ctx: LiftContext) -> list[ir.Stmt]: + """One augmented assignment to a variable.""" + assert isinstance(stmt, ast.AugAssign) + target = stmt.target + if not isinstance(target, ast.Name): + ctx.decline("augmented assignment to an element") + combined = ast.BinOp(left=ast.Name(id=target.id, ctx=ast.Load()), op=stmt.op, right=stmt.value) + ast.copy_location(combined, stmt) + ast.fix_missing_locations(combined) + # The synthetic node has no inferred facts of its own; its operands do. + ctx.analysis.infos[id(combined.left)] = ctx.info(target) + value = ctx.expr(combined) + loc = ctx.loc(stmt) + return [ir.Assign(loc=loc, targets=[ir.Name(loc=ctx.loc(target), id=target.id)], value=value)] diff --git a/rules/operators/division/cases/basic.m b/rules/operators/division/cases/basic.m new file mode 100644 index 0000000..5eeb805 --- /dev/null +++ b/rules/operators/division/cases/basic.m @@ -0,0 +1,9 @@ +q = 7 / 2; % 3.5: no integer division +v = [2 4 8]; +half = v / 2; % by a scalar +recip = 1 ./ v; % element-wise +A = [4 1; 2 3]; +b = [1; 2]; +x = A \ b; % solves A * x = b +B = [1 2; 3 4]; +R = B / A; % solves R * A = B diff --git a/rules/operators/division/cases/basic.py b/rules/operators/division/cases/basic.py new file mode 100644 index 0000000..f43b013 --- /dev/null +++ b/rules/operators/division/cases/basic.py @@ -0,0 +1,11 @@ +import numpy as np + +q = 7 / 2 # 3.5: no integer division +v = np.array([2, 4, 8]) +half = v / 2 +recip = 1 / v +A = np.array([[4, 1], [2, 3]]) +b = np.array([1, 2]) +x = np.linalg.solve(A, b) # never np.linalg.inv(A) @ b +B = np.array([[1, 2], [3, 4]]) +R = np.linalg.solve(A.T, B.T).T # R @ A = B diff --git a/rules/operators/division/rule.yaml b/rules/operators/division/rule.yaml new file mode 100644 index 0000000..6ba179e --- /dev/null +++ b/rules/operators/division/rule.yaml @@ -0,0 +1,36 @@ +id: operators/division +title: "`/`, `./` and `\\`: true division and linear solves" +status: mechanical +dialects: [octave, matlab] +match: [op:mrdivide, op:rdivide, op:mldivide, op:ldivide] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:op:div + - py:op:floordiv + - py:call:np.linalg.solve +octave: | + h = v / 2; % by a scalar + r = 1 ./ v; % element-wise + x = A \ b; % solve A * x = b +python: | + h = v / 2 + r = 1 / v + x = np.linalg.solve(A, b) +why: > + Division by a scalar and element-wise division (`./`) are Python's `/`, which + is always true division. With a matrix on the right, `/` is *matrix* right + division: `B / A` solves `X * A = B`, which is + `np.linalg.solve(A.T, B.T).T`. Left division `A \ b` solves `A * x = b`: + `np.linalg.solve(A, b)`. Never compute an inverse for either. +pitfalls: + - >- + `B / A` with a matrix `A` is not element-wise; `B / A` in NumPy is. + - >- + For a non-square `A`, `A \ b` is the least-squares solution: + `np.linalg.lstsq(A, b, rcond=None)[0]`. `np.linalg.solve` raises for it. + - >- + `1 / 0` is `Inf` in `.m` code but raises ZeroDivisionError for Python + numbers (NumPy arrays give inf with a warning). +related: [operators/matrix-multiply, operators/arithmetic] +python_imports: [import numpy as np] diff --git a/rules/operators/division/translate.py b/rules/operators/division/translate.py new file mode 100644 index 0000000..faebbe4 --- /dev/null +++ b/rules/operators/division/translate.py @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for operators/division: ``./``, ``/``, ``\\`` and ``.\\``. + +Element-wise division and division by a scalar are Python's ``/``. Matrix +divisions become linear solves: ``A \\ b`` is ``np.linalg.solve(A, b)`` and +``B / A`` is ``np.linalg.solve(A.T, B.T).T``. A divisor of unknown shape is +assumed to be a scalar (docs/design.md section 5.2). +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.lift import LiftContext + + +def _transpose(expr: ast.expr) -> ast.expr: + return ast.Attribute(value=expr, attr="T") + + +def translate(node: ir.BinOp, ctx: Context) -> ast.expr: + """One division.""" + arithmetic = ctx.module("operators/arithmetic") + left, right = ctx.info(node.left), ctx.info(node.right) + if node.op == "rdivide": + a, b = arithmetic.expand(node, ctx) + return ast.BinOp(left=a, op=ast.Div(), right=b) + if node.op == "ldivide": + a, b = arithmetic.expand(node, ctx) + return ast.BinOp(left=b, op=ast.Div(), right=a) + if node.op == "mrdivide": + if right.is_scalar: + return ast.BinOp(left=ctx.expr(node.left), op=ast.Div(), right=ctx.expr(node.right)) + if right.is_matrix and (left.is_matrix or left.kind.value == "row"): + solved = ctx.call( + ctx.np("linalg.solve"), + _transpose(ctx.expr(node.right)), + _transpose(ctx.expr(node.left)), + ) + return _transpose(solved) if left.is_matrix else solved + if right.kind.value in ("unknown", "array"): + ctx.assume(f"scalar divisor {ast.unparse(ctx.expr(node.right))}") + return ast.BinOp(left=ctx.expr(node.left), op=ast.Div(), right=ctx.expr(node.right)) + ctx.decline("matrix right division with these shapes") + if node.op == "mldivide": + if left.is_scalar: + return ast.BinOp(left=ctx.expr(node.right), op=ast.Div(), right=ctx.expr(node.left)) + if left.is_matrix and left.rows is not None and left.rows == left.cols: + return ctx.call(ctx.np("linalg.solve"), ctx.expr(node.left), ctx.expr(node.right)) + ctx.decline("left division by a matrix that is not known to be square") + ctx.decline(f"operator {node.op}") + + +# --- Python -> .m ------------------------------------------------------------ +# +# Python's / is always true division: ./ (or / by a scalar). a // b floors: +# floor(a ./ b). np.linalg.solve(A, b) is A \ b; a 1-D b is a row on the .m side, +# so the solve is (A \ b.').'. + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``/``, ``//`` and ``np.linalg.solve``.""" + loc = ctx.loc(node) + if isinstance(node, ast.Call): + if len(node.args) != 2 or node.keywords: + ctx.decline("np.linalg.solve with these arguments") + a_node, b_node = node.args + if not ctx.info(a_node).is_matrix: + ctx.decline("solving with a value not known to be a matrix") + a = ctx.expr(a_node) + b_info = ctx.info(b_node) + if b_info.is_matrix: + return ctx.binop("mldivide", a, ctx.expr(b_node), loc=loc) + if b_info.is_vector or isinstance(b_node, ast.List): + b = ctx.module_for("syntax/array-literals").lift_items(b_node, ctx) + return ctx.transpose(ctx.binop("mldivide", a, ctx.transpose(b), loc=loc)) + ctx.decline("solving for a right-hand side of unknown dimensions") + assert isinstance(node, ast.BinOp) + left, right = ctx.expr(node.left), ctx.expr(node.right) + by_scalar = ctx.info(node.right).is_scalar + op = "mrdivide" if by_scalar else "rdivide" + if not (by_scalar or ctx.info(node.right).is_array): + ctx.assume("element-wise division") + quotient = ctx.binop(op, left, right, loc=loc) + if isinstance(node.op, ast.Div): + return quotient + if isinstance(node.op, ast.FloorDiv): + divisor = ctx.info(node.right).value + if divisor == 0: + ctx.decline("floor division by zero") + if divisor is None: + ctx.assume("nonzero divisor in //") + return ctx.call("floor", quotient, loc=loc) + ctx.decline(f"operator {type(node.op).__name__}") diff --git a/rules/operators/matrix-multiply/cases/basic.m b/rules/operators/matrix-multiply/cases/basic.m new file mode 100644 index 0000000..a44b4dc --- /dev/null +++ b/rules/operators/matrix-multiply/cases/basic.m @@ -0,0 +1,10 @@ +A = [1 2; 3 4]; +B = [5 6; 7 8]; +C = A * B; +D = A .* B; +s = 2 * A; +y = A * [1; 1]; +u = [1 2 3]; +v = [4 5 6]; +inner = u * v'; +outer = u' * v; diff --git a/rules/operators/matrix-multiply/cases/basic.py b/rules/operators/matrix-multiply/cases/basic.py new file mode 100644 index 0000000..ea76937 --- /dev/null +++ b/rules/operators/matrix-multiply/cases/basic.py @@ -0,0 +1,12 @@ +import numpy as np + +A = np.array([[1, 2], [3, 4]]) +B = np.array([[5, 6], [7, 8]]) +C = A @ B +D = A * B +s = 2 * A +y = A @ np.array([1, 1]) +u = np.array([1, 2, 3]) +v = np.array([4, 5, 6]) +inner = u @ v +outer = np.outer(u, v) diff --git a/rules/operators/matrix-multiply/rule.yaml b/rules/operators/matrix-multiply/rule.yaml new file mode 100644 index 0000000..1260059 --- /dev/null +++ b/rules/operators/matrix-multiply/rule.yaml @@ -0,0 +1,42 @@ +id: operators/matrix-multiply +title: "`*` (matrix product) vs `.*` (element-wise)" +status: mechanical +dialects: [octave, matlab] +match: [op:mtimes, op:times] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:op:mult + - py:op:matmult + - py:call:np.outer +octave: | + C = A * B; % matrix product + D = A .* B; % element-wise + s = 2 * A; % scalar: same either way +python: | + C = A @ B + D = A * B + s = 2 * A +why: > + In Octave `*` is the matrix product and `.*` is element-wise; in NumPy `*` + is element-wise and `@` is the matrix product. Scalar times array is the same + in both. Mapping `*` to `*` does not always fail: two square matrices of the + same size multiply element-wise without any error, giving wrong numbers. +pitfalls: + - >- + A function or lambda called once with a row and once with a column has a + vector of unknown orientation: `u * v` is inner for one call and outer for + the other, so no single `@` is right and the statement is declined. + - >- + With 1-D arrays there is no row/column: `u * v'` (inner product of rows) + is `u @ v`, and `u' * v` (outer product) is `np.outer(u, v)`. + - >- + `A * x` with a column vector `x` is `A @ x`; a 1-D `x` works and returns 1-D. + - >- + `/` and `\` are matrix division when both sides are matrices: + `A \ b` is `np.linalg.solve(A, b)`, never `b / A`. + - >- + When an operand's shape is unknown (scalar or matrix?), `@` is the safe + translation of `*` only if both are arrays; `@` with a Python scalar raises. +related: [operators/power, operators/transpose] +python_imports: [import numpy as np] diff --git a/rules/operators/matrix-multiply/translate.py b/rules/operators/matrix-multiply/translate.py new file mode 100644 index 0000000..1593588 --- /dev/null +++ b/rules/operators/matrix-multiply/translate.py @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for operators/matrix-multiply: ``*`` and ``.*``. + +``.*`` is NumPy's ``*``. ``*`` is a scalar product when either side is a +scalar, and otherwise the matrix product ``@``, with the 1-D cases spelled out: +row times column is the inner product ``u @ v``, column times row the outer +product ``np.outer(u, v)``. With an operand of unknown shape the product is +assumed to be a matrix product (docs/design.md section 5.2); a vector whose +orientation is not known (row at one call site, column at another) is declined, +since the product means an inner product for one and an outer for the other. +Two logical operands are multiplied as numbers (see operators/arithmetic). +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.infer import Kind +from dualect.lift import LiftContext + + +def translate(node: ir.BinOp, ctx: Context) -> ast.expr: + """One multiplication.""" + left, right = ctx.info(node.left), ctx.info(node.right) + if node.op == "times": + arithmetic = ctx.module("operators/arithmetic") + a, b = arithmetic.expand(node, ctx) + return ast.BinOp(left=arithmetic.numeric(a, left, right, ctx), op=ast.Mult(), right=b) + if node.op != "mtimes": + ctx.decline(f"operator {node.op}") + a, b = ctx.expr(node.left), ctx.expr(node.right) + a = ctx.module("operators/arithmetic").numeric(a, left, right, ctx) + if left.is_scalar or right.is_scalar: + return ast.BinOp(left=a, op=ast.Mult(), right=b) + if left.kind is Kind.COL and right.kind is Kind.ROW: + return ctx.call(ctx.np("outer"), a, b) + known = {Kind.ROW, Kind.COL, Kind.MATRIX} + if left.kind in known and right.kind in known: + if left.kind is Kind.COL or right.kind is Kind.ROW: + ctx.decline("a matrix product with these shapes") + return ast.BinOp(left=a, op=ast.MatMult(), right=b) + if left.kind is Kind.STRING or right.kind is Kind.STRING: + ctx.decline("multiplying char arrays") + if Kind.VECTOR in (left.kind, right.kind): + # A vector whose orientation differs between uses (a function called + # with a row and with a column): `u * v` is an inner product for one + # and an outer product for the other, and `@` can only be one of them. + ctx.decline("a product with a vector whose orientation is not known") + ctx.assume("matrix multiply") + return ast.BinOp(left=a, op=ast.MatMult(), right=b) + + +# --- Python -> .m ------------------------------------------------------------ +# +# NumPy's * is element-wise (.*), @ the matrix product. A 1-D array is a row on +# the .m side, so @ with a 1-D operand needs a transpose: u @ v is u * v.', +# A @ v is (A * v.').', v @ A is v * A; np.outer(u, v) is u.' * v. + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``*``, ``@`` and ``np.outer``.""" + loc = ctx.loc(node) + if isinstance(node, ast.Call): + if len(node.args) != 2 or node.keywords: + ctx.decline("np.outer with these arguments") + u, v = node.args + if not all(ctx.info(x).is_vector or isinstance(x, ast.List) for x in (u, v)): + ctx.decline("np.outer of values not known to be 1-D (it flattens them)") + literals = ctx.module_for("syntax/array-literals") + return ctx.binop( + "mtimes", + ctx.transpose(literals.lift_items(u, ctx)), + literals.lift_items(v, ctx), + loc=loc, + ) + assert isinstance(node, ast.BinOp) + a, b = ctx.info(node.left), ctx.info(node.right) + if isinstance(node.op, ast.Mult): + if a.kind.value == "string" or b.kind.value == "string": + ctx.decline("repeating a string") + if ctx.module_for("operators/arithmetic").both_bool_arrays(node.left, node.right, ctx): + ctx.decline("multiplying boolean arrays (NumPy keeps bool * bool as a logical AND)") + left, right = ctx.expr(node.left), ctx.expr(node.right) + op = "mtimes" if a.is_scalar or b.is_scalar else "times" + if not (a.is_scalar or b.is_scalar or a.is_array or b.is_array): + ctx.assume("element-wise product") + return ctx.binop(op, left, right, loc=loc) + if not isinstance(node.op, ast.MatMult): + ctx.decline(f"operator {type(node.op).__name__}") + left, right = ctx.expr(node.left), ctx.expr(node.right) + if a.is_matrix and b.is_matrix: + return ctx.binop("mtimes", left, right, loc=loc) + if a.is_vector and b.is_vector: + return ctx.binop("mtimes", left, ctx.transpose(right), loc=loc) + if a.is_matrix and b.is_vector: + return ctx.transpose(ctx.binop("mtimes", left, ctx.transpose(right), loc=loc)) + if a.is_vector and b.is_matrix: + return ctx.binop("mtimes", left, right, loc=loc) + ctx.decline("@ with an operand whose dimensions are unknown") diff --git a/rules/operators/not-equal/cases/basic.m b/rules/operators/not-equal/cases/basic.m new file mode 100644 index 0000000..47425de --- /dev/null +++ b/rules/operators/not-equal/cases/basic.m @@ -0,0 +1,9 @@ +a = [1 2 3 4]; +b = [1 0 3 0]; +d1 = a ~= b; +d2 = a != b; % Octave only +mask = a > 2; +nm = ~mask; +z = ~b; % NOT of numbers: true where b is zero +s = ~5; +t = !0; % Octave only diff --git a/rules/operators/not-equal/cases/basic.py b/rules/operators/not-equal/cases/basic.py new file mode 100644 index 0000000..3971e38 --- /dev/null +++ b/rules/operators/not-equal/cases/basic.py @@ -0,0 +1,11 @@ +import numpy as np + +a = np.array([1, 2, 3, 4]) +b = np.array([1, 0, 3, 0]) +d1 = a != b +d2 = a != b +mask = a > 2 +nm = ~mask +z = np.logical_not(b) # ~b would be bitwise on integers +s = not 5 +t = not 0 diff --git a/rules/operators/not-equal/rule.yaml b/rules/operators/not-equal/rule.yaml new file mode 100644 index 0000000..530d5dd --- /dev/null +++ b/rules/operators/not-equal/rule.yaml @@ -0,0 +1,38 @@ +id: operators/not-equal +title: "`~=` / `!=` and logical NOT `~` / `!`" +status: mechanical +dialects: [octave, matlab] +match: [op:ne, op:not] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:cmp:noteq + - py:op:not + - py:op:invert + - py:call:np.logical_not +octave: | + d = a ~= b; + d = a != b; % Octave only + n = ~mask; +python: | + d = a != b + n = ~mask # mask must be a bool array +why: > + `~=` (both dialects) and `!=` (Octave only) are element-wise not-equal, `!=` + in NumPy. Unary `~` (or `!` in Octave) is logical NOT: on a bool array it is + NumPy's `~`, but on numbers it must be `np.logical_not(x)` (true where x is + zero), because Python's `~` on integers is bitwise. +pitfalls: + - >- + `~5` is false in Octave, but `~5` is -6 in Python: `~` means NOT only for + bool arrays. A scalar becomes `not x`. + - >- + `if a ~= b` with arrays is true only when every element differs; see + control-flow/if-elseif. + - >- + `!=` and `!x` are not valid MATLAB; `~=` and `~x` work in both dialects. + - >- + `[~, i] = max(x)` uses `~` as an ignored-output placeholder (`_` in Python), + unrelated to NOT. +related: [operators/short-circuit, control-flow/if-elseif] +python_imports: [import numpy as np] diff --git a/rules/operators/not-equal/translate.py b/rules/operators/not-equal/translate.py new file mode 100644 index 0000000..bd1b5a1 --- /dev/null +++ b/rules/operators/not-equal/translate.py @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for operators/not-equal: ``~=`` / ``!=`` and ``~x`` / ``!x``. + +Not-equal is an element-wise comparison (shared with operators/arithmetic). +Logical NOT depends on the operand: ``not x`` for a scalar, ``~x`` for a +logical array, and ``np.logical_not(x)`` otherwise, because Python's ``~`` on +integers is bitwise. +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.lift import LiftContext + + +def translate(node: ir.BinOp | ir.UnOp, ctx: Context) -> ast.expr: + """``a ~= b`` or ``~x``.""" + if isinstance(node, ir.BinOp): + a, b = ctx.module("operators/arithmetic").expand(node, ctx) + return ast.Compare(left=a, ops=[ast.NotEq()], comparators=[b]) + info = ctx.info(node.operand) + operand = ctx.expr(node.operand) + if info.is_scalar: + return ast.UnaryOp(op=ast.Not(), operand=operand) + if info.is_logical and info.is_array: + return ast.UnaryOp(op=ast.Invert(), operand=operand) + return ctx.call(ctx.np("logical_not"), operand) + + +# --- Python -> .m ------------------------------------------------------------ +# +# != is ~=. `not x` is ~x for a scalar (Python raises for an array of several +# elements). ~m is ~m only on booleans: on integers Python's ~ is bitwise +# (~5 is -6), which is declined. np.logical_not(x) is ~x. + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``!=``, ``not``, ``~`` and ``np.logical_not``.""" + loc = ctx.loc(node) + if isinstance(node, ast.Compare): + if len(node.ops) != 1: + ctx.decline("a chained comparison") + left, right = node.left, node.comparators[0] + if ctx.info(left).kind.value == "string" or ctx.info(right).kind.value == "string": + equal = ctx.module_for("types/char-strings").lift_compare(node, ctx) + return ir.UnOp(loc=loc, op="not", operand=equal) + return ctx.binop("ne", ctx.expr(left), ctx.expr(right), loc=loc) + if isinstance(node, ast.Call): + if len(node.args) != 1 or node.keywords: + ctx.decline("np.logical_not with these arguments") + operand = ctx.module_for("syntax/array-literals").lift_items(node.args[0], ctx) + return ir.UnOp(loc=loc, op="not", operand=operand) + assert isinstance(node, ast.UnaryOp) + info = ctx.info(node.operand) + if isinstance(node.op, ast.Not): + if info.is_array: + ctx.decline("`not` of an array") + return ir.UnOp(loc=loc, op="not", operand=ctx.expr(node.operand)) + if not info.is_bool: + ctx.decline("~ of a value not known to be boolean (bitwise on integers)") + return ir.UnOp(loc=loc, op="not", operand=ctx.expr(node.operand)) diff --git a/rules/operators/power/cases/basic.m b/rules/operators/power/cases/basic.m new file mode 100644 index 0000000..8e54d82 --- /dev/null +++ b/rules/operators/power/cases/basic.m @@ -0,0 +1,9 @@ +A = [1 2; 3 4]; +P = A ^ 2; +P3 = A ^ 3; +Q = A .^ 2; +n = -2 ^ 2; +h = 2 ^ -1; +x = [1 2 3]; +y = 2 .^ x; +r = x .^ -1; diff --git a/rules/operators/power/cases/basic.py b/rules/operators/power/cases/basic.py new file mode 100644 index 0000000..ac3c2a6 --- /dev/null +++ b/rules/operators/power/cases/basic.py @@ -0,0 +1,11 @@ +import numpy as np + +A = np.array([[1, 2], [3, 4]]) +P = np.linalg.matrix_power(A, 2) +P3 = np.linalg.matrix_power(A, 3) +Q = A**2 +n = -(2**2) +h = 2**-1 +x = np.array([1, 2, 3]) +y = 2.0**x # a float base: 2**x on integers wraps around for x >= 63 +r = x**-1.0 # a float exponent: integer arrays reject negative integer powers diff --git a/rules/operators/power/rule.yaml b/rules/operators/power/rule.yaml new file mode 100644 index 0000000..1004642 --- /dev/null +++ b/rules/operators/power/rule.yaml @@ -0,0 +1,46 @@ +id: operators/power +title: "`^` (matrix power) vs `.^` (element-wise power)" +status: mechanical +dialects: [octave, matlab] +match: [op:mpower, op:power] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:op:pow + - py:call:np.linalg.matrix_power +octave: | + P = A ^ 2; % A * A + Q = A .^ 2; % element-wise +python: | + P = np.linalg.matrix_power(A, 2) + Q = A**2 +why: > + For a square matrix, `^` is the matrix power (repeated matrix product) and + `.^` is element-wise. Python's `**` on arrays is element-wise. For scalars + the two coincide, so `x^2` with scalar `x` is just `x**2`. +pitfalls: + - >- + `^` in Python is bitwise XOR: `2 ^ 3` is 1, not 8. + - >- + `-2^2` is -4 in both languages (power binds tighter than unary minus), and + `2^-1` is `2**-1`, 0.5. + - >- + NumPy integer arrays raise on negative integer powers + (`np.arange(1, 4)**-1`); write the exponent as a float (`x**-1.0`) or + use float data. + - >- + NumPy integers wrap around silently on overflow (`np.array([2, 3])**40`, + `2**np.arange(70)`), where the source computes in doubles; an exponent + above 2 or a scalar base over an integer array is written as a float + (`x**40.0`, `2.0**x`). `2.^x` means `2 .^ x`, not `2. ^ x`. + - >- + Logical operands are numbers in the source: `m .^ 2` of a mask is 0/1 + doubles, so the mask is converted (`m.astype(int)`) first. + - >- + A non-integer matrix power `A^0.5` is `scipy.linalg.fractional_matrix_power`, + not `A**0.5`. + - >- + Old Octave versions accepted `**` as an alias for `^` (matrix power, not + element-wise); Octave 11 rejects it. +related: [operators/matrix-multiply] +python_imports: [import numpy as np] diff --git a/rules/operators/power/translate.py b/rules/operators/power/translate.py new file mode 100644 index 0000000..51dea36 --- /dev/null +++ b/rules/operators/power/translate.py @@ -0,0 +1,102 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for operators/power: ``^`` and ``.^``. + +``.^`` is ``**``. ``^`` is ``**`` between scalars and +``np.linalg.matrix_power`` for a square matrix and an integer exponent. A +negative integer exponent on an integer array is written as a float +(``x**-1.0``) because NumPy rejects negative integer powers of integers, +and an exponent above 2 (or unknown) is written as a float too, because NumPy +integers wrap around on overflow where the source computes in doubles +(``[2 3] .^ 40``); likewise ``2 .^ n`` for an integer array ``n`` is +``2.0**n``. Two logical operands are powered as numbers. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, int_constant +from dualect.infer import Info +from dualect.lift import LiftContext + + +def _float_exponent(exponent: ast.expr) -> ast.expr: + value = int_constant(exponent) + if value is not None and value < 0: + return Context.const(float(value)) + return exponent + + +def _small_exponent(exponent: Info) -> bool: + """An exponent known to be 0, 1, 2 or negative: no int64 overflow from realistic data.""" + value = exponent.value + return isinstance(value, int | float) and value <= 2 + + +def _as_float(expr: ast.expr, info: Info, ctx: Context) -> ast.expr: + """``expr`` computed in floating point: a float literal, ``float(n)`` or ``x.astype(float)``.""" + value = int_constant(expr) + if value is not None: + return Context.const(float(value)) + if isinstance(expr, ast.Constant) and isinstance(expr.value, float): + return expr + if info.is_scalar: + return ctx.call(ast.Name("float"), expr) + return ctx.method(expr, "astype", ast.Name("float")) + + +def translate(node: ir.BinOp, ctx: Context) -> ast.expr: + """One power.""" + base, exponent = ctx.info(node.left), ctx.info(node.right) + if node.op == "power": + arithmetic = ctx.module("operators/arithmetic") + a, b = arithmetic.expand(node, ctx) + a = arithmetic.numeric(a, base, exponent, ctx) + if base.is_array and base.int_dtype: + b = _float_exponent(b) + if not _small_exponent(exponent): + # NumPy integers wrap around silently (3**40 overflows int64); + # the source computes in doubles. + b = _as_float(b, exponent, ctx) + elif base.int_dtype and exponent.is_array and exponent.int_dtype: + a = _as_float(a, base, ctx) # 2 .^ (1:70): the same overflow, from the base + return ast.BinOp(left=a, op=ast.Pow(), right=b) + if node.op != "mpower": + ctx.decline(f"operator {node.op}") + a, b = ctx.expr(node.left), ctx.expr(node.right) + if base.is_scalar and exponent.is_scalar: + return ast.BinOp(left=a, op=ast.Pow(), right=b) + if base.is_matrix and exponent.is_scalar: + value = exponent.value + if isinstance(value, int | float) and float(value).is_integer(): + return ctx.call(ctx.np("linalg.matrix_power"), a, ctx.const(int(value))) + ctx.decline("a matrix power with a non-integer or unknown exponent") + if exponent.is_scalar and base.kind.value in ("unknown", "array"): + ctx.assume(f"scalar base {ast.unparse(a)}") + return ast.BinOp(left=a, op=ast.Pow(), right=b) + ctx.decline("a matrix power with these shapes") + + +# --- Python -> .m ------------------------------------------------------------ +# +# ** is .^ (^ between scalars); np.linalg.matrix_power(A, k) is A ^ k. A +# fractional power of a negative array element is NaN in NumPy but complex on +# the .m side, so such a power is assumed to stay in the real domain. + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``**`` and ``np.linalg.matrix_power``.""" + loc = ctx.loc(node) + if isinstance(node, ast.Call): + if len(node.args) != 2 or node.keywords or not ctx.info(node.args[0]).is_matrix: + ctx.decline("matrix_power with these arguments") + return ctx.binop("mpower", ctx.expr(node.args[0]), ctx.expr(node.args[1]), loc=loc) + assert isinstance(node, ast.BinOp) + base, exponent = ctx.info(node.left), ctx.info(node.right) + if base.is_bool and exponent.is_bool: + ctx.decline("a power of booleans") + if base.is_array and not base.nonneg and exponent.dtype.value not in ("int", "bool"): + ctx.assume("non-negative base or integer exponent") + op = "mpower" if base.is_scalar and exponent.is_scalar else "power" + return ctx.binop(op, ctx.expr(node.left), ctx.expr(node.right), loc=loc) diff --git a/rules/operators/short-circuit/cases/basic.m b/rules/operators/short-circuit/cases/basic.m new file mode 100644 index 0000000..2639441 --- /dev/null +++ b/rules/operators/short-circuit/cases/basic.m @@ -0,0 +1,12 @@ +x = [5 0 3]; +n = 0; +guarded = n > 0 && x(n) > 1; % x(0) is never evaluated +n = 2; +second_big = n > 0 && x(n) > 1; +flag = isempty(x) || x(1) == 5; +a = [1 -1 2 -2]; +b = [-1 -1 2 2]; +both = a > 0 & b > 0; +either = a > 0 | b > 0; +num_and = [1 2] & [2 2]; % logical, not bitwise +one = xor(true, false); diff --git a/rules/operators/short-circuit/cases/basic.py b/rules/operators/short-circuit/cases/basic.py new file mode 100644 index 0000000..620cfb8 --- /dev/null +++ b/rules/operators/short-circuit/cases/basic.py @@ -0,0 +1,14 @@ +import numpy as np + +x = np.array([5, 0, 3]) +n = 0 +guarded = n > 0 and x[n - 1] > 1 # x[-1] is never evaluated +n = 2 +second_big = n > 0 and x[n - 1] > 1 +flag = x.size == 0 or x[0] == 5 +a = np.array([1, -1, 2, -2]) +b = np.array([-1, -1, 2, 2]) +both = (a > 0) & (b > 0) +either = (a > 0) | (b > 0) +num_and = np.logical_and([1, 2], [2, 2]) # & would be bitwise: [0, 2] +one = np.logical_xor(True, False) diff --git a/rules/operators/short-circuit/rule.yaml b/rules/operators/short-circuit/rule.yaml new file mode 100644 index 0000000..857c4ec --- /dev/null +++ b/rules/operators/short-circuit/rule.yaml @@ -0,0 +1,43 @@ +id: operators/short-circuit +title: "`&&`/`||` (short-circuit) vs `&`/`|` (element-wise)" +status: mechanical +dialects: [octave, matlab] +match: [op:andand, op:oror, op:and, op:or, call:xor] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:boolop:and + - py:boolop:or + - py:op:bitand + - py:op:bitor + - py:call:np.logical_and + - py:call:np.logical_or + - py:call:np.logical_xor +octave: | + if n > 0 && x(n) > 1, ... end + ok = a > 0 | b > 0; % element-wise +python: | + if n > 0 and x[n - 1] > 1: ... + ok = (a > 0) | (b > 0) +why: > + `&&`/`||` work on scalars and stop as soon as the result is known: they are + `and`/`or`. `&`/`|` are element-wise on arrays: NumPy's `&`/`|`. In Python + those bind tighter than comparisons, so every comparison needs parentheses. +pitfalls: + - >- + `a > 0 & b > 0` in Python parses as the chained comparison + `a > (0 & b) > 0`; always parenthesize each comparison. + - >- + `and`/`or` on NumPy arrays raise "truth value of an array is ambiguous"; + use `&`/`|` or `np.logical_and`/`np.logical_or`. + - >- + `&`/`|` on integer (not bool) arrays are bitwise in NumPy: + `np.array([1, 2]) & np.array([2, 2])` is `[0, 2]`, while Octave's `&` gives + `[1 1]`. Use `np.logical_and` for numbers. + - >- + Inside an `if`/`while` condition, MATLAB also short-circuits `&` and `|`; + do not translate code that relies on that for side effects without care. + - >- + `xor(a, b)` is `np.logical_xor(a, b)`; Python's `^` is bitwise. +related: [operators/not-equal, indexing/logical, control-flow/if-elseif] +python_imports: [import numpy as np] diff --git a/rules/operators/short-circuit/translate.py b/rules/operators/short-circuit/translate.py new file mode 100644 index 0000000..fce6b9b --- /dev/null +++ b/rules/operators/short-circuit/translate.py @@ -0,0 +1,82 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for operators/short-circuit: ``&&``, ``||``, ``&``, ``|``, ``xor``. + +``&&`` / ``||`` are ``and`` / ``or``; a non-logical operand is wrapped in +``bool()`` so the result is a truth value, as in the source (Python's ``and`` +returns an operand). ``&`` / ``|`` are NumPy's ``&`` / ``|`` on logical +operands and ``np.logical_and`` / ``np.logical_or`` otherwise, since ``&`` on +integers is bitwise. +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.lift import LiftContext + + +def _truth(node: ir.Expr, ctx: Context) -> ast.expr: + expr = ctx.expr(node) + return expr if ctx.info(node).is_logical else ctx.call(ast.Name("bool"), expr) + + +def translate(node: ir.BinOp | ir.Call, ctx: Context) -> ast.expr: + """One logical operation.""" + if isinstance(node, ir.Call): + if node.func != "xor" or len(node.args) != 2: + ctx.decline(f"call {node.func}") + return ctx.call(ctx.np("logical_xor"), *(ctx.arg(a) for a in node.args)) + if node.op in ("andand", "oror"): + op: ast.boolop = ast.And() if node.op == "andand" else ast.Or() + return ast.BoolOp(op=op, values=[_truth(node.left, ctx), _truth(node.right, ctx)]) + left, right = ctx.info(node.left), ctx.info(node.right) + if left.is_logical and right.is_logical: + a, b = ctx.module("operators/arithmetic").expand(node, ctx) + bit: ast.operator = ast.BitAnd() if node.op == "and" else ast.BitOr() + return ast.BinOp(left=a, op=bit, right=b) + func = "logical_and" if node.op == "and" else "logical_or" + return ctx.call(ctx.np(func), ctx.arg(node.left), ctx.arg(node.right)) + + +# --- Python -> .m ------------------------------------------------------------ +# +# `and`/`or` return one of their operands in Python; && and || return a +# logical. They agree when the operands are booleans, or when only the truth +# of the result is used (an if/while test). & and | are the element-wise +# operators on booleans (bitwise on integers: declined). np.logical_and/or +# are & and |, np.logical_xor is xor(). + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``and``, ``or``, ``&``, ``|`` and the ``np.logical_*`` functions.""" + loc = ctx.loc(node) + if isinstance(node, ast.BoolOp): + truth_only = ctx.in_condition + infos = [ctx.info(v) for v in node.values] + if any(i.is_array for i in infos): + ctx.decline("`and`/`or` of arrays") + if not truth_only and not all(i.is_bool for i in infos): + ctx.decline("`and`/`or` whose value (an operand, not a logical) is used") + op = "andand" if isinstance(node.op, ast.And) else "oror" + values = [ctx.expr(v) for v in node.values] + result = values[0] + for value in values[1:]: + result = ctx.binop(op, result, value, loc=loc) + return result + literals = ctx.module_for("syntax/array-literals") + if isinstance(node, ast.Call): + name = ctx.tag(node) + if len(node.args) != 2 or node.keywords: + ctx.decline(f"{name} with these arguments") + a, b = (literals.lift_items(arg, ctx) for arg in node.args) + if name == "py:call:np.logical_xor": + return ctx.call("xor", a, b, loc=loc) + op = "and" if name == "py:call:np.logical_and" else "or" + return ctx.binop(op, a, b, loc=loc) + assert isinstance(node, ast.BinOp) + if not (ctx.info(node.left).is_bool and ctx.info(node.right).is_bool): + ctx.decline("& or | of values not known to be boolean (bitwise on integers)") + op = "and" if isinstance(node.op, ast.BitAnd) else "or" + return ctx.binop(op, ctx.expr(node.left), ctx.expr(node.right), loc=loc) diff --git a/rules/operators/transpose/cases/basic.m b/rules/operators/transpose/cases/basic.m new file mode 100644 index 0000000..0b15f62 --- /dev/null +++ b/rules/operators/transpose/cases/basic.m @@ -0,0 +1,9 @@ +A = [1 2 3; 4 5 6]; +At = A'; +Z = [1+2i, 3-1i; 2i, 4]; +Zh = Z'; % conjugate transpose +Zt = Z.'; % plain transpose +z = [1+2i, 3-1i]; +zh = z'; +c = [1 2 3]'; +c_total = sum(c); diff --git a/rules/operators/transpose/cases/basic.py b/rules/operators/transpose/cases/basic.py new file mode 100644 index 0000000..cd4b62c --- /dev/null +++ b/rules/operators/transpose/cases/basic.py @@ -0,0 +1,11 @@ +import numpy as np + +A = np.array([[1, 2, 3], [4, 5, 6]]) +At = A.T +Z = np.array([[1 + 2j, 3 - 1j], [2j, 4]]) +Zh = Z.conj().T # conjugate transpose +Zt = Z.T # plain transpose +z = np.array([1 + 2j, 3 - 1j]) +zh = z.conj() # 1-D: nothing to flip, but the conjugate still applies +c = np.array([1, 2, 3]) +c_total = c.sum() diff --git a/rules/operators/transpose/rule.yaml b/rules/operators/transpose/rule.yaml new file mode 100644 index 0000000..349306d --- /dev/null +++ b/rules/operators/transpose/rule.yaml @@ -0,0 +1,33 @@ +id: operators/transpose +title: "`'` (conjugate transpose) vs `.'` (transpose)" +status: mechanical +dialects: [octave, matlab] +match: [op:ctranspose, op:transpose] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:attr:T + - py:method:conj + - py:call:np.conj + - py:call:np.transpose +octave: | + Ah = A'; % conjugate transpose + At = A.'; % plain transpose +python: | + Ah = A.conj().T + At = A.T +why: > + `'` is the *conjugate* transpose and `.'` the plain transpose; they differ + only for complex values. NumPy's `.T` never conjugates. For data known to be + real, `A'` is `A.T`; for complex or unknown data use `A.conj().T`. +pitfalls: + - >- + `.T` on a 1-D array does nothing: there is no row/column distinction to + flip. Use `v[:, np.newaxis]` when a 2-D column is really needed. + - >- + For a complex 1-D vector, `z'` still conjugates: `z.conj()`. + - >- + A quote right after a name, `)` or `]` is a transpose; elsewhere it starts + a string: `[x' y']` vs `['ab' 'cd']`. +related: [operators/matrix-multiply, indexing/colon-all] +python_imports: [import numpy as np] diff --git a/rules/operators/transpose/translate.py b/rules/operators/transpose/translate.py new file mode 100644 index 0000000..04864c1 --- /dev/null +++ b/rules/operators/transpose/translate.py @@ -0,0 +1,81 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for operators/transpose: ``'`` (conjugate) and ``.'``. + +A 1-D NumPy vector has no orientation, so transposing a vector changes +nothing but the facts the analysis tracks (it is a column now); only the +conjugation remains for complex data. A matrix gets ``.T`` (and ``.conj()`` +first when it may be complex). +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.infer import Kind +from dualect.lift import LiftContext + + +def translate(node: ir.Transpose, ctx: Context) -> ast.expr: + """``x'`` or ``x.'``.""" + info = ctx.info(node.operand) + operand = ctx.expr(node.operand) + conjugate = node.conjugate and not info.is_real + if info.is_scalar: + return ctx.call(ctx.np("conj"), operand) if conjugate else operand + if info.kind in (Kind.ROW, Kind.COL, Kind.VECTOR, Kind.EMPTY): + return ctx.method(operand, "conj") if conjugate else operand + if info.is_matrix: + if conjugate: + operand = ctx.method(operand, "conj") + return ast.Attribute(value=operand, attr="T") + if info.kind is Kind.STRING: + ctx.decline("transposing a char array") + # Unknown shape: np.conj / np.transpose work on scalars and arrays alike. + if conjugate: + operand = ctx.call(ctx.np("conj"), operand) + return ctx.call(ctx.np("transpose"), operand) + + +# --- Python -> .m ------------------------------------------------------------ +# +# .T of a 1-D array changes nothing (it is a row on the .m side either way); +# of a 2-D array it is .' (never ', which also conjugates). x.conj().T is x'. + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``.T``, ``.conj()``, ``np.conj`` and ``np.transpose``.""" + loc = ctx.loc(node) + if isinstance(node, ast.Attribute): # .T + inner = node.value + info = ctx.info(inner) + if info.is_vector or info.is_scalar: + return ctx.expr(inner) + if not info.is_matrix: + ctx.decline(".T of a value whose dimensions are unknown") + if ( + isinstance(inner, ast.Call) + and isinstance(inner.func, ast.Attribute) + and inner.func.attr == "conj" + and not inner.args + ): + return ir.Transpose(loc=loc, operand=ctx.expr(inner.func.value), conjugate=True) + return ir.Transpose(loc=loc, operand=ctx.expr(inner), conjugate=False) + assert isinstance(node, ast.Call) + name = ctx.tag(node) + if name == "py:method:conj": + assert isinstance(node.func, ast.Attribute) + if node.args: + ctx.decline("conj with arguments") + return ctx.call("conj", ctx.expr(node.func.value), loc=loc) + if len(node.args) != 1 or node.keywords: + ctx.decline(f"{name} with these arguments") + if name == "py:call:np.conj": + return ctx.call("conj", ctx.expr(node.args[0]), loc=loc) + info = ctx.info(node.args[0]) + if info.is_vector or info.is_scalar: + return ctx.expr(node.args[0]) + if not info.is_matrix: + ctx.decline("np.transpose of a value whose dimensions are unknown") + return ir.Transpose(loc=loc, operand=ctx.expr(node.args[0]), conjugate=False) diff --git a/rules/syntax/array-literals/cases/basic.m b/rules/syntax/array-literals/cases/basic.m new file mode 100644 index 0000000..2abb744 --- /dev/null +++ b/rules/syntax/array-literals/cases/basic.m @@ -0,0 +1,10 @@ +v = [1 2 3]; +c = [4; 5; 6]; % a column is 1-D in NumPy too +A = [1 2; 3 4]; +e = []; +neg = [1 -2]; % two elements +one = [1 - 2]; % one element: -1 +w = [v 4]; % concatenation, not nesting +x = 2; +row = [x, 2*x, x^2]; +B = [v; v]; % two rows stacked: 2x3 diff --git a/rules/syntax/array-literals/cases/basic.py b/rules/syntax/array-literals/cases/basic.py new file mode 100644 index 0000000..949301b --- /dev/null +++ b/rules/syntax/array-literals/cases/basic.py @@ -0,0 +1,12 @@ +import numpy as np + +v = np.array([1, 2, 3]) +c = np.array([4, 5, 6]) # a column is 1-D in NumPy too +A = np.array([[1, 2], [3, 4]]) +e = np.array([]) +neg = np.array([1, -2]) # two elements +one = 1 - 2 # one element: -1 +w = np.concatenate((v, [4])) # concatenation, not nesting +x = 2 +row = np.array([x, 2 * x, x**2]) +B = np.vstack((v, v)) # two rows stacked: 2x3 diff --git a/rules/syntax/array-literals/cases/columns.m b/rules/syntax/array-literals/cases/columns.m new file mode 100644 index 0000000..1b3d662 --- /dev/null +++ b/rules/syntax/array-literals/cases/columns.m @@ -0,0 +1,5 @@ +b = [1; 2; 3]; +A = [1 2; 3 4; 5 6]; +B = [b, b]; +C = [A, b]; +D = [b, A, b]; diff --git a/rules/syntax/array-literals/cases/columns.py b/rules/syntax/array-literals/cases/columns.py new file mode 100644 index 0000000..33fcf45 --- /dev/null +++ b/rules/syntax/array-literals/cases/columns.py @@ -0,0 +1,7 @@ +import numpy as np + +b = np.array([1, 2, 3]) +A = np.array([[1, 2], [3, 4], [5, 6]]) +B = np.column_stack((b, b)) +C = np.column_stack((A, b)) +D = np.column_stack((b, A, b)) diff --git a/rules/syntax/array-literals/rule.yaml b/rules/syntax/array-literals/rule.yaml new file mode 100644 index 0000000..69cd319 --- /dev/null +++ b/rules/syntax/array-literals/rule.yaml @@ -0,0 +1,52 @@ +id: syntax/array-literals +title: "Bracket literals: rows, columns, matrices, `[]` and concatenation" +status: mechanical +dialects: [octave, matlab] +match: [literal:matrix, literal:empty, expr:concat] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:call:np.array + - py:list + - py:tuple + - py:call:np.concatenate + - py:call:np.vstack + - py:call:np.column_stack +octave: | + v = [1 2 3]; % 1x3 row + c = [1; 2; 3]; % 3x1 column + A = [1 2; 3 4]; + e = []; + w = [v 4]; % concatenation +python: | + v = np.array([1, 2, 3]) + c = np.array([1, 2, 3]) + A = np.array([[1, 2], [3, 4]]) + e = np.array([]) + w = np.concatenate((v, [4])) +why: > + Brackets build a matrix: spaces or commas separate columns, semicolons or + newlines separate rows, and every value is at least 2-D. Idiomatic NumPy keeps + vectors 1-D, so a 1xN row and an Nx1 column both become `np.array([...])` and + only a real matrix gets nested lists. Elements that are arrays themselves are + concatenated, never nested: `[v 4]` is `np.concatenate((v, [4]))` and `[a; b]` + of two rows is `np.vstack((a, b))`. +pitfalls: + - >- + `[b, b]` of two columns is `np.column_stack((b, b))`, an Nx2 matrix; + `np.concatenate` of the 1-D vectors would give one long vector. + - >- + `[1 -2]` is two elements but `[1 - 2]` is one: inside brackets, a space + before a sign that is not followed by a space starts a new element. + - >- + A 1-D array has no orientation. Code that depends on row vs column + (broadcasting a column against a row, outer products) must say so + explicitly; see operators/arithmetic and operators/matrix-multiply. + - >- + A one-element literal `[x]` is just `x`. + - >- + Numbers in `.m` code are doubles, while `np.array([1, 2, 3])` holds + integers. That is fine for indexing and most arithmetic, but integer arrays + reject negative integer powers (see operators/power). +related: [operators/arithmetic, operators/transpose, indexing/grow-on-assign] +python_imports: [import numpy as np] diff --git a/rules/syntax/array-literals/translate.py b/rules/syntax/array-literals/translate.py new file mode 100644 index 0000000..55ce44a --- /dev/null +++ b/rules/syntax/array-literals/translate.py @@ -0,0 +1,149 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for syntax/array-literals: ``[...]`` literals and concatenation. + +Vectors become 1-D arrays (a row and a column alike), matrices nested lists, +a one-element literal its element, and ``[]`` an empty 1-D array. Elements +that are arrays are concatenated: a row of vectors and scalars with +``np.concatenate``, columns and matrices side by side with +``np.column_stack`` (a 1-D vector is taken as a column there), rows of equally +long rows with ``np.vstack``. +""" + +import ast + +from dualect import ir +from dualect.emit import Context +from dualect.infer import Kind +from dualect.lift import LiftContext + + +def translate(node: ir.Matrix, ctx: Context) -> ast.expr: + """One bracket literal.""" + if not node.rows: + return ctx.call(ctx.np("array"), ast.List(elts=[])) + infos = [[ctx.info(item) for item in row] for row in node.rows] + flat = [info for row in infos for info in row] + if any(info.kind is Kind.STRING for info in flat): + ctx.decline("a bracket literal mixing strings and numbers") + if all(info.is_scalar for info in flat): + if len(flat) == 1: + return ctx.expr(node.rows[0][0]) + if len(node.rows) == 1 or all(len(row) == 1 for row in node.rows): + items = [ctx.expr(item) for row in node.rows for item in row] + return ctx.call(ctx.np("array"), ast.List(elts=items)) + if len({len(row) for row in node.rows}) != 1: + ctx.decline("rows of different lengths") + rows = [ast.List(elts=[ctx.expr(item) for item in row]) for row in node.rows] + return ctx.call(ctx.np("array"), ast.List(elts=list(rows))) + return _concatenate(node, infos, ctx) + + +def _part(item: ir.Expr, ctx: Context) -> ast.expr: + """One piece of a concatenation: a scalar becomes a one-element list.""" + if ctx.info(item).is_scalar: + return ast.List(elts=[ctx.expr(item)]) + return ctx.expr(item) + + +def _concatenate(node: ir.Matrix, infos: list[list], ctx: Context) -> ast.expr: + rows = node.rows + if len(rows) == 1: + if all(info.kind in (Kind.ROW, Kind.SCALAR, Kind.EMPTY) for info in infos[0]): + parts = [_part(item, ctx) for item in rows[0]] + return ctx.call(ctx.np("concatenate"), ast.Tuple(elts=parts)) + kinds = {info.kind for info in infos[0]} + if kinds <= {Kind.COL, Kind.MATRIX}: + # 1-D vectors have no orientation; column_stack reads them as columns. + parts = [ctx.expr(item) for item in rows[0]] + return ctx.call(ctx.np("column_stack"), ast.Tuple(elts=parts)) + ctx.decline("horizontal concatenation mixing columns with rows or scalars") + if all(len(row) == 1 for row in rows): + kinds = {info.kind for row in infos for info in row} + if kinds <= {Kind.COL, Kind.SCALAR, Kind.EMPTY}: + parts = [_part(row[0], ctx) for row in rows] + return ctx.call(ctx.np("concatenate"), ast.Tuple(elts=parts)) + if kinds <= {Kind.ROW, Kind.MATRIX}: + widths = {info.cols for row in infos for info in row} + if None not in widths and len(widths) == 1: + parts = [ctx.expr(row[0]) for row in rows] + return ctx.call(ctx.np("vstack"), ast.Tuple(elts=parts)) + ctx.decline("this concatenation") + + +# --- Python -> .m ------------------------------------------------------------ +# +# A 1-D NumPy array is a 1xN row on the .m side, a list of lists a matrix. +# np.concatenate of 1-D parts is [a, b]; of 2-D parts (axis 0) [A; B]; +# np.vstack stacks rows, np.column_stack turns 1-D parts into columns. + + +def lift_items(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """A list (or tuple) of scalars as a row, of equal rows as a matrix; else the value.""" + loc = ctx.loc(node) + if not isinstance(node, ast.List | ast.Tuple): + return ctx.expr(node) + elts = node.elts + if all(isinstance(e, ast.List | ast.Tuple) for e in elts) and elts: + rows = [[ctx.expr(x) for x in row.elts] for row in elts] # type: ignore[attr-defined] + if len({len(row) for row in rows}) != 1: + ctx.decline("rows of different lengths") + if not all(ctx.info(x).is_scalar for row in elts for x in row.elts): # type: ignore[attr-defined] + ctx.decline("a nested list of arrays") + return ir.Matrix(loc=loc, rows=rows) + if not all(ctx.info(e).is_scalar for e in elts): + ctx.decline("a list of arrays") + return ir.Matrix(loc=loc, rows=[[ctx.expr(e) for e in elts]] if elts else []) + + +def _parts(node: ast.Call, ctx: LiftContext) -> list[ast.expr]: + if len(node.args) != 1 or node.keywords or not isinstance(node.args[0], ast.Tuple | ast.List): + ctx.decline(f"{ast.unparse(node.func)} with these arguments") + return list(node.args[0].elts) + + +def lift(node: ast.expr, ctx: LiftContext) -> ir.Expr: + """``np.array``, a list argument, and the stacking functions.""" + loc = ctx.loc(node) + if isinstance(node, ast.List): + return lift_items(node, ctx) + if not isinstance(node, ast.Call): + ctx.decline("a tuple used as a value") + name = ctx.tag(node) + if name == "py:call:np.array": + if len(node.args) != 1 or node.keywords: + ctx.decline("np.array with a dtype or other options") + return lift_items(node.args[0], ctx) + parts = _parts(node, ctx) + infos = [ctx.info(p) for p in parts] + lifted = [lift_items(p, ctx) for p in parts] + one_d = all( + i.is_vector or i.is_scalar or isinstance(p, ast.List) + for i, p in zip(infos, parts, strict=True) + ) + two_d = all(i.is_matrix for i in infos) + if name == "py:call:np.concatenate": + if one_d: + return ir.Matrix(loc=loc, rows=[lifted]) + if two_d: + return ir.Matrix(loc=loc, rows=[[part] for part in lifted]) + ctx.decline("concatenating values of unknown or mixed dimensions") + if name == "py:call:np.vstack": + if all( + i.is_vector or i.is_matrix or isinstance(p, ast.List) + for i, p in zip(infos, parts, strict=True) + ): + return ir.Matrix(loc=loc, rows=[[part] for part in lifted]) + ctx.decline("vstack of values of unknown dimensions") + if name == "py:call:np.column_stack": + columns: list[ir.Expr] = [] + for info, part, value in zip(infos, parts, lifted, strict=True): + if info.is_matrix: + columns.append(value) + elif info.is_vector or isinstance(part, ast.List): + columns.append(ctx.transpose(value)) + else: + ctx.decline("column_stack of a value of unknown dimensions") + return ir.Matrix(loc=loc, rows=[columns]) + ctx.decline(f"{name}") diff --git a/rules/syntax/command-syntax/cases/basic.m b/rules/syntax/command-syntax/cases/basic.m new file mode 100644 index 0000000..59b242e --- /dev/null +++ b/rules/syntax/command-syntax/cases/basic.m @@ -0,0 +1,9 @@ +% Command syntax: every word after the command name is passed as a string. +a = 5; +b = 7; +c = 9; +format long % display only: no numeric effect +clear a b % same as clear('a', 'b') +words = 'a b'; % what clear received: text, not values +n_words = numel(strsplit(words, ' ')); +format short diff --git a/rules/syntax/command-syntax/cases/basic.py b/rules/syntax/command-syntax/cases/basic.py new file mode 100644 index 0000000..fa9cb04 --- /dev/null +++ b/rules/syntax/command-syntax/cases/basic.py @@ -0,0 +1,11 @@ +# Command syntax: every word after the command name is passed as a string. +import numpy as np + +a = 5 +b = 7 +c = 9 +np.set_printoptions(precision=16) # format long: display only +del a, b # clear a b +words = "a b" # what clear received: text, not values +n_words = len(words.split(" ")) +np.set_printoptions(precision=8) # format short: back to NumPy's default diff --git a/rules/syntax/command-syntax/rule.yaml b/rules/syntax/command-syntax/rule.yaml new file mode 100644 index 0000000..b0d208c --- /dev/null +++ b/rules/syntax/command-syntax/rule.yaml @@ -0,0 +1,32 @@ +id: syntax/command-syntax +title: "Command syntax: `name arg1 arg2` vs `name('arg1', 'arg2')`" +status: guided +dialects: [octave, matlab] +match: [syntax:command] +octave: | + hold on % hold('on') + format long % format('long') + clear a b % clear('a', 'b') +python: | + # hold on: matplotlib keeps adding to the current axes by default + np.set_printoptions(precision=16) + del a, b +why: > + A statement `name word1 word2` calls `name('word1', 'word2')`: every word is + passed as a literal string, never evaluated. Rewrite it in function form + first, then translate the call. Many commands (`hold`, `format`, `more`, + `clc`, `close all`) only change display state and have no numeric effect. +pitfalls: + - >- + `disp x` prints the letter x, not the value of `x`. + - >- + `a -1` is `a - 1` when `a` is a variable but `a('-1')` when `a` is a + function: whitespace decides, so check what the name is. + - >- + Command syntax cannot return a value: `x = load data.txt` is an error; it + must be `x = load('data.txt')`. + - >- + `clear` alone empties the whole workspace and `clear all` also drops + functions; in a translated script these usually become nothing at all. +related: [functions/definition] +python_imports: [import numpy as np] diff --git a/rules/syntax/comments/cases/basic.m b/rules/syntax/comments/cases/basic.m new file mode 100644 index 0000000..ac81fa6 --- /dev/null +++ b/rules/syntax/comments/cases/basic.m @@ -0,0 +1,12 @@ +% Every comment form; the arithmetic shows that none of them was executed. +x = 1; % trailing comment +# Octave also accepts hash comments +%{ +x = 100; +%} +#{ +x = 200; +#} +%% a cell divider is a comment too +y = x + 1; % y = 50 would be ignored here +fmt = '%d items'; % a percent sign inside a string is not a comment diff --git a/rules/syntax/comments/cases/basic.py b/rules/syntax/comments/cases/basic.py new file mode 100644 index 0000000..d4072c7 --- /dev/null +++ b/rules/syntax/comments/cases/basic.py @@ -0,0 +1,8 @@ +# Every comment form; the arithmetic shows that none of them was executed. +x = 1 # trailing comment +# Octave also accepts hash comments +# x = 100 (was a %{ ... %} block) +# x = 200 (was a #{ ... #} block) +# %% a cell divider is a comment too +y = x + 1 # y = 50 would be ignored here +fmt = "%d items" # a percent sign inside a string is not a comment diff --git a/rules/syntax/comments/rule.yaml b/rules/syntax/comments/rule.yaml new file mode 100644 index 0000000..3ac62e1 --- /dev/null +++ b/rules/syntax/comments/rule.yaml @@ -0,0 +1,36 @@ +id: syntax/comments +title: "Comments: `%`, `#`, and `%{ ... %}` blocks" +status: mechanical +dialects: [octave, matlab] +match: [syntax:comment, syntax:hash-comment, syntax:block-comment] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:comment +octave: | + x = 1; % trailing comment + # line comment (Octave only) + %{ + block comment + %} +python: | + x = 1 # trailing comment + # line comment + # block comment, one '#' per line +why: > + `%` starts a comment in both dialects and Octave also accepts `#`. A block + comment is `%{` ... `%}` (or `#{` ... `#}`), each marker alone on its line. + Python has only `#`: a block becomes consecutive `#` lines, not a string + literal, which would be an expression statement. +pitfalls: + - >- + `%` inside a string is not a comment: `fmt = '%d items'` keeps the `%`. + - >- + `#` comments and `#{ ... #}` blocks are Octave only; MATLAB rejects them. + - >- + `%{` opens a block only when nothing else is on its line; otherwise it is an + ordinary line comment. + - >- + A `%%` line marks a code cell; keep it as `# %%` so editors still see cells. +related: [syntax/line-continuation] +python_imports: [] diff --git a/rules/syntax/comments/translate.py b/rules/syntax/comments/translate.py new file mode 100644 index 0000000..aa8c005 --- /dev/null +++ b/rules/syntax/comments/translate.py @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for syntax/comments: ``%`` / ``#`` comments and ``%{ ... %}`` blocks. + +A comment becomes ``# text``; a block becomes one ``#`` line per line (never a +string literal, which would be an expression statement); a ``%%`` cell divider +stays a cell divider, ``# %%``. Comments on a statement's line are attached by +the emitter. +""" + +import ast + +from dualect import ir +from dualect.emit import Context, Line +from dualect.lift import LiftContext + + +def translate(stmt: ir.Comment, ctx: Context) -> list[Line]: + """One comment statement.""" + lines = stmt.text.split("\n") if stmt.block else [stmt.text] + return [ctx.line(f"# {line}".rstrip()) for line in lines] + + +# --- Python -> .m ------------------------------------------------------------ +# +# `# text` is `% text`, on its own line or after a statement; a docstring +# becomes comment lines. The engine places comments (dualect.lift); `dualect:` +# verify directives are never copied, since they describe the source pairing. + + +def lift(node: ast.AST, ctx: LiftContext) -> ir.Expr: + """Never called: comments are placed by the engine.""" + ctx.decline("a comment is not an expression") diff --git a/rules/syntax/line-continuation/cases/basic.m b/rules/syntax/line-continuation/cases/basic.m new file mode 100644 index 0000000..ab1e8cd --- /dev/null +++ b/rules/syntax/line-continuation/cases/basic.m @@ -0,0 +1,8 @@ +total = 1 + 2 + ... this text is a comment + 3; +v = [1, 2, ... + 3]; +M = [1 2 + 3 4]; % a newline inside brackets starts a new row +w = [1 2 ... + 3 4]; % ... joins the lines into one row diff --git a/rules/syntax/line-continuation/cases/basic.py b/rules/syntax/line-continuation/cases/basic.py new file mode 100644 index 0000000..0495078 --- /dev/null +++ b/rules/syntax/line-continuation/cases/basic.py @@ -0,0 +1,10 @@ +import numpy as np + +total = ( + 1 + + 2 # this text is a comment + + 3 +) +v = np.array([1, 2, 3]) +M = np.array([[1, 2], [3, 4]]) # a newline inside brackets starts a new row +w = np.array([1, 2, 3, 4]) # ... joins the lines into one row diff --git a/rules/syntax/line-continuation/rule.yaml b/rules/syntax/line-continuation/rule.yaml new file mode 100644 index 0000000..4d6e8e6 --- /dev/null +++ b/rules/syntax/line-continuation/rule.yaml @@ -0,0 +1,31 @@ +id: syntax/line-continuation +title: "Line continuation with `...`" +status: mechanical +dialects: [octave, matlab] +match: [syntax:continuation] +octave: | + total = a + b + ... + c; + v = [1, 2, ... + 3]; +python: | + total = (a + b + + c) + v = np.array([1, 2, + 3]) +why: > + `...` joins the next line to the current one, and anything after it on the + same line is a comment. Python continues lines implicitly inside brackets, + so wrap a long expression in parentheses instead of using a backslash. +pitfalls: + - >- + Inside `[ ]` or `{ }` a newline *without* `...` starts a new row: + `[1 2` newline `3 4]` is a 2x2 matrix, while `[1 2 ...` newline `3 4]` is a + 1x4 row. + - >- + Old Octave versions also accepted a backslash as continuation outside + strings; Octave 11 rejects it. Treat it as unsupported, not as `...`. + - >- + Text after `...` is a comment even if it looks like code. +related: [syntax/comments] +python_imports: [import numpy as np] diff --git a/rules/syntax/line-continuation/translate.py b/rules/syntax/line-continuation/translate.py new file mode 100644 index 0000000..031133e --- /dev/null +++ b/rules/syntax/line-continuation/translate.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for syntax/line-continuation: ``...``. + +There is nothing left to translate by the time a statement reaches the +emitter: the parser joins continued lines into one statement, and the text +after ``...`` becomes the statement's trailing comment. ruff then wraps long +Python lines inside parentheses. This module exists so the rule can be +``mechanical``; its construct never reaches :func:`translate`. +""" + +from dualect import ir +from dualect.emit import Context + + +def translate(node: ir.Node, ctx: Context) -> None: + """Never called: continuations do not survive parsing.""" + ctx.decline("a line continuation is not a node") diff --git a/rules/types/char-strings/cases/basic.m b/rules/types/char-strings/cases/basic.m new file mode 100644 index 0000000..c30809d --- /dev/null +++ b/rules/types/char-strings/cases/basic.m @@ -0,0 +1,7 @@ +name = 'beam'; +label = ['span of ', name]; +n = numel(name); +same = strcmp(name, 'beam'); +quote = 'it''s'; +first = name(1); +tabbed = "a\tb"; % Octave reads escapes in double quotes diff --git a/rules/types/char-strings/cases/basic.py b/rules/types/char-strings/cases/basic.py new file mode 100644 index 0000000..c2483b7 --- /dev/null +++ b/rules/types/char-strings/cases/basic.py @@ -0,0 +1,7 @@ +name = "beam" +label = "span of " + name +n = len(name) +same = name == "beam" +quote = "it's" +first = name[0] +tabbed = "a\tb" # Octave reads escapes in double quotes diff --git a/rules/types/char-strings/rule.yaml b/rules/types/char-strings/rule.yaml new file mode 100644 index 0000000..dd4027f --- /dev/null +++ b/rules/types/char-strings/rule.yaml @@ -0,0 +1,37 @@ +id: types/char-strings +title: "Char arrays `'...'` and double-quoted strings" +status: mechanical +dialects: [octave, matlab] +match: [literal:string, literal:dq-string, expr:string-concat, call:strcmp] +from_python: # the Python -> .m direction + status: mechanical + match: + - py:str +octave: | + name = 'beam'; + label = ['span of ', name]; + same = strcmp(name, 'beam'); +python: | + name = "beam" + label = "span of " + name + same = name == "beam" +why: > + A single-quoted literal is a char row vector; Python's `str` covers what + numeric code does with it. Concatenation is bracket syntax (`[a, b]`), which + is `a + b` for Python strings, and `strcmp` is `==`. Inside single quotes a + quote is doubled (`'it''s'`). Indexing a string is one-based like any array. +pitfalls: + - >- + `a == b` on two char arrays compares character by character (and fails when + the lengths differ); string equality is `strcmp`, which is `==` in Python. + - >- + Double-quoted strings differ by dialect: Octave makes a char array and reads + backslash escapes (`"a\tb"` has a tab), MATLAB (R2016b+) makes a `string` + object and does not. + - >- + `numel(s)` is `len(s)`, not `s.size`. + - >- + Char arrays are numbers underneath: `'a' + 1` is 98. Python raises instead; + use `ord('a') + 1`. +related: [syntax/array-literals, builtins/size-numel-length] +python_imports: [] diff --git a/rules/types/char-strings/translate.py b/rules/types/char-strings/translate.py new file mode 100644 index 0000000..9b28cac --- /dev/null +++ b/rules/types/char-strings/translate.py @@ -0,0 +1,86 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Translator for types/char-strings: string literals, ``[a, b]`` and ``strcmp``. + +A literal becomes a Python ``str`` (its escapes were resolved when parsing, +per dialect); bracket concatenation of strings is ``+``; ``strcmp(a, b)`` is +``a == b`` when both are strings. +""" + +import ast +from functools import reduce + +from dualect import ir +from dualect.emit import Context +from dualect.infer import Kind +from dualect.lift import LiftContext +from dualect.pyinfer import PyKind + + +def translate(node: ir.Str | ir.Matrix | ir.Call, ctx: Context) -> ast.expr: + """A string literal, a string concatenation or ``strcmp``.""" + if isinstance(node, ir.Str): + return ast.Constant(node.value) + if isinstance(node, ir.Matrix): + if len(node.rows) != 1: + ctx.decline("stacking strings into a char matrix") + parts = [ctx.expr(item) for item in node.rows[0]] + return reduce(lambda a, b: ast.BinOp(left=a, op=ast.Add(), right=b), parts) + if node.func == "strcmp" and len(node.args) == 2: + if all(ctx.info(arg).kind is Kind.STRING for arg in node.args): + a, b = (ctx.expr(arg) for arg in node.args) + return ast.Compare(left=a, ops=[ast.Eq()], comparators=[b]) + ctx.decline("strcmp on values not known to be strings") + ctx.decline(f"call {node.func}") + + +# --- Python -> .m ------------------------------------------------------------ +# +# A str literal is a single-quoted char array (quotes doubled); a + b of two +# strings is [a, b]; a == b of two strings compares the whole text, strcmp(a, +# b) (== on char arrays compares character by character). Control characters +# would need escapes the two dialects read differently, so they are written +# with char(): "a\tb" is ['a', char(9), 'b']. + + +def lift(node: ast.AST, ctx: LiftContext) -> ir.Expr: + """A string literal.""" + assert isinstance(node, ast.Constant) and isinstance(node.value, str) + loc = ctx.loc(node) + text = node.value + if not any(ord(c) < 32 or ord(c) == 127 for c in text): + return ir.Str(loc=loc, value=text, quote="'") + # ['a', char(9), 'b']: the same characters in either dialect, no escapes. + parts: list[ir.Expr] = [] + run = "" + for char in text: + if ord(char) < 32 or ord(char) == 127: + if run: + parts.append(ir.Str(loc=loc, value=run, quote="'")) + run = "" + parts.append(ctx.call("char", ctx.num(ord(char)), loc=loc)) + else: + run += char + if run: + parts.append(ir.Str(loc=loc, value=run, quote="'")) + return ir.Matrix(loc=loc, rows=[parts]) + + +def lift_concat(node: ast.BinOp, ctx: LiftContext) -> ir.Expr: + """``a + b`` of two strings.""" + if not isinstance(node.op, ast.Add): + ctx.decline("this operation on strings") + if not all(ctx.info(x).kind is PyKind.STRING for x in (node.left, node.right)): + ctx.decline("adding a string and a value that is not a string") + return ir.Matrix(loc=ctx.loc(node), rows=[[ctx.expr(node.left), ctx.expr(node.right)]]) + + +def lift_compare(node: ast.Compare, ctx: LiftContext) -> ir.Expr: + """``a == b`` (or ``!=``, negated by the caller) of two strings.""" + left, right = node.left, node.comparators[0] + if not isinstance(node.ops[0], ast.Eq | ast.NotEq): + ctx.decline("ordering strings") + if not all(ctx.info(x).kind is PyKind.STRING for x in (left, right)): + ctx.decline("comparing a string with a value that is not a string") + return ctx.call("strcmp", ctx.expr(left), ctx.expr(right), loc=ctx.loc(node)) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..aa091f2 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Shared pytest setup. + +Tests that execute .m code carry ``@pytest.mark.octave``. They are skipped when +Octave is not installed, so the rest of the suite runs anywhere. CI sets +``DUALECT_REQUIRE_OCTAVE=1`` so a missing Octave fails loudly there instead of +turning every execution test into a silent skip. +""" + +import os +from collections.abc import Iterator +from pathlib import Path + +import pytest + +from dualect.runners import MRunner, m_runtime_available + +REQUIRE_ENV = "DUALECT_REQUIRE_OCTAVE" +REPO_ROOT = Path(__file__).resolve().parent.parent +RULES_DIR = REPO_ROOT / "rules" +DATA_DIR = Path(__file__).resolve().parent / "data" + + +def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]) -> None: + """Skip Octave tests when Octave is absent, unless the environment demands it.""" + if m_runtime_available() or os.environ.get(REQUIRE_ENV): + return + skip = pytest.mark.skip(reason="GNU Octave is not installed") + for item in items: + if "octave" in item.keywords: + item.add_marker(skip) + + +@pytest.fixture(scope="session") +def m_runner() -> Iterator[MRunner]: + """One Octave session for the whole run; starting Octave costs about a second.""" + with MRunner() as runner: + yield runner diff --git a/tests/data/beam.m b/tests/data/beam.m new file mode 100644 index 0000000..571c320 --- /dev/null +++ b/tests/data/beam.m @@ -0,0 +1,11 @@ +% Cantilever beam with an end load: tip deflection and the deflection curve. +% Hand-written pair used to check the verify harness itself (milestone 1). +E = 200e9; % Young's modulus [Pa] +Iz = 8.33e-6; % second moment of area [m^4] +L = 2.0; % length [m] +P = 1000; % end load [N] +x = linspace(0, L, 5); +w = P .* x.^2 .* (3*L - x) ./ (6*E*Iz); +tip = w(end); +[wmax, imax] = max(w); +% dualect: index imax diff --git a/tests/data/beam.py b/tests/data/beam.py new file mode 100644 index 0000000..3cc72dc --- /dev/null +++ b/tests/data/beam.py @@ -0,0 +1,13 @@ +# Cantilever beam with an end load: tip deflection and the deflection curve. +# Hand-written twin of beam.m used to check the verify harness itself. +import numpy as np + +E = 200e9 # Young's modulus [Pa] +Iz = 8.33e-6 # second moment of area [m^4] +L = 2.0 # length [m] +P = 1000 # end load [N] +x = np.linspace(0, L, 5) +w = P * x**2 * (3 * L - x) / (6 * E * Iz) +tip = w[-1] +imax = int(np.argmax(w)) +wmax = w[imax] diff --git a/tests/test_adversarial.py b/tests/test_adversarial.py new file mode 100644 index 0000000..3600d00 --- /dev/null +++ b/tests/test_adversarial.py @@ -0,0 +1,154 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Adversarial probes of the ``.m`` -> Python engine: never silently wrong. + +Each snippet here once translated to code that ran but computed something +else (or is a near neighbour of one that did). The rule is the project's +central promise: a translation is either right, verified by running both +sides, or it is a named hole (guided/unsupported) in the report. The +``VERIFIES`` snippets must translate completely and verify against the +interpreter; the ``DECLINES`` snippets must leave the named statement as a hole. +""" + +from pathlib import Path + +import pytest +from conftest import RULES_DIR + +from dualect.dialect import Dialect +from dualect.pipeline import translate_file, translate_text +from dualect.rulebook import Status, load_rules +from dualect.runners import MRunner + +RULES = load_rules(rules_dir=RULES_DIR) + +#: Snippets that must translate completely and verify by execution. +VERIFIES: dict[str, str] = { + # 1-D vectors: orientation matters for products, transposes, concatenation. + "vectors": ( + "b = [1; 2; 3];\nr = [4 5 6];\nA = [1 2 3; 4 5 6; 7 8 10];\n" + "outer_bb = b * b';\ninner_bb = b' * b;\nrt = r';\nrr = [r; r];\nbb = [b, b];\n" + "Ab_ = [A, b];\nsb = size(b);\nsr = size(r);\nbc = b(:);\nrc = r(:);\n" + "Ab = A * b;\nAsb = A \\ b;\nrA = r * A;\na = b' * A;\nc = A * r';\nd = r * r';\n" + "k = A(:, 1) * A(1, :);\nm = A(1, :) * A(:, 1);\ns = A(:, 1) + A(1, :);\n" + "v = A \\ r';\nw = r / A;\n" + ), + "vector-into-function": ( + "1;\nfunction y = f(v)\n y = v * v';\nend\nb = [1; 2; 3];\nyb = f(b);\n" + ), + "precedence": ( + "x = [1 2 3];\ny = [4 5 6];\na = -2^-2;\nb = 2^3';\nc = x.^-1;\nd = ~x == 0;\n" + "e = 1:3+2;\nf = -x';\ng = [1 -2];\nh = [1 - 2];\nk = [x' y'];\nn = 2^-1^2;\n" + "o = -x.^2;\np = x(2)^2;\nq = ~x(1) + 1;\ns = 1 - - 1;\nt = [1 -2 +3];\n" + "u = [x -1];\nv = 3 - 2 - 1;\nw = 12 / 3 / 2;\nz = x .* y + x ./ y - 2;\n" + ), + "number-dot-operators": ( + "x = [2 3];\nb = 2.^x;\nA = [1 2; 3 4];\nB = 2.^A;\nC = 3.*A;\nD = 1.5.^x;\nE = 2./x;\n" + ), + "end-in-nested-index": ( + "x = [10 20 30 40 50];\ny = [1 2 3];\nA = [1 2 3; 4 5 6; 7 8 9];\n" + "a = x(y(end));\nb = x(min(end, 4));\nc = x(end-1);\nd = A(end, end-1);\n" + "e = A(end);\nf = x(end:-1:1);\ng = x(end:-2:1);\nh = x(3:-1:1);\nk = A(:, end);\n" + "m = x(2:end-1);\no = A(end, :);\np = A(2:end, 1);\nq = x(end-2:end);\n" + "r = x([1 end]);\ns = x(y(end-1):end);\nt = A(end-1:end, end-1:end);\n" + ), + "ranges": ( + "a = 5:-1:1;\nb = 1:0.5:3;\nc = 0:0.1:1;\nd = 1:0;\ne = 5:1;\nf = 1:-1:5;\n" + "h = -3:-1;\nk = 10:-3:1;\nn = 0:-0.25:-1;\no = numel(1:0);\np = 3:3;\n" + ), + "logical-arithmetic": ( + "x = [1 2 3];\na = true + 1;\nm = x > 1;\nb = m + m;\nc = m * 2;\nd = sum(m);\n" + "e = ~[1 0 2];\nf = true & 1;\ng = m .* m;\nh = (x > 1) + 0;\nn = m | false;\n" + "p = 3 > 2;\nq = p + p;\nr = x(m);\ns = ~p;\nt = -m;\nu = m(2) + m(3);\n" + "v = m .^ 2;\nw = m' * m;\n" + ), + "integer-overflow": ( + "x = [2 3];\na = x .^ 40;\nb = x / 2;\nc = 7 / 2;\nd = floor(7 / 2);\n" + "e = mod(-7, 3);\nf = rem(-7, 3);\ng = prod([100000 100000 100000 100000]);\n" + "h = x .^ 70;\nk = 2 .^ (1:70);\nn = 3;\np = x .^ n;\n" + ), + "loops": ( + "s = 0;\nfor k = 1:3\n k = k * 2;\n s = s + k;\nend\nA = [1 2; 3 4];\nt = 0;\n" + "for c = A\n t = t + c(1) * 10 + c(2);\nend\nB = [1 2; 3 4];\nfor c = B\n" + " c(1) = 0;\nend\nw = 0;\nfor v = [3 1 2]\n w = w * 10 + v;\nend\n" + "cnt = 0;\nfor i = 5:-1:1\n cnt = cnt + i;\nend\n" + ), + "lambda-same-shapes": ("f = @(x) x * x';\nb = [1; 2; 3];\na1 = f(b);\na2 = f(2 * b);\n"), +} + +#: Snippets whose given (1-based) line must become a hole, not a guess. +DECLINES: dict[str, tuple[str, int]] = { + # A lambda translated once cannot follow whichever call came last. + "lambda-row-and-column": ("f = @(x) x * x';\nr = [1 2 3];\nb = [1; 2; 3];\n" + "a1 = f(r);\na2 = f(b);\n", 1), + "lambda-size-row-and-column": ("f = @(x) size(x, 1);\nb = [1; 2; 3];\nr = [1 2 3];\n" + "a1 = f(b);\na2 = f(r);\n", 1), + # A function called with both orientations: `u * v` has no single `@` form. + "function-row-and-column": ("1;\nfunction y = op(u, v)\n y = u * v;\nend\nb = [1; 2; 3];\n" + "r = [4 5 6];\no1 = op(b, r);\no2 = op(r, b);\n", 3), + "mod-by-zero": ("m = mod(-1, 0);\n", 1), + "empty-loop": ("z = 0;\nfor j = 1:0\n z = z + 1;\nend\n", 2), +} # fmt: skip + + +@pytest.mark.parametrize("name", sorted(VERIFIES)) +def test_probe_translates_completely(name: str) -> None: + result = translate_text(text=VERIFIES[name], name="p.m", rules=RULES, dialect=Dialect()) + assert result.complete, result.report() + + +@pytest.mark.octave +@pytest.mark.parametrize("name", sorted(VERIFIES)) +def test_probe_verifies(name: str, tmp_path: Path, m_runner: MRunner) -> None: + source = tmp_path / "probe.m" + source.write_text(VERIFIES[name], encoding="utf-8") + result = translate_file( + source=source, output=tmp_path / "probe.py", rules=RULES, dialect=Dialect(), runner=m_runner + ) + assert result.verified, result.report() + + +@pytest.mark.parametrize("name", sorted(DECLINES)) +def test_probe_is_a_named_hole(name: str) -> None: + text, line = DECLINES[name] + result = translate_text(text=text, name="p.m", rules=RULES, dialect=Dialect()) + holes = [h for h in result.holes if h.loc.line == line] + assert holes, result.report() + assert all(h.status is not Status.MECHANICAL and h.reason for h in holes) + + +def test_lambda_body_follows_every_call() -> None: + # The body is annotated for the join of all calls, not the last one. + code = translate_text( + text=VERIFIES["lambda-same-shapes"], name="p.m", rules=RULES, dialect=Dialect() + ).code + assert "np.outer(x, x)" in code + + +def test_logical_operands_become_numbers() -> None: + code = translate_text( + text="m = [1 2 3] > 1;\nb = m + m;\n", name="p.m", rules=RULES, dialect=Dialect() + ).code + assert "b = m.astype(int) + m" in code + + +def test_loop_over_matrix_copies_a_written_column() -> None: + code = translate_text( + text="B = [1 2; 3 4];\nfor c = B\n c(1) = 0;\nend\n", + name="p.m", + rules=RULES, + dialect=Dialect(), + ).code + assert "for c in B.T.copy():" in code + + +def test_assumptions_stay_on_their_own_statement() -> None: + code = translate_text( + text="1;\nfunction c = f(a, b)\n c = a * b;\nend\n", + name="p.m", + rules=RULES, + dialect=Dialect(), + ).code + header = next(line for line in code.splitlines() if line.startswith("def f")) + assert "assumed" not in header diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..ffc009c --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""The ``dualect`` command line.""" + +from pathlib import Path + +import pytest +from conftest import DATA_DIR, RULES_DIR + +from dualect.cli import EXIT_FAILED, EXIT_OK, main +from dualect.paths import RULES_DIR_ENV, default_rules_dir +from dualect.rulebook import load_rule +from dualect.validate import validate_rule_dir + + +def test_rules_list(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None: + main(["rules", "--rules-dir", str(tmp_path), "new", "indexing/foo"]) + capsys.readouterr() + assert main(["rules", "--rules-dir", str(tmp_path), "list"]) == EXIT_OK + out = capsys.readouterr().out + assert "indexing/foo" in out + assert "unsupported" in out + + +def test_rules_list_repository(capsys: pytest.CaptureFixture[str]) -> None: + assert main(["rules", "--rules-dir", str(RULES_DIR), "list", "--status", "guided"]) == EXIT_OK + out = capsys.readouterr().out + assert "indexing/grow-on-assign" in out + assert "builtins/find" not in out + + +def test_rules_list_status_filter(capsys: pytest.CaptureFixture[str]) -> None: + assert main(["rules", "--rules-dir", str(RULES_DIR), "list", "--status", "mechanical"]) == 0 + out = capsys.readouterr().out + assert "indexing/end-in-index" in out + assert "indexing/grow-on-assign" not in out + assert main(["rules", "--rules-dir", str(RULES_DIR), "list", "--status", "unsupported"]) == 0 + assert "no rules found" in capsys.readouterr().err + + +def test_default_rules_dir_is_the_repository(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.delenv(RULES_DIR_ENV, raising=False) + assert default_rules_dir() == RULES_DIR + + +def test_rules_new_scaffolds_a_loadable_rule(tmp_path: Path) -> None: + assert main(["rules", "--rules-dir", str(tmp_path), "new", "indexing/foo-bar"]) == EXIT_OK + rule_dir = tmp_path / "indexing" / "foo-bar" + assert validate_rule_dir(rule_dir=rule_dir) == [] + rule = load_rule(rule_dir=rule_dir) + assert rule.id == "indexing/foo-bar" + assert [case.name for case in rule.cases] == ["basic"] + + +@pytest.mark.parametrize("rule_id", ["Indexing/foo", "foo", "a/b/c", "indexing/foo_bar"]) +def test_rules_new_rejects_bad_ids( + rule_id: str, tmp_path: Path, capsys: pytest.CaptureFixture[str] +) -> None: + assert main(["rules", "--rules-dir", str(tmp_path), "new", rule_id]) == EXIT_FAILED + assert "invalid rule id" in capsys.readouterr().err + + +def test_rules_new_refuses_to_overwrite(tmp_path: Path) -> None: + assert main(["rules", "--rules-dir", str(tmp_path), "new", "syntax/x"]) == EXIT_OK + assert main(["rules", "--rules-dir", str(tmp_path), "new", "syntax/x"]) == EXIT_FAILED + + +@pytest.mark.octave +def test_verify_command(capsys: pytest.CaptureFixture[str]) -> None: + code = main(["verify", str(DATA_DIR / "beam.m"), str(DATA_DIR / "beam.py")]) + out = capsys.readouterr().out + assert code == EXIT_OK, out + assert out.rstrip().endswith("PASS") diff --git a/tests/test_compare.py b/tests/test_compare.py new file mode 100644 index 0000000..8eb2ea1 --- /dev/null +++ b/tests/test_compare.py @@ -0,0 +1,89 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Value comparison rules (no Octave needed: values are built by hand).""" + +import numpy as np +import pytest + +from dualect.compare import Tolerance, compare_values +from dualect.runners import CallableValue + +TOL = Tolerance() + + +def same(m_value: object, py_value: object, *, index: bool = False) -> bool: + return compare_values(m_value=m_value, py_value=py_value, tolerance=TOL, index=index) is None + + +def test_row_vector_equals_1d_array() -> None: + assert same(np.array([[1.0, 2.0, 3.0]]), np.array([1, 2, 3])) + + +def test_column_vector_equals_1d_array() -> None: + assert same(np.array([[1.0], [2.0]]), np.array([1.0, 2.0])) + + +def test_matrix_shape_must_match() -> None: + assert not same(np.ones((2, 3)), np.ones((3, 2))) + + +def test_values_within_tolerance() -> None: + assert same(1.0, 1.0 + 1e-13) + assert not same(1.0, 1.001) + + +def test_nan_equals_nan_but_not_number() -> None: + assert same(np.array([np.nan, 1.0]), np.array([np.nan, 1.0])) + reason = compare_values(m_value=np.nan, py_value=1.0, tolerance=TOL) + assert reason is not None and "NaN" in reason + + +def test_empty_arrays_equal_regardless_of_shape() -> None: + assert same([], np.array([])) + assert same(np.zeros((1, 0)), np.zeros((0,))) + + +def test_logical_vs_numeric_is_a_difference() -> None: + reason = compare_values( + m_value=np.array([True, False]), py_value=np.array([1, 0]), tolerance=TOL + ) + assert reason is not None and "logical" in reason + assert same(np.array([True, False]), np.array([True, False])) + + +def test_int_vs_float_is_not_a_difference() -> None: + assert same(3.0, 3) + + +def test_index_values_are_shifted() -> None: + assert same(np.array([[1.0, 4.0]]), np.array([0, 3]), index=True) + assert not same(np.array([[1.0, 4.0]]), np.array([1, 4]), index=True) + + +def test_strings() -> None: + assert same("abc", "abc") + assert not same("abc", "abd") + assert not same("1", 1.0) + + +def test_struct_and_dict() -> None: + assert same({"a": 1.0, "b": "x"}, {"a": 1, "b": "x"}) + assert not same({"a": 1.0}, {"a": 1.0, "b": 2.0}) + + +def test_cell_and_list() -> None: + cell = np.empty((1, 2), dtype=object) + cell[0, 0], cell[0, 1] = 1.0, "a" + assert same(cell, [1, "a"]) + assert not same(cell, [1]) + + +def test_callables_only_agree_on_being_callable() -> None: + assert same(CallableValue(description="@(x) x"), CallableValue(description="lambda")) + assert not same(CallableValue(description="@(x) x"), 1.0) + + +@pytest.mark.parametrize("value", [1 + 2j, np.array([1 + 1j, 2])]) +def test_complex(value: object) -> None: + assert same(value, value) diff --git a/tests/test_corpus.py b/tests/test_corpus.py new file mode 100644 index 0000000..6ea54a1 --- /dev/null +++ b/tests/test_corpus.py @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Testing layer 3 (docs/design.md section 7): the combination corpus. + +Each ``corpus/*.m`` file is a realistic multi-construct script run through the +whole pipeline. A file the engine cannot fully translate is an honest result, +not a failure: the test checks that every untranslated statement is reported +and left as a hole, and that a *complete* translation verifies against the +interpreter, since a complete translation that does not verify means a +mechanical rule translated something wrong. +""" + +import ast +from pathlib import Path + +import pytest +from conftest import REPO_ROOT, RULES_DIR + +from dualect import ir +from dualect.dialect import Dialect +from dualect.pipeline import UNVERIFIED, translate_file +from dualect.rulebook import load_rules +from dualect.runners import MRunner + +RULES = load_rules(rules_dir=RULES_DIR) +CORPUS = sorted((REPO_ROOT / "corpus").glob("*.m")) + + +def test_corpus_exists() -> None: + names = {path.stem for path in CORPUS} + assert {"beam_deflection", "ode_rk4", "signal_filter"} <= names + + +@pytest.mark.parametrize("source", CORPUS, ids=lambda path: path.stem) +def test_corpus_translation_is_honest(source: Path, tmp_path: Path) -> None: + output = tmp_path / f"{source.stem}.py" + result = translate_file( + source=source, output=output, rules=RULES, dialect=Dialect(), verify=False + ) + text = output.read_text(encoding="utf-8") + ast.parse(text) + # Every top-level statement is accounted for in the report. + reported = {(s.loc.line, s.kind) for s in result.statements} + for stmt in result.scan.program.body: + assert (stmt.loc.line, type(stmt).__name__) in reported + assert text.count("raise NotImplementedError(") == len(result.holes) + assert UNVERIFIED in text.splitlines()[0] + + +@pytest.mark.octave +@pytest.mark.parametrize("source", CORPUS, ids=lambda path: path.stem) +def test_corpus_complete_translations_verify( + source: Path, tmp_path: Path, m_runner: MRunner +) -> None: + result = translate_file( + source=source, + output=tmp_path / f"{source.stem}.py", + rules=RULES, + dialect=Dialect(), + runner=m_runner, + ) + if result.complete: + assert result.verified, result.report() + else: + assert not result.verified + assert all(s.reason for s in result.holes) + mechanical = len(result.statements) - len(result.holes) + print(f"{source.name}: {mechanical}/{len(result.statements)} statements mechanical") + + +@pytest.mark.octave +@pytest.mark.parametrize("source", CORPUS, ids=lambda path: path.stem) +def test_corpus_sources_run(source: Path, m_runner: MRunner) -> None: + assert m_runner.run(path=source) + + +def test_corpus_statements_are_all_lowered() -> None: + for source in CORPUS: + from dualect.lower import lower_source + + program = lower_source(text=source.read_text(encoding="utf-8"), name=source.name) + opaque = [s for s in ir.walk_stmts(program.body) if isinstance(s, ir.OpaqueStmt)] + assert opaque == [], source.name diff --git a/tests/test_milestone6.py b/tests/test_milestone6.py new file mode 100644 index 0000000..3d30002 --- /dev/null +++ b/tests/test_milestone6.py @@ -0,0 +1,146 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Milestone 6: the MCP server, the promotion check and ``llms.txt``. + +The MCP tools are called in-process through the SDK's own ``call_tool``, as a +client would call them, without starting a subprocess. The promotion check +(docs/design.md section 4.3) runs over every rule in both directions: a rule +marked ``mechanical`` that does not earn it fails the suite, and so does a +``guided`` rule that does. ``llms.txt`` must match what the rules generate. +""" + +import asyncio +import json +import shutil +from pathlib import Path +from typing import Any + +import pytest +from conftest import REPO_ROOT, RULES_DIR + +from dualect.cli import EXIT_FAILED, EXIT_OK, main +from dualect.llmstxt import render_llms_txt +from dualect.mcp_server import build_server +from dualect.promotion import check_rules, same_m_code +from dualect.rulebook import DIRECTIONS, Status, load_rules + +RULES = load_rules(rules_dir=RULES_DIR) +SERVER = build_server(rules_dir=RULES_DIR) + + +def _call(name: str, **arguments: Any) -> dict[str, Any]: + result = asyncio.run(SERVER.call_tool(name, arguments)) + assert not getattr(result, "is_error", False), result + structured = getattr(result, "structured_content", None) + if structured is None: + structured = json.loads(result.content[0].text) # type: ignore[union-attr] + return dict(structured) + + +# --- MCP server ------------------------------------------------------------------ + + +def test_mcp_lists_exactly_the_four_tools() -> None: + tools = asyncio.run(SERVER.list_tools()) + assert sorted(tool.name for tool in tools) == ["get_rule", "scan", "translate", "verify"] + + +def test_mcp_scan() -> None: + case = RULES_DIR / "builtins" / "find" / "cases" / "basic.m" + result = _call("scan", path=str(case)) + assert "builtins/find" in {rule["id"] for rule in result["rules"]} + assert result["direction"] == "to-python" + + +def test_mcp_get_rule() -> None: + result = _call("get_rule", rule_id="indexing/end-in-index", cases=1) + assert result["status"] == {"to-python": "mechanical", "from-python": "mechanical"} + assert "x(end)" in result["markdown"] and "```python" in result["markdown"] + + +def test_mcp_get_rule_unknown_is_an_error() -> None: + with pytest.raises(Exception, match="no rule"): + asyncio.run(SERVER.call_tool("get_rule", {"rule_id": "nope/nothing"})) + + +def test_mcp_translate_without_verifying() -> None: + case = RULES_DIR / "control-flow" / "while" / "cases" / "basic.py" + result = _call("translate", path=str(case), verify=False) + assert result["complete"] and not result["verified"] + assert result["output"] is None + assert result["text"].startswith("% Translated from basic.py by dualect. UNVERIFIED") + + +@pytest.mark.octave +def test_mcp_translate_and_verify(tmp_path: Path) -> None: + case = RULES_DIR / "indexing" / "ranges" / "cases" / "basic.m" + output = tmp_path / "ranges.py" + result = _call("translate", path=str(case), output=str(output)) + assert result["verified"], result["report"] + assert output.read_text(encoding="utf-8") == result["text"] + checked = _call("verify", m_file=str(case), py_file=str(output)) + assert checked["ok"], checked["report"] + + +# --- promotion check ----------------------------------------------------------------- + + +@pytest.mark.parametrize("direction", DIRECTIONS) +def test_declared_mechanical_rules_qualify_without_execution(direction: str) -> None: + results = check_rules(rules=RULES, directions=(direction,), verify=False) + problems = [r.line() for r in results if r.declared is Status.MECHANICAL and r.problem] + assert problems == [] + + +@pytest.mark.octave +def test_every_rule_earns_its_status_in_both_directions() -> None: + results = check_rules(rules=RULES, verify=True) + problems = [r.line() for r in results if r.problem] + assert problems == [] + + +def test_check_fails_for_a_mechanical_rule_that_does_not_qualify( + tmp_path: Path, capsys: pytest.CaptureFixture[str] +) -> None: + rules_dir = tmp_path / "rules" + shutil.copytree(RULES_DIR, rules_dir, ignore=shutil.ignore_patterns("__pycache__")) + case = rules_dir / "operators" / "power" / "cases" / "basic.py" + case.write_text(case.read_text(encoding="utf-8").replace("Q = A**2", "Q = A @ A")) + code = main( + ["rules", "--rules-dir", str(rules_dir), "check", "operators/power", + "--direction", "to-python", "--no-verify"] + ) # fmt: skip + assert code == EXIT_FAILED + assert "marked mechanical but does not qualify" in capsys.readouterr().out + + +def test_check_command_passes_on_the_repository(capsys: pytest.CaptureFixture[str]) -> None: + assert main(["rules", "check", "indexing/ranges", "--no-verify"]) == EXIT_OK + assert "0 with a status problem" in capsys.readouterr().out + + +def test_m_layer2_compares_structure_not_layout() -> None: + assert same_m_code("x = [1 2 3];\ny = x(end);\n", "x = [1, 2, 3]; % note\ny = x(end);\n") + assert not same_m_code("y = x(1);\n", "y = x(2);\n") + + +# --- llms.txt ---------------------------------------------------------------------- + + +def test_llms_txt_is_current() -> None: + committed = (REPO_ROOT / "llms.txt").read_text(encoding="utf-8") + assert committed == render_llms_txt(rules=RULES), "run: uv run dualect llms-txt -o llms.txt" + + +def test_llms_txt_has_one_line_per_rule() -> None: + text = render_llms_txt(rules=RULES) + lines = [line for line in text.splitlines() if line.startswith("- [")] + assert len(lines) == len(RULES) + assert all(f"[{rule.id}]" in text for rule in RULES) + + +def test_llms_txt_command(tmp_path: Path) -> None: + output = tmp_path / "llms.txt" + assert main(["llms-txt", "-o", str(output)]) == EXIT_OK + assert output.read_text(encoding="utf-8") == render_llms_txt(rules=RULES) diff --git a/tests/test_reverse.py b/tests/test_reverse.py new file mode 100644 index 0000000..dc8f4b4 --- /dev/null +++ b/tests/test_reverse.py @@ -0,0 +1,215 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Milestone 5: Python -> ``.m`` through the shared IR. + +Every rule case's ``.py`` is translated to ``.m``; a complete translation must +verify by execution against the original ``.py``, and an incomplete one must +report each hole by name. The corpus runs in reverse too: each ``corpus/*.m`` +is translated to Python and that Python back to ``.m``. Python constructs +outside the subset are reported as unsupported by name, and Python behaviours +with no ``.m`` counterpart (aliasing views, writes into arguments, late-binding +lambdas, ...) are declined rather than translated as if they did not exist. +""" + +from pathlib import Path + +import pytest +from conftest import REPO_ROOT, RULES_DIR + +from dualect.cli import EXIT_OK, main +from dualect.dialect import Dialect +from dualect.pipeline import UNVERIFIED, translate_file, translate_python_text +from dualect.rulebook import CasePair, Rule, Status, load_rules +from dualect.runners import MRunner +from dualect.scan import scan_file + +RULES = load_rules(rules_dir=RULES_DIR) +ALL_CASES = [(rule, case) for rule in RULES for case in rule.cases] +CORPUS = sorted((REPO_ROOT / "corpus").glob("*.m")) + + +def _id(item: tuple[Rule, CasePair]) -> str: + return f"{item[0].id}:{item[1].name}" + + +def _lift(text: str) -> str: + return translate_python_text(text=text, name="t.py", rules=RULES).code + + +def _holes(text: str) -> list[str]: + result = translate_python_text(text=text, name="t.py", rules=RULES) + return [h.reason for h in result.holes] + + +@pytest.mark.parametrize("item", ALL_CASES, ids=_id) +def test_every_case_lifts_or_reports_its_holes(item: tuple[Rule, CasePair]) -> None: + _rule, case = item + result = translate_python_text( + text=case.py_path.read_text(encoding="utf-8"), name=str(case.py_path), rules=RULES + ) + assert result.text().count("error('dualect: line") == len(result.holes) + assert all(h.reason for h in result.holes) + if result.holes: + assert UNVERIFIED in result.header() + + +@pytest.mark.octave +@pytest.mark.parametrize("item", ALL_CASES, ids=_id) +def test_complete_case_translations_verify( + item: tuple[Rule, CasePair], tmp_path: Path, m_runner: MRunner +) -> None: + _rule, case = item + result = translate_file( + source=case.py_path, + output=tmp_path / f"{case.name}.m", + rules=RULES, + dialect=Dialect(), + runner=m_runner, + ) + if result.complete: + assert result.verified, result.report() + else: + assert not result.verified + + +@pytest.mark.octave +@pytest.mark.parametrize("source", CORPUS, ids=lambda path: path.stem) +def test_corpus_round_trip(source: Path, tmp_path: Path, m_runner: MRunner) -> None: + python = tmp_path / f"{source.stem}.py" + forward = translate_file( + source=source, output=python, rules=RULES, dialect=Dialect(), runner=m_runner + ) + back = translate_file( + source=python, + output=tmp_path / f"{source.stem}_back.m", + rules=RULES, + dialect=Dialect(), + runner=m_runner, + ) + mechanical = len(back.statements) - len(back.holes) + print( + f"{source.name}: forward complete={forward.complete}; " + f"back {mechanical}/{len(back.statements)}" + ) + if back.complete: + assert back.verified, back.report() + else: + assert all(h.reason for h in back.holes) + + +# --- honesty: named gaps, never a silent guess ----------------------------------- + + +@pytest.mark.parametrize( + ("source", "tag"), + [ + ("import scipy\n", "py:import:scipy"), + ("import numpy as np\ny = np.fft.fft([1, 2])\n", "py:call:np.fft.fft"), + ("try:\n x = 1\nexcept ValueError:\n x = 2\n", "py:stmt:try"), + ("xs = [k for k in range(3)]\n", "py:expr:ListComp"), + ("a = 1 < 2 < 3\n", "py:cmp:chain"), + ], +) +def test_unsupported_constructs_are_named(source: str, tag: str) -> None: + reasons = _holes(source) + assert reasons and tag in reasons[0] + + +@pytest.mark.parametrize( + ("source", "reason"), + [ + # y is a view of x: writing into y changes x in NumPy. + ("import numpy as np\nx = np.array([1, 2, 3])\ny = x\ny[0] = 5\n", "shares memory"), + ("import numpy as np\nx = np.array([1, 2, 3])\ny = x[0:2]\ny[0] = 5\n", "shares memory"), + # The caller's array changes in NumPy, never in .m code. + ( + "def f(a):\n a[0] = 1\n return a\nimport numpy as np\nv = f(np.array([1, 2]))\n", + "writing into the argument", + ), + # A .m function cannot see the script's variables. + ("k = 2\ndef f(x):\n return k * x\ny = f(3)\n", "module variable k"), + # Python reads k when the lambda is called; a .m handle captured it. + ("k = 2\nf = lambda t: k * t\nk = 10\ny = f(3)\n", "changes later"), + # A variable would hide the function on the .m side. + ("import numpy as np\nmax = 3\nx = np.array([1, 2])\ny = x.max()\n", "hide the function"), + # NumPy truncates a fraction stored into an integer array. + ("import numpy as np\nx = np.array([1, 2, 3])\nx[0] = 0.5\n", "truncates"), + # bool + bool is a logical OR in NumPy. + ("import numpy as np\nm = np.array([1, 2]) > 1\nb = m + m\n", "boolean arrays"), + # NumPy's max propagates NaN; the .m max skips it. + ("import numpy as np\nw = np.array([1, np.nan])\nm = w.max()\n", "NaN"), + # linspace with one point: NumPy gives the start, the .m side the end. + ("import numpy as np\nx = np.linspace(0, 1, 1)\n", "count of 1"), + # `and` returns an operand in Python. + ("a = 2\nb = 3\nc = a and b\n", "whose value"), + # Python's ~ on integers is bitwise. + ("x = 5\ny = ~x\n", "bitwise"), + # np.round rounds halves to even. + ("import numpy as np\nx = np.round(np.array([0.5, 1.5]))\n", "halves to even"), + ], # fmt: skip +) +def test_python_only_behaviour_is_declined(source: str, reason: str) -> None: + reasons = _holes(source) + assert any(reason in r for r in reasons), reasons + + +def test_one_d_arrays_are_rows() -> None: + code = _lift( + "import numpy as np\nA = np.array([[1, 2], [3, 4]])\nv = np.array([1, 1])\n" + "y = A @ v\nu = v @ A\nd = v @ v\no = np.outer(v, v)\nc = A[:, 0]\n" + ) + assert "y = (A * v.').';" in code + assert "u = v * A;" in code + assert "d = v * v.';" in code + assert "o = v.' * v;" in code + assert "c = A(:, 1).';" in code + + +def test_indices_shift_and_count_from_the_end() -> None: + code = _lift( + "import numpy as np\nx = np.array([1, 2, 3, 4])\na = x[0]\nb = x[-1]\nc = x[1:3]\n" + "d = x[::-1]\ne = x[-2:]\n" + ) + for line in ( + "a = x(1);", + "b = x(end);", + "c = x(2:3);", + "d = x(end:-1:1);", + "e = x(end - 1:end);", + ): + assert line in code + + +def test_unknown_index_sign_is_assumed_out_loud() -> None: + code = _lift( + "import numpy as np\ndef f(x, i):\n return x[i]\n" + "k = -1 + 1\ny = f(np.array([1, 2]), k)\n" + ) + assert "% dualect: assumed non-negative index i" in code + + +def test_verify_directives_are_not_copied() -> None: + code = _lift("i = 1 # dualect: index i\n# dualect: ignore i\nj = 2 # a note\n") + assert "dualect: index" not in code and "dualect: ignore" not in code + assert "j = 2; % a note" in code + + +def test_scan_and_context_read_python(tmp_path: Path) -> None: + source = tmp_path / "s.py" + source.write_text("import numpy as np\nx = np.zeros(3)\nprint(x)\n", encoding="utf-8") + result = scan_file(path=source, rules=RULES, dialect=Dialect()) + ids = {rule.id for rule in result.needed_rules()} + assert {"builtins/zeros-ones-eye", "io/display"} <= ids + assert result.as_json()["direction"] == "from-python" + assert result.status_of(next(r for r in RULES if r.id == "io/display")) is Status.GUIDED + + +@pytest.mark.octave +def test_translate_command_from_python(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None: + case = RULES_DIR / "control-flow" / "while" / "cases" / "basic.py" + output = tmp_path / "out.m" + assert main(["translate", str(case), "-o", str(output)]) == EXIT_OK + text = output.read_text(encoding="utf-8") + assert text.startswith("% Translated from basic.py by dualect; verified against the .py") + assert "verified: yes" in capsys.readouterr().out diff --git a/tests/test_rules.py b/tests/test_rules.py new file mode 100644 index 0000000..2f5c0cf --- /dev/null +++ b/tests/test_rules.py @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""The rule knowledge base: schema, conventions, and every case pair executed. + +Each case pair is its own test, so a failure names exactly one rule and case. +""" + +import pytest +from conftest import RULES_DIR + +from dualect.compare import Tolerance +from dualect.rulebook import CasePair, Rule, Status, load_rules +from dualect.runners import MRunner, run_py_script +from dualect.scaffold import PLACEHOLDER +from dualect.validate import validate_all, validate_rule_dir +from dualect.verify import options_for_pair, verify_pair + +RULES = load_rules(rules_dir=RULES_DIR) +CASES: list[tuple[Rule, CasePair]] = [(rule, case) for rule in RULES for case in rule.cases] + + +def _case_id(item: tuple[Rule, CasePair]) -> str: + rule, case = item + return f"{rule.id}:{case.name}" + + +#: Milestone 2 (docs/design.md section 11): the first rules, Octave -> Python. +MILESTONE_2 = { + "syntax/comments", "syntax/line-continuation", "syntax/command-syntax", + "indexing/one-based", "indexing/ranges", "indexing/end-in-index", "indexing/logical", + "indexing/grow-on-assign", "indexing/colon-all", + "operators/matrix-multiply", "operators/transpose", "operators/power", + "operators/not-equal", "operators/short-circuit", + "control-flow/for-columns", "control-flow/while", "control-flow/if-elseif", + "control-flow/switch", + "functions/definition", "functions/multiple-returns", "functions/nargin", + "builtins/zeros-ones-eye", "builtins/linspace", "builtins/size-numel-length", + "builtins/sum-mean-max", "builtins/find", +} # fmt: skip + + +def test_milestone_2_rules_exist() -> None: + assert {rule.id for rule in RULES} >= MILESTONE_2 + + +def test_whole_knowledge_base_validates() -> None: + assert validate_all(rules_dir=RULES_DIR) == [] + + +@pytest.mark.parametrize("rule", RULES, ids=lambda rule: rule.id) +def test_rule_folder_is_valid(rule: Rule) -> None: + assert validate_rule_dir(rule_dir=rule.path) == [] + + +@pytest.mark.parametrize("rule", RULES, ids=lambda rule: rule.id) +def test_rule_has_no_placeholders(rule: Rule) -> None: + # The scaffolder writes TODO markers; a rule that still has one is unfinished. + for path in [rule.path / "rule.yaml", *(p for c in rule.cases for p in (c.m_path, c.py_path))]: + assert PLACEHOLDER not in path.read_text(encoding="utf-8"), path + + +@pytest.mark.parametrize("rule", RULES, ids=lambda rule: rule.id) +def test_executable_rules_have_cases(rule: Rule) -> None: + if rule.status in (Status.GUIDED, Status.MECHANICAL): + assert rule.cases + + +@pytest.mark.parametrize("item", CASES, ids=_case_id) +def test_case_python_side_runs(item: tuple[Rule, CasePair]) -> None: + # Cheap check that needs no Octave: the hand-written NumPy runs cleanly. + _rule, case = item + assert run_py_script(path=case.py_path) + + +@pytest.mark.octave +@pytest.mark.parametrize("item", CASES, ids=_case_id) +def test_case_pair_matches(item: tuple[Rule, CasePair], m_runner: MRunner) -> None: + rule, case = item + tolerance = Tolerance(**rule.tolerance) + options = options_for_pair(m_path=case.m_path, py_path=case.py_path, tolerance=tolerance) + result = verify_pair(m_path=case.m_path, py_path=case.py_path, options=options, runner=m_runner) + assert result.ok, result.report() diff --git a/tests/test_scan.py b/tests/test_scan.py new file mode 100644 index 0000000..6bf5140 --- /dev/null +++ b/tests/test_scan.py @@ -0,0 +1,205 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Milestone 3: parsing (with the Octave dialect), lowering, scanning, context.""" + +from pathlib import Path + +import pytest +from conftest import RULES_DIR + +from dualect import ir +from dualect.cli import EXIT_OK, main +from dualect.context import build_context +from dualect.dialect import Dialect, DialectError, parse_dialect +from dualect.lower import lower_source +from dualect.rulebook import CasePair, Rule, load_rules +from dualect.scan import OCTAVE_ONLY_TAG, RuleIndex, scan_file, scan_text +from dualect.source import normalize + +RULES = load_rules(rules_dir=RULES_DIR) +CASES: list[tuple[Rule, CasePair]] = [(rule, case) for rule in RULES for case in rule.cases] +INDEX = RuleIndex(rules=RULES, dialect=Dialect()) + + +def _scan(text: str, dialect: Dialect | None = None) -> set[str]: + index = INDEX if dialect is None else RuleIndex(rules=RULES, dialect=dialect) + result = scan_text(text=text, name="t.m", index=index) + return {rule.id for rule in result.needed_rules()} + + +def _tags(text: str) -> set[str]: + result = scan_text(text=text, name="t.m", index=INDEX) + return {finding.tag for finding in result.findings} + + +@pytest.mark.parametrize("item", CASES, ids=lambda item: f"{item[0].id}:{item[1].name}") +def test_scanning_a_rule_case_finds_that_rule(item: tuple[Rule, CasePair]) -> None: + rule, case = item + result = scan_file(path=case.m_path, rules=RULES, dialect=Dialect()) + assert rule.id in {found.id for found in result.needed_rules()}, result.report() + + +@pytest.mark.parametrize("item", CASES, ids=lambda item: f"{item[0].id}:{item[1].name}") +def test_rule_cases_parse_without_errors(item: tuple[Rule, CasePair]) -> None: + # Every case uses only syntax the parser (plus normalization) understands. + _rule, case = item + result = scan_file(path=case.m_path, rules=RULES, dialect=Dialect()) + assert "parse:error" not in {f.tag for f in result.findings}, result.report() + + +# --- the Octave dialect in front of a grammar that only knows the other one --- + + +def test_normalize_keeps_lines_and_marks_features() -> None: + source = "x = 1; # note\nif a != b, c = !d; endif\nk += 2;\nn++;\n#{\nhidden\n#}\n" + normalized = normalize(source) + assert normalized.text.count("\n") == source.count("\n") + assert "#" not in normalized.text and "!" not in normalized.text + assert "endif" not in normalized.text + names = {feature.name for feature in normalized.features} + assert {"# comment", "!=", "! (not)", "endif", "+=", "++", "#{ #} block comment"} <= names + + +def test_normalize_leaves_strings_and_transposes_alone() -> None: + source = "s = '# not a comment != ok';\nt = \"it's #1\";\nu = x';\n" + assert normalize(source).text == source + + +def test_do_until_is_a_loop_not_two_commands() -> None: + program = lower_source(text="n = 0;\ndo\n n++;\nuntil n >= 3\n") + loop = program.body[1] + assert isinstance(loop, ir.DoUntil) + assert isinstance(loop.body[0], ir.AugAssign) + assert isinstance(loop.cond, ir.BinOp) and loop.cond.op == "ge" + assert loop.loc.line == 2 and loop.cond.loc.line == 4 + + +def test_stray_until_is_a_parse_error() -> None: + assert "parse:error" in _tags("x = 1;\nuntil x > 0\n") + + +@pytest.mark.parametrize( + ("text", "expected"), + [ + # The grammar nests these wrongly; the lowering rebuilds them. + ("y = -2 ^ 2;", "uminus(mpower(2, 2))"), + ("y = 2 ^ -2 ^ 2;", "mpower(mpower(2, uminus(2)), 2)"), + ("y = a == b & c;", "and(eq(a, b), c)"), + ("y = a.^b';", "ctranspose(power(a, b))"), + ("y = -x';", "uminus(ctranspose(x))"), + ("y = ~a == b;", "eq(not(a), b)"), + ("y = a | b && c;", "andand(or(a, b), c)"), + ("y = a - -b * c;", "minus(a, mtimes(uminus(b), c))"), + ], +) +def test_operator_precedence(text: str, expected: str) -> None: + program = lower_source(text="a = 1; b = 2; c = 3; x = 4;\n" + text) + stmt = program.body[-1] + assert isinstance(stmt, ir.Assign) + assert _render(stmt.value) == expected + + +def _render(node: ir.Expr) -> str: + match node: + case ir.BinOp(op=op, left=left, right=right): + return f"{op}({_render(left)}, {_render(right)})" + case ir.UnOp(op=op, operand=operand): + return f"{op}({_render(operand)})" + case ir.Transpose(operand=operand, conjugate=conjugate): + return f"{'ctranspose' if conjugate else 'transpose'}({_render(operand)})" + case ir.Name(id=name): + return name + case ir.Num(text=text): + return text + raise AssertionError(node) + + +def test_unparsable_text_is_reported_not_dropped() -> None: + result = scan_text(text="x = 1;\ny = (2 + ;\nz = 3;\n", name="t.m", index=INDEX) + errors = [f for f in result.findings if f.tag == "parse:error"] + assert errors and errors[0].loc.line == 2 + assert errors[0].unsupported + + +# --- scanning ----------------------------------------------------------------- + + +def test_index_versus_call_is_resolved_by_assignment() -> None: + program = lower_source(text="x = [1 2 3];\na = x(2);\nb = numel(x);\n") + first, second = program.body[1], program.body[2] + assert isinstance(first, ir.Assign) and isinstance(first.value, ir.Index) + assert isinstance(second, ir.Assign) and isinstance(second.value, ir.Call) + + +def test_unknown_builtin_is_named_as_unsupported() -> None: + result = scan_text(text="w = strsplit('a b', ' ');\n", name="t.m", index=INDEX) + gaps = result.unsupported() + assert [gap.tag for gap in gaps] == ["call:strsplit"] + assert gaps[0].rule is None and gaps[0].loc.line == 1 + assert "call:strsplit" in result.report() + + +def test_struct_and_cell_access_are_named() -> None: + tags = _tags("s.a = 1;\nc = {1, 2};\nv = c{1};\n") + assert {"expr:field", "literal:cell", "expr:cell-index"} <= tags + + +def test_semantic_tags_use_inferred_facts() -> None: + tags = _tags("x = [1 2 3];\nm = x > 1;\ny = x(m);\nx(end+1) = 4;\nz = [];\nz(3) = 1;\n") + assert {"index:logical", "assign:grow"} <= tags + # An in-range element assignment does not grow the array. + assert "assign:grow" not in _tags("x = zeros(1, 3);\nx(2) = 5;\n") + # A loop's later iterations must not make an undefined array look defined. + assert "assign:grow" in _tags("for i = 1:3\n A(i) = i;\nend\n") + + +def test_matlab_dialect_rejects_octave_only_syntax() -> None: + text = "x = 1; # hash comment\nx += 1;\n" + result = scan_text( + text=text, name="t.m", index=RuleIndex(rules=RULES, dialect=parse_dialect("matlab")) + ) + tags = [f.tag for f in result.unsupported()] + assert OCTAVE_ONLY_TAG in tags + # The Octave-only rule for `+=` does not apply to the matlab dialect. + assert "op:augassign" in tags + assert "operators/augmented-assignment" in _scan(text) + + +def test_dialect_versions_filter_rules() -> None: + data = {"dialects": ["matlab"], "since": {"matlab": "R2016b"}, "until": None} + assert parse_dialect("matlab@R2023a").allows(data) + assert not parse_dialect("matlab@R2016a").allows(data) + assert not parse_dialect("octave").allows(data) + with pytest.raises(DialectError): + parse_dialect("fortran") + with pytest.raises(DialectError): + parse_dialect("matlab@2023") + + +# --- context -------------------------------------------------------------------- + + +def test_context_contains_exactly_the_needed_rules(tmp_path: Path) -> None: + source = tmp_path / "t.m" + source.write_text("x = linspace(0, 1, 5);\ny = strsplit('a b', ' ');\n", encoding="utf-8") + result = scan_file(path=source, rules=RULES, dialect=Dialect()) + text = build_context(result=result) + needed = {rule.id for rule in result.needed_rules()} + assert "builtins/linspace" in needed + for rule in RULES: + assert (f"## {rule.id} (" in text) == (rule.id in needed), rule.id + assert "id: builtins/linspace" in text # the rule.yaml itself + assert "x = linspace(0, 1, 5);" in text # a case, .m side + assert "np.linspace(0, 1, 5)" in text # and its Python twin + assert "call:strsplit at 2:5" in text + + +def test_scan_and_context_commands(capsys: pytest.CaptureFixture[str]) -> None: + case = RULES_DIR / "builtins" / "find" / "cases" / "basic.m" + assert main(["scan", str(case)]) == EXIT_OK + assert "builtins/find" in capsys.readouterr().out + assert main(["scan", "--json", str(case)]) == EXIT_OK + assert '"id": "builtins/find"' in capsys.readouterr().out + assert main(["context", str(case)]) == EXIT_OK + assert "## builtins/find" in capsys.readouterr().out diff --git a/tests/test_translate.py b/tests/test_translate.py new file mode 100644 index 0000000..ee3e041 --- /dev/null +++ b/tests/test_translate.py @@ -0,0 +1,219 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Milestone 4: deterministic translators and the translate pipeline. + +Testing layer 2 (docs/design.md section 7): every case of every ``mechanical`` +rule translates, with no hole, to the same code as its hand-written ``.py`` +(compared after formatting, comments ignored), and the translation verifies +by execution against the ``.m`` side. +""" + +import ast +import difflib +from pathlib import Path + +import pytest +from conftest import RULES_DIR + +from dualect.cli import EXIT_FAILED, EXIT_INCOMPLETE, EXIT_OK, main +from dualect.dialect import Dialect, parse_dialect +from dualect.pipeline import UNVERIFIED, StrictModeError, translate_file, translate_text +from dualect.pyformat import normalized_code, same_code +from dualect.rulebook import CasePair, Rule, Status, load_rules +from dualect.runners import MRunner, run_py_script + +RULES = load_rules(rules_dir=RULES_DIR) +ALL_CASES = [(rule, case) for rule in RULES for case in rule.cases] +MECHANICAL = [(rule, case) for rule, case in ALL_CASES if rule.status is Status.MECHANICAL] + + +def _id(item: tuple[Rule, CasePair]) -> str: + return f"{item[0].id}:{item[1].name}" + + +def _translate(text: str, dialect: Dialect | None = None) -> str: + result = translate_text(text=text, name="t.m", rules=RULES, dialect=dialect or Dialect()) + return result.code + + +@pytest.mark.parametrize("item", MECHANICAL, ids=_id) +def test_translator_matches_hand_written_case(item: tuple[Rule, CasePair]) -> None: + _rule, case = item + result = translate_text( + text=case.m_path.read_text(encoding="utf-8"), + name=str(case.m_path), + rules=RULES, + dialect=Dialect(), + strict=True, + ) + expected = case.py_path.read_text(encoding="utf-8") + diff = "\n".join( + difflib.unified_diff( + normalized_code(expected).splitlines(), + normalized_code(result.code).splitlines(), + "hand-written", + "translated", + lineterm="", + ) + ) + assert same_code(result.code, expected), diff + + +@pytest.mark.octave +@pytest.mark.parametrize("item", MECHANICAL, ids=_id) +def test_translated_case_verifies( + item: tuple[Rule, CasePair], m_runner: MRunner, tmp_path: Path +) -> None: + _rule, case = item + result = translate_file( + source=case.m_path, + output=tmp_path / f"{case.name}.py", + rules=RULES, + dialect=Dialect(), + strict=True, + runner=m_runner, + ) + assert result.verified, result.report() + + +@pytest.mark.parametrize("item", ALL_CASES, ids=_id) +def test_every_case_translates_or_reports_its_holes(item: tuple[Rule, CasePair]) -> None: + _rule, case = item + result = translate_text( + text=case.m_path.read_text(encoding="utf-8"), + name=str(case.m_path), + rules=RULES, + dialect=Dialect(), + ) + ast.parse(result.text()) + assert result.text().count("raise NotImplementedError(") == len(result.holes) + if result.holes: + assert UNVERIFIED in result.header() + + +def test_guided_rules_are_not_secretly_mechanical() -> None: + # The promotion loop (docs/design.md section 4.3): a guided rule whose cases + # all translate cleanly to the hand-written code should be promoted. + ready = [] + for rule in RULES: + if rule.status is not Status.GUIDED or not rule.cases: + continue + results = [ + translate_text( + text=c.m_path.read_text(encoding="utf-8"), + name="c.m", + rules=RULES, + dialect=Dialect(), + ) + for c in rule.cases + ] + if all( + r.complete and same_code(r.code, c.py_path.read_text(encoding="utf-8")) + for r, c in zip(results, rule.cases, strict=True) + ): + ready.append(rule.id) + assert ready == [], f"promote to mechanical: {ready}" + + +# --- behavior that must never be silently wrong ------------------------------ + + +def test_holes_raise_and_say_why() -> None: + result = translate_text( + text="x = [1 2 3];\ny = strsplit('a b', ' ');\nz = x(2);\n", + name="t.m", + rules=RULES, + dialect=Dialect(), + ) + assert not result.complete + [hole] = result.holes + assert hole.status is Status.UNSUPPORTED and "call:strsplit" in hole.reason + assert "z = x[1]" in result.code # the rest is still translated + namespace: dict[str, object] = {} + with pytest.raises(NotImplementedError, match="line 2"): + exec(compile(result.code, "t.py", "exec"), namespace) + + +def test_strict_stops_and_writes_nothing(tmp_path: Path) -> None: + source = tmp_path / "s.m" + source.write_text("x = [1 2 3];\nx(end+1) = 4;\n", encoding="utf-8") + output = tmp_path / "s.py" + with pytest.raises(StrictModeError, match="indexing/grow-on-assign"): + translate_file(source=source, output=output, rules=RULES, dialect=Dialect(), strict=True) + assert not output.exists() + assert main(["translate", str(source), "-o", str(output), "--strict"]) == EXIT_FAILED + assert not output.exists() + + +def test_integer_arrays_are_not_silently_truncated() -> None: + # np.array([1, 2, 3]) holds integers; storing 0.5 into it would give 0. + result = translate_text( + text="x = [1 2 3];\nx(2) = 0.5;\n", name="t.m", rules=RULES, dialect=Dialect() + ) + [hole] = result.holes + assert "truncate" in hole.reason + assert "x[1] = 0" in _translate("x = [1 2 3];\nx(2) = 0;\n") + + +def test_assignment_copies_when_either_side_is_modified() -> None: + code = _translate("x = [1 2 3];\ny = x;\ny(1) = 0;\nz = x;\n") + assert "y = x.copy()" in code + assert "z = x\n" in code # z is never modified in place: no copy needed + + +def test_unknown_shapes_are_assumed_out_loud() -> None: + code = _translate("1;\nfunction c = f(a, b)\n c = a * b;\nend\n") + assert "a @ b" in code and "# dualect: assumed matrix multiply" in code + + +def test_column_against_row_gets_an_axis() -> None: + code = _translate("r = [1 2 3];\nc = [1; 2];\ng = c + r;\n") + assert "c[:, np.newaxis] + r" in code + + +def test_octave_only_syntax_is_unsupported_under_matlab() -> None: + result = translate_text( + text="n = 0;\nn += 1;\n", name="t.m", rules=RULES, dialect=parse_dialect("matlab") + ) + assert [h.status for h in result.holes] == [Status.UNSUPPORTED] + + +def test_float_literals_keep_their_spelling() -> None: + assert "E = 200e9" in _translate("E = 200e9;\n") + + +# --- end to end against the interpreter -------------------------------------- + + +@pytest.mark.octave +def test_precedence_survives_translation(tmp_path: Path, m_runner: MRunner) -> None: + # The grammar nests these wrongly; a wrong nesting would change the values. + source = tmp_path / "p.m" + source.write_text( + "a = -2 ^ 2;\nb = 2 ^ -2 ^ 2;\nx = [1 2 3];\nc = x == 2 & x > 1;\n" + "d = -x .^ 2;\ne = ~x == 0;\n", + encoding="utf-8", + ) + result = translate_file( + source=source, output=tmp_path / "p.py", rules=RULES, dialect=Dialect(), runner=m_runner + ) + assert result.verified, result.report() + + +@pytest.mark.octave +def test_translate_command(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None: + case = RULES_DIR / "control-flow" / "while" / "cases" / "basic.m" + output = tmp_path / "out.py" + assert main(["translate", str(case), "-o", str(output)]) == EXIT_OK + text = output.read_text(encoding="utf-8") + assert text.startswith("# Translated from basic.m by dualect; verified") + assert "verified: yes" in capsys.readouterr().out + run_py_script(path=output) + + +def test_translate_command_unverified(tmp_path: Path) -> None: + case = RULES_DIR / "control-flow" / "while" / "cases" / "basic.m" + output = tmp_path / "out.py" + assert main(["translate", str(case), "-o", str(output), "--no-verify"]) == EXIT_INCOMPLETE + assert UNVERIFIED in output.read_text(encoding="utf-8").splitlines()[0] diff --git a/tests/test_verify.py b/tests/test_verify.py new file mode 100644 index 0000000..f6260a8 --- /dev/null +++ b/tests/test_verify.py @@ -0,0 +1,109 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""The verify harness on hand-written pairs, and directive parsing.""" + +from pathlib import Path + +import pytest +from conftest import DATA_DIR + +from dualect.errors import DirectiveError, ExecutionError +from dualect.runners import MRunner, run_py_script +from dualect.verify import parse_directives, verify_pair + + +def test_parse_directives_both_comment_styles() -> None: + text = "% dualect: index i, j\n# dualect: ignore k\nx = 1;\n" + index_vars, ignore = parse_directives(text=text, path=Path("t.m")) + assert index_vars == {"i", "j"} + assert ignore == {"k"} + + +@pytest.mark.parametrize( + "line", ["% dualect: indexes i", "# dualect: ignore", "% dualect: index 1x"] +) +def test_bad_directive_is_an_error(line: str) -> None: + with pytest.raises(DirectiveError): + parse_directives(text=line, path=Path("t.m")) + + +def test_python_runner_drops_scaffolding(tmp_path: Path) -> None: + script = tmp_path / "s.py" + script.write_text( + "import numpy as np\nfrom math import sqrt\n_tmp = 1\n" + "def helper():\n return 1\nf = lambda t: t\nx = sqrt(4.0)\n" + ) + outputs = run_py_script(path=script) + assert set(outputs) == {"f", "x"} + + +def test_python_failure_is_named(tmp_path: Path) -> None: + script = tmp_path / "bad.py" + script.write_text("x = 1 / 0\n") + with pytest.raises(ExecutionError) as info: + run_py_script(path=script) + assert info.value.side == "py" + + +@pytest.mark.octave +def test_hand_written_pair_passes(m_runner: MRunner) -> None: + result = verify_pair(m_path=DATA_DIR / "beam.m", py_path=DATA_DIR / "beam.py", runner=m_runner) + assert result.ok, result.report() + names = {var.name for var in result.variables} + assert {"w", "tip", "imax"} <= names + + +@pytest.mark.octave +def test_wrong_translation_fails(m_runner: MRunner, tmp_path: Path) -> None: + # The classic off-by-one: end-2:end is three elements, not two. + m_file = tmp_path / "t.m" + py_file = tmp_path / "t.py" + m_file.write_text("x = 1:5;\ntail = x(end-2:end);\n") + py_file.write_text("import numpy as np\nx = np.arange(1, 6)\ntail = x[-2:]\n") + result = verify_pair(m_path=m_file, py_path=py_file, runner=m_runner) + assert not result.ok + assert [var.name for var in result.variables if not var.ok] == ["tail"] + + +@pytest.mark.octave +def test_missing_python_variable_fails(m_runner: MRunner, tmp_path: Path) -> None: + m_file = tmp_path / "t.m" + py_file = tmp_path / "t.py" + m_file.write_text("a = 1;\nb = 2;\n") + py_file.write_text("a = 1\n") + result = verify_pair(m_path=m_file, py_path=py_file, runner=m_runner) + assert not result.ok + assert "missing" in result.report() + + +@pytest.mark.octave +def test_nothing_compared_fails(m_runner: MRunner, tmp_path: Path) -> None: + m_file = tmp_path / "t.m" + py_file = tmp_path / "t.py" + m_file.write_text("% only a comment\n") + py_file.write_text("# only a comment\n") + result = verify_pair(m_path=m_file, py_path=py_file, runner=m_runner) + assert not result.ok + + +@pytest.mark.octave +def test_logical_type_is_preserved(m_runner: MRunner, tmp_path: Path) -> None: + m_file = tmp_path / "t.m" + m_file.write_text("mask = [1 2 3] > 1;\nflag = true;\n") + outputs = m_runner.run(path=m_file) + assert outputs["mask"].dtype == bool + assert outputs["flag"].dtype == bool + + +@pytest.mark.octave +def test_octave_failure_is_named(m_runner: MRunner, tmp_path: Path) -> None: + m_file = tmp_path / "bad.m" + m_file.write_text("x = [1 2 3];\ny = x(5);\n") + with pytest.raises(ExecutionError) as info: + m_runner.run(path=m_file) + assert info.value.side == "m" + # The session stays usable after an error. + ok_file = tmp_path / "ok.m" + ok_file.write_text("z = 2;\n") + assert m_runner.run(path=ok_file) == {"z": 2.0} diff --git a/tools/mypy_rules.py b/tools/mypy_rules.py new file mode 100644 index 0000000..c81b66b --- /dev/null +++ b/tools/mypy_rules.py @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Evan Gress + +"""Type-check every ``rules/**/translate.py`` with the repository's mypy settings. + +The translators are loaded at run time under the module names +``dualect_rules...translate`` (hyphens become underscores, +see :func:`dualect.translators.load_translator`). Their folders are not valid +package names and every file is called ``translate.py``, so ``mypy rules`` +cannot tell them apart. This script links each file into a temporary package +tree under its run-time name and checks that tree in one mypy run. + +Usage: ``uv run python tools/mypy_rules.py``. +""" + +import sys +import tempfile +from pathlib import Path + +from mypy import api + +REPO = Path(__file__).resolve().parent.parent + + +def main() -> int: + """Run mypy over the translators; return its exit status.""" + files = sorted((REPO / "rules").glob("*/*/translate.py")) + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) / "dualect_rules" + targets = [] + for path in files: + category, rule = path.parent.parent.name, path.parent.name + package = root / category.replace("-", "_") / rule.replace("-", "_") + package.mkdir(parents=True, exist_ok=True) + for folder in (root, package.parent, package): + (folder / "__init__.py").touch() + # A copy, not a link: mypy reports paths, and a copy keeps them in + # the temporary tree; errors are mapped back below. + target = package / "translate.py" + target.write_text(path.read_text(encoding="utf-8"), encoding="utf-8") + targets.append((target, path)) + stdout, stderr, status = api.run( + [ + "--config-file", + str(REPO / "pyproject.toml"), + "--explicit-package-bases", + *(str(t) for t, _ in targets), + ] + ) + for target, path in targets: + stdout = stdout.replace(str(target), str(path.relative_to(REPO))) + sys.stdout.write(stdout.replace(f"{tmp}/", "")) + sys.stderr.write(stderr) + return status + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..a926209 --- /dev/null +++ b/uv.lock @@ -0,0 +1,2160 @@ +version = 1 +revision = 3 +requires-python = ">=3.11" +resolution-markers = [ + "python_full_version >= '3.15'", + "python_full_version == '3.14.*'", + "python_full_version >= '3.12' and python_full_version < '3.14'", + "python_full_version < '3.12'", +] + +[[package]] +name = "annotated-types" +version = "0.8.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5f/56/a8120250d128bed162cd73c76d45f6ef9991f3e068f62a8ee060afa3104a/annotated_types-0.8.0.tar.gz", hash = "sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7", size = 15893, upload-time = "2026-07-23T20:16:13.995Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/99/91/8acff4f5e50511b911bbccb72b8628a49c68ce14148cd9f6431094859a90/annotated_types-0.8.0-py3-none-any.whl", hash = "sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0", size = 13427, upload-time = "2026-07-23T20:16:12.938Z" }, +] + +[[package]] +name = "anyio" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "typing-extensions", marker = "python_full_version < '3.15'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a1/98/7e457a3b014976887a050561955c0b76e1e7e2d6e27b78ecef2ef80518f2/anyio-4.16.0.tar.gz", hash = "sha256:59bb03251907983d1603d27c3087ddb1e93299ea2163adcdba37899a4fb12ffb", size = 310971, upload-time = "2026-11-01T11:20:07.282Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a9/16/7757fb84c819accc7d7e9af5291b261e4abb8627ee040f99e7d35ef2457a/anyio-4.16.0-py3-none-any.whl", hash = "sha256:c66ae634e0b8228396b801741beb3294326d4b6102f7bba4041c0dfb58c29026", size = 134521, upload-time = "2026-11-01T11:20:05.59Z" }, +] + +[[package]] +name = "appnope" +version = "1.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/11/f7/a82489c2b6ebe32d3e2831895ae19c77861f0eadf3bb16034484d965dbb2/appnope-1.0.0.tar.gz", hash = "sha256:685db59cb6043c3c2e528adc0b3bce3a5f8d09bcf7492c6ea650d1b7421f3c49", size = 5454, upload-time = "2026-08-20T21:36:13.748Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/46/c7/6b687cb0f83d2a51017d47953f2ee430ffad6fec2a8ebc964e0718a33eb1/appnope-1.0.0-py3-none-any.whl", hash = "sha256:6fe0c04218aab65c54c4ff81638cdbf848d89f5653b74d68638a137f200dd16e", size = 4158, upload-time = "2026-08-20T21:36:12.444Z" }, +] + +[[package]] +name = "ast-serialize" +version = "0.13.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/21/d5/5dc1ee8a80c3b20a0b63c61b43ba6bc53517faecd1def47bcd752d22268e/ast_serialize-0.13.1.tar.gz", hash = "sha256:401cc84e8888d4d76f2c8d296fa006ed1a5ff993b6aff90dd777c03973efd025", size = 955137, upload-time = "2026-10-17T00:04:17.183Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f3/a8/fbd136b9f70c59e75f59a8e974c84102976f1201828b4f886480ba956936/ast_serialize-0.13.1-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:3e129d44b0cffbea24a7f40117ce49e30993c3d119e584d4817ebd6f87246456", size = 897306, upload-time = "2026-10-17T00:02:52.479Z" }, + { url = "https://files.pythonhosted.org/packages/50/3f/2ad51e9823a790e7a70fd781e9595ab3abeace27f3aefcaa1939457efd72/ast_serialize-0.13.1-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:523d45bab16ddaf1399c04c4fe81bbf180f81e33c2f7bcbe76be56b0f7311ab4", size = 1236082, upload-time = "2026-10-17T00:02:54.82Z" }, + { url = "https://files.pythonhosted.org/packages/c0/5c/8e959db5cc2237f9d4c560a8e2253c98f9746883fb4774651e4cda458901/ast_serialize-0.13.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:638333fb8ae72c62753f9e794fda20290883ddc65b0d85e26e08f8bb227567ad", size = 1221242, upload-time = "2026-10-17T00:02:56.395Z" }, + { url = "https://files.pythonhosted.org/packages/d6/05/ab1c56c3b7adcac88764bba609502d6b4989e449b2dd60eb478e1d20e369/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc34c670747d85d4232834665e247009413eaebe47c69eaf60a5c439aaecaed9", size = 1282105, upload-time = "2026-10-17T00:02:58.275Z" }, + { url = "https://files.pythonhosted.org/packages/0d/f4/41981fcd2ddffe0760e5326be9dcbd2eda9478a8430a637e5123bd8fcb26/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8c8ebd419811c435812d242fb2a173e57dfede198c9ac9a0a584666ebc9b9331", size = 1287905, upload-time = "2026-10-17T00:03:00.068Z" }, + { url = "https://files.pythonhosted.org/packages/6a/43/b783addc5681153707121991b7b47892f7e9c8ba58a0d03b71a3b023ba47/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8899c038b1c15ae8b98e379057fb3ef398ceb0b21d1737a8156dd5a0923b7e51", size = 1541806, upload-time = "2026-10-17T00:03:01.503Z" }, + { url = "https://files.pythonhosted.org/packages/47/10/969db095038ee15270f65ad20d1129c5e4da605bf7e93b70ae640f1c8a9f/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e14c4de98f965647a74e6eaf37e20207124e45451ccd36e84a6f6ebab45e0372", size = 1309946, upload-time = "2026-10-17T00:03:02.971Z" }, + { url = "https://files.pythonhosted.org/packages/06/dd/7c623d2fb0b868948952d1787e629a43b866f7d4caefd5445e20aefacec4/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f3e8a3eff69af640db985360fef35073fb46956dfc3e5c614cf00920d2746dd", size = 1302773, upload-time = "2026-10-17T00:03:04.378Z" }, + { url = "https://files.pythonhosted.org/packages/d4/c2/4d49469110a19a44fc6269f4fd59679bcf84df068f185f89b73bee4da19b/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:75d7750fe98f6f35a96c43aba8d98a2e623e22c778a0c17ab9ede92eb10f5d82", size = 1299579, upload-time = "2026-10-17T00:03:05.88Z" }, + { url = "https://files.pythonhosted.org/packages/9d/9a/2d381f1f262dda15affc8ad643fba1619eb07e7d9f8bd904deffef183006/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43e8ddd63e80fc280c2f790157386f27f9b9f6ccb9c4f8e803b863cbfb085769", size = 1355969, upload-time = "2026-10-17T00:03:07.321Z" }, + { url = "https://files.pythonhosted.org/packages/9d/9c/2266794e6c25fa9ce51ce04a9bf4b7e330e3ac9351ba3fa14e487678acdb/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:9221e09496fb942901993c1812ee87950cc0ecbb514c7c0f1f5fa6d78f701ed8", size = 1460227, upload-time = "2026-10-17T00:03:08.733Z" }, + { url = "https://files.pythonhosted.org/packages/2b/d6/14deb28e5d8f328f626a0778ea2cf98fe908f2bbcccd804cb6f449ee1782/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:7a5c38bdb93669c596f94fb7204dd6ebe4fadb19058ac9a2faf2948c2a175f96", size = 1562691, upload-time = "2026-10-17T00:03:10.25Z" }, + { url = "https://files.pythonhosted.org/packages/f5/19/7a28c0e5ba54f0d3e054f847a2a549b748cb179ab433321a8dc1b39e398d/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:acf4e9f055d75058ab01536da330648746f2f82b7697a85230547f2d5ebe895c", size = 1558669, upload-time = "2026-10-17T00:03:11.799Z" }, + { url = "https://files.pythonhosted.org/packages/18/9a/f9e2690eab58217f1d395a964a78efa7eaf813a1e38be8dfd9a8d45d0840/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:87427913c325adc811e81e7c9a757b061f47ef1e29114ac479aa0953a2687a98", size = 1665071, upload-time = "2026-10-17T00:03:13.284Z" }, + { url = "https://files.pythonhosted.org/packages/8e/f3/ef5b159a0d7161b404f05e7ec21cf7735ee7edc10c000cd2cbbc7bb6b69a/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:ad88921f95b92bc144d9ad059a0e16f8c1ae69f5239f2d3c6536fd2774f73dfe", size = 1473364, upload-time = "2026-10-17T00:03:14.563Z" }, + { url = "https://files.pythonhosted.org/packages/1d/87/6e8ac4a865124a12cc4f915bf1bcfac3bba426cd5f58d3712a873ee61012/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f8b17e2921e56621bcb46792bd3e0b82ca3b85de78d5936e7b8174ba1758b0aa", size = 1500566, upload-time = "2026-10-17T00:03:15.917Z" }, + { url = "https://files.pythonhosted.org/packages/f5/1e/29155f1621433008013ad5c940a03d41a676be0680c41527040472d37583/ast_serialize-0.13.1-cp314-cp314t-win32.whl", hash = "sha256:2f9a9ce8b0994f757b941f7f7fe384a6666b4162b941ebc5c248081baea18e47", size = 1128674, upload-time = "2026-10-17T00:03:17.481Z" }, + { url = "https://files.pythonhosted.org/packages/bb/64/2506da65143ea138de5822e9173e0b72320a2f70e23bd723f044033175f1/ast_serialize-0.13.1-cp314-cp314t-win_amd64.whl", hash = "sha256:5d99910e6b9a9b9360bcca2ae99aee36cc912ce058df2a57d1c33099b6cb2593", size = 1163306, upload-time = "2026-10-17T00:03:19.046Z" }, + { url = "https://files.pythonhosted.org/packages/6d/8f/c7cb22638899b0cf15908809c270560e46395e65604bc59e4b623ab9f405/ast_serialize-0.13.1-cp314-cp314t-win_arm64.whl", hash = "sha256:a789cbe14d0a0e9ec9b32a456e5abc81ad8799479c3cfd88a29e3442262aebe6", size = 1133775, upload-time = "2026-10-17T00:03:20.377Z" }, + { url = "https://files.pythonhosted.org/packages/2b/e2/b0c140fe50fa39dd249e382f7733af6f816c90021fe7959a0b026f86237f/ast_serialize-0.13.1-cp315-abi3.abi3t-macosx_10_12_x86_64.whl", hash = "sha256:23d768369b89d551077dc173da6892fad00443338417523b6732f4e8ba4a7ed5", size = 1236160, upload-time = "2026-10-17T00:03:21.945Z" }, + { url = "https://files.pythonhosted.org/packages/23/c4/a8a2ca21e3943555b48221f8fba546877a7ad39efaf6505506524967d7c4/ast_serialize-0.13.1-cp315-abi3.abi3t-macosx_11_0_arm64.whl", hash = "sha256:68f8829d114dab6c9db4a8bbb8d0e342958faee1b5e15a29022678df639960f8", size = 1222214, upload-time = "2026-10-17T00:03:23.462Z" }, + { url = "https://files.pythonhosted.org/packages/15/19/2f58f2ba64e4799b39de85c140aef09a03aa6ea53be75dd292a9d9b9d8ae/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e385b17d5bde892a6184003a9aff3518387908b73f8f5ea539313c07c8c0ede", size = 1282979, upload-time = "2026-10-17T00:03:24.695Z" }, + { url = "https://files.pythonhosted.org/packages/b1/af/ca6087fe84210c1ccd43e3182917bb70649fa1e69745a90c1d59ba08fea8/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:02686b281ec9b8e9614f6f0db27e12e4cac515f336c5d05b678bc9eb73ff2af5", size = 1288596, upload-time = "2026-10-17T00:03:26.04Z" }, + { url = "https://files.pythonhosted.org/packages/b0/2c/4ef964c763329a0347125e745ec0451ba4fbaceec9efe2ac729b7cd55f17/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a8ab2c2585b2e22e48cd4aff2136fce4eab4ced569b85f150ef9a5a5d6f34d49", size = 1545540, upload-time = "2026-10-17T00:03:27.52Z" }, + { url = "https://files.pythonhosted.org/packages/bb/85/aa961dbb75813cfa94de0ce9a16a9510c226b95f604c405421e727f44bb0/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c652d9f5d52d8b81eff3ff2c95c9dd0f281de45f6ad5d3fa95527550c396454a", size = 1309374, upload-time = "2026-10-17T00:03:29.091Z" }, + { url = "https://files.pythonhosted.org/packages/b4/e6/f2b67c327d9f9533e41791804403ccc2dc457821195a2e51f0b587a90b90/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:121e1d08d58b75c15491cc3003609cbad71ac2b0016043c36d30a6b2032b6605", size = 1303466, upload-time = "2026-10-17T00:03:30.451Z" }, + { url = "https://files.pythonhosted.org/packages/73/1d/33f18b81d1bb1f5d682943ea92fda8130a6593627f12f6201668d40824fd/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_31_riscv64.whl", hash = "sha256:30cf89b6a6844542d116c758725d13de5b97b9410a51ee577715f761270d0c1c", size = 1300576, upload-time = "2026-10-17T00:03:32.102Z" }, + { url = "https://files.pythonhosted.org/packages/25/cb/64914144925f1a4abdd9217e717b122255c38fc5ebe4342f92052f3bacbc/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:732aaae9e498c973fc63fd7f308009b57c4afa6ff59d0b674d894e57d0bca01a", size = 1355960, upload-time = "2026-10-17T00:03:33.676Z" }, + { url = "https://files.pythonhosted.org/packages/ee/80/bd29379fab2bce19adc0bf9177002b11b23dfe8d8fecf409998b458b4624/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_aarch64.whl", hash = "sha256:d9c1a920b2aa0c1e016bed7721689717034ca0dba64ac3a3ff243b003d4e8dd8", size = 1459779, upload-time = "2026-10-17T00:03:35.09Z" }, + { url = "https://files.pythonhosted.org/packages/83/89/012dbe733de05ffdf8e40ca0f9fa5d417cb16ec93a74463c57c001914198/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_armv7l.whl", hash = "sha256:847cad4c22953823f5e76d0b126c6f9da670cfa45b1df41b9324e22189d77611", size = 1563399, upload-time = "2026-10-17T00:03:37.285Z" }, + { url = "https://files.pythonhosted.org/packages/69/37/ee4bcb0358bee38744eb0f18560446572d095fe3bf6b63d6f739d08a839c/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_i686.whl", hash = "sha256:aca07de3ca8e3d9f2b716c3c31f4f384fe4bd2d03e09912417cff7a3e08036f7", size = 1558808, upload-time = "2026-10-17T00:03:38.711Z" }, + { url = "https://files.pythonhosted.org/packages/54/1c/ff44c5355251d61ef22934c4430bb31a61de4781d25a992154aac9b8c82a/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_ppc64le.whl", hash = "sha256:5db12d843d931b9d1f1519ce66b9cbfe72d8563b75c1204d255322254d1964dd", size = 1666324, upload-time = "2026-10-17T00:03:40.376Z" }, + { url = "https://files.pythonhosted.org/packages/c8/bb/6da4bfc8aa3403e6447607131bf3463acaf954d990c6c8b6787c1902ddfe/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_riscv64.whl", hash = "sha256:fb8021f4dc3296de18737e3b8b34994411da725374d74a0b9eb32a738f2a23d0", size = 1474089, upload-time = "2026-10-17T00:03:41.715Z" }, + { url = "https://files.pythonhosted.org/packages/21/97/897e33bef2eefd880e6350e375cc66bc5bcd00a139be480fd655f5b3f095/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_x86_64.whl", hash = "sha256:0d764913374ba21df8cd618045b371ed104ce55c6276de7c59e554a4f5ba26fd", size = 1501542, upload-time = "2026-10-17T00:03:43.08Z" }, + { url = "https://files.pythonhosted.org/packages/8d/4c/821211ac83870c27e4412381b7c7838336456b40575bf840e4680b2018d9/ast_serialize-0.13.1-cp315-abi3.abi3t-win32.whl", hash = "sha256:2bad302ae2427454ef9dab71bd5c3ad67188860c39d36daee38f72031edb39c4", size = 1126118, upload-time = "2026-10-17T00:03:44.616Z" }, + { url = "https://files.pythonhosted.org/packages/1f/86/2b2d5e6c4fa352874a80618e742ffd32d249dee6c119f4233b51afc6b8f4/ast_serialize-0.13.1-cp315-abi3.abi3t-win_amd64.whl", hash = "sha256:032b09d86c785c3984e975378b7861f2a68ac44e22ba7b07b93a536b2524eeb8", size = 1163766, upload-time = "2026-10-17T00:03:45.986Z" }, + { url = "https://files.pythonhosted.org/packages/77/a3/d610cfcdabaa44fd62a54ca1fc57a7dba120643798b089a14914973562de/ast_serialize-0.13.1-cp315-abi3.abi3t-win_arm64.whl", hash = "sha256:929eda0c419e622ab49df3a4c45f81c57dcc10874bbad55d0470a4a03324dac3", size = 1134043, upload-time = "2026-10-17T00:03:48.453Z" }, + { url = "https://files.pythonhosted.org/packages/f0/89/0e30f9eddf7d44ccf9d25979030754fd0457af61fa4279acb8c293a04f97/ast_serialize-0.13.1-cp315-cp315-pyemscripten_2026_5_wasm32.whl", hash = "sha256:bf53a3ba1cbe45399fc1e4ccd684b8f2a11cca450f89706b79122f478534c6f5", size = 897546, upload-time = "2026-10-17T00:03:50.093Z" }, + { url = "https://files.pythonhosted.org/packages/81/92/d705be88ff452b9ba0088b554a0cbd308fd01879da092b33fd2ad7d1aa60/ast_serialize-0.13.1-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:4bcf1d5f4eefecaa325a34ecf079b2741189e7d0821523f92cb343a389a67489", size = 1242416, upload-time = "2026-10-17T00:03:51.521Z" }, + { url = "https://files.pythonhosted.org/packages/60/c2/98370845a7f35cb8a25782e78284b48e01bf3128339881d48d613f304f8f/ast_serialize-0.13.1-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:1b158f1c9e3a0d386913924c57995d6df78224868a4d0f215bdd41587c97b34a", size = 1229729, upload-time = "2026-10-17T00:03:52.825Z" }, + { url = "https://files.pythonhosted.org/packages/d8/8b/2d7ffed76addd9d3fcf37fb171400942735c8912264c763561a85407f6a8/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77a6201b69ce42e919f2fd9a559138d5410b5d8afff7c3a6b1f500b0481ff7d8", size = 1292255, upload-time = "2026-10-17T00:03:54.148Z" }, + { url = "https://files.pythonhosted.org/packages/6b/2a/bb9e0e719d89cc950fadfcfcc9cb4bc7640419c4228c852f031ab8abf440/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6eb0be64c9b8f1ed26637eef345abe75ea90351c92c85a8aec7838b3af971011", size = 1298501, upload-time = "2026-10-17T00:03:55.559Z" }, + { url = "https://files.pythonhosted.org/packages/7a/32/13ce07dce48226f5bd9cfd8f708ec101a8be05aa430cda4918ce31ce8c82/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7f2427bddfca208e84de700044fadf9aef2769a70bae740a1bdabb89ee9e1117", size = 1553758, upload-time = "2026-10-17T00:03:56.952Z" }, + { url = "https://files.pythonhosted.org/packages/e2/fb/9b51d186db0c20ca28cbaaefd50f03b573c89327b9a2627820cbce22196b/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:88df960e67184a71874e5b2ee014f87d1254a0dbc1f903c7bd7b1ab7733ecaef", size = 1318258, upload-time = "2026-10-17T00:03:58.418Z" }, + { url = "https://files.pythonhosted.org/packages/c5/fa/da311559dd3dae9af5825cf21660775a929b970f72e3786af3f2cd667944/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f99786e0d62082a5b121b3437f3167562133711df22128de1e9886f57f0b226", size = 1313260, upload-time = "2026-10-17T00:04:00.194Z" }, + { url = "https://files.pythonhosted.org/packages/2b/11/97a4b9e5b4776d72f47fcd9a09a497bbf68ec8c1ae074307a2c51e410d85/ast_serialize-0.13.1-cp39-abi3-manylinux_2_31_riscv64.whl", hash = "sha256:a01b515b25a03184eff4acef25b981ae007916379682e908fc8785b342a0bf3e", size = 1309992, upload-time = "2026-10-17T00:04:01.575Z" }, + { url = "https://files.pythonhosted.org/packages/2e/c4/62f85121a80cd451ef04f550cf0f7ea0ad9ff46cc4e9a5b9ae439b6527b1/ast_serialize-0.13.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:29422d7bcd9e7f39411571c36cec45ce8a7a9b3ad4b2e7aa64497c15a9e397f6", size = 1362715, upload-time = "2026-10-17T00:04:02.881Z" }, + { url = "https://files.pythonhosted.org/packages/c1/fa/c5f4a545f72a7681e3295bab6e3600ee0862ec4391bed961fe9f735b67e0/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:6ffb0f548a7dc126067fdfb7b2325ab5dfcdeecc29faf5e0f0461c96d6ebfa3d", size = 1469931, upload-time = "2026-10-17T00:04:04.181Z" }, + { url = "https://files.pythonhosted.org/packages/38/a9/65aed4f8fa7a001a7cfdc03e68e844517ab041ba6fb614b7d78a1d6ac056/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:2876444a5f87a7c76f371af3c07c2fda563a08bc8af52568df812e8aba4bf568", size = 1570945, upload-time = "2026-10-17T00:04:05.778Z" }, + { url = "https://files.pythonhosted.org/packages/fb/8c/44b2da991cede79bfbf52089f33a5f0168945466b3d9cd38b5dcf08e7130/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_i686.whl", hash = "sha256:885a62ec6481ce58ab24c6357360d7a82023b62dd7e5e7ceccf59e9662a3272b", size = 1569978, upload-time = "2026-10-17T00:04:07.347Z" }, + { url = "https://files.pythonhosted.org/packages/46/e4/109b2a5beca700237767d5add920c2f8e1ba9bd5799b0faf143d0e9cf4ef/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_ppc64le.whl", hash = "sha256:2015fd0165e463aac3b1aadc6a1fa1e5820c14ca950821f4fe02f8a3f6a388d6", size = 1676082, upload-time = "2026-10-17T00:04:08.7Z" }, + { url = "https://files.pythonhosted.org/packages/73/e0/7df70f6dbb11b5762da5416318f08316a1c51348e0d69ec79ca5f98f836a/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:eb41e1906502ac80d24ff343f45008552a3f5b5158607959fe6a07dbfc6eb037", size = 1483207, upload-time = "2026-10-17T00:04:10.162Z" }, + { url = "https://files.pythonhosted.org/packages/1f/bc/523aa1c08bd69b5654621beb3dc1a9035715a4a63762fb8d219d6fb3eb81/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ca9acc67f796aa2554fa3037dccc022a4b08b38b2ad153edfac9c9bb7cb1f3c6", size = 1512140, upload-time = "2026-10-17T00:04:11.589Z" }, + { url = "https://files.pythonhosted.org/packages/66/83/6607060659998f00afdea0d8375c1e6e2b7d515ab905090d9a5a02f48851/ast_serialize-0.13.1-cp39-abi3-win32.whl", hash = "sha256:4f98da562e5901d69c7dd30885594c5438f859edf354e9ac7517d188fb026c3a", size = 1131889, upload-time = "2026-10-17T00:04:12.953Z" }, + { url = "https://files.pythonhosted.org/packages/9f/6f/bafd6490fe7b355627fabe95f4417e3d02da93102c8552550eb9a0774e1e/ast_serialize-0.13.1-cp39-abi3-win_amd64.whl", hash = "sha256:ddf7cbc9c8abf70102c4a088efe154bb86bfb825b0a10e556d2b15972cf99bd7", size = 1171153, upload-time = "2026-10-17T00:04:14.362Z" }, + { url = "https://files.pythonhosted.org/packages/11/25/4235f4b375a67a37ac595bf478a5407a744eaf7b64113c1c3a5432b8d954/ast_serialize-0.13.1-cp39-abi3-win_arm64.whl", hash = "sha256:48f11d96c9ec71119612f8e79a8c55c12f2b136716d68347433c561d27a25f43", size = 1139035, upload-time = "2026-10-17T00:04:15.767Z" }, +] + +[[package]] +name = "asttokens" +version = "3.0.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/25/1e/faf0f247f6f881b98fc4d6d07e14085cb89d13665084e6d6ac1dc2c03d0b/asttokens-3.0.2.tar.gz", hash = "sha256:3ecdbd8f2cc195f53ccada3a613538bb5f9ef6f6869129f13e03c30a677b8fe2", size = 63136, upload-time = "2026-07-12T03:31:49.084Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d4/2b/04b8a15f3a1c77bc79ddf5c73875327f34b4fa75982df2b76e45e402d364/asttokens-3.0.2-py3-none-any.whl", hash = "sha256:9da13157f5b28becde0bd374fc677dcd3c290614264eff096f167c469cd9f933", size = 28702, upload-time = "2026-07-12T03:31:47.542Z" }, +] + +[[package]] +name = "attrs" +version = "26.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz", hash = "sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32", size = 952055, upload-time = "2026-03-19T14:22:25.026Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", hash = "sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309", size = 67548, upload-time = "2026-03-19T14:22:23.645Z" }, +] + +[[package]] +name = "cffi" +version = "2.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pycparser", marker = "implementation_name != 'PyPy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9e/ef/008a1939e372c06329a3fce4279c02f328488f3526744906eeec3da7ad5f/cffi-2.1.1.tar.gz", hash = "sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be", size = 530807, upload-time = "2026-08-03T21:21:18.939Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/70/d2/16d99a0c4948febc0ebd133a13b2f688ff7f8cb04da971e1128872ce0c03/cffi-2.1.1-cp311-cp311-macosx_10_15_x86_64.whl", hash = "sha256:c8d2c9fd1f2d16f780d15127abb050d13d1a76c03a4bd87d7e4980e45e511e12", size = 183838, upload-time = "2026-08-03T21:19:29.637Z" }, + { url = "https://files.pythonhosted.org/packages/cd/95/31b535a9f0220ae9f357de4a08d57ce89cb417653c2fd9f075f50822a388/cffi-2.1.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:398aff33cee2767e3e781d2554c54bd0dff386bb437581e0d8011fde1a942ec1", size = 184168, upload-time = "2026-08-03T21:19:30.764Z" }, + { url = "https://files.pythonhosted.org/packages/ad/5a/4707a0dc1f203f5dde5a907b0d4e3c25d71120241048bd5bc6f1bb9d4e71/cffi-2.1.1-cp311-cp311-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:154852545011f779917b11c78db2358d095da62a9a172b78ad0a583ee5adc0d0", size = 211805, upload-time = "2026-08-03T21:19:31.867Z" }, + { url = "https://files.pythonhosted.org/packages/ad/66/c19feabb28485b6e0bbaaafa90837a1ef5d302e90f2178bd33f17a49879b/cffi-2.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:3311ed60d36f83378794e1009ac6258bafbf81f7888b4caa7b35a521e3f95813", size = 218716, upload-time = "2026-08-03T21:19:32.896Z" }, + { url = "https://files.pythonhosted.org/packages/a7/92/500760486c8baab49a7a8a58ba7fc3355ec3974b454b8a09e528efde9e1d/cffi-2.1.1-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:6e192623c49c94421616a5778fba35cf0d5a8d000650c1967ef4448ee5cdd990", size = 205569, upload-time = "2026-08-03T21:19:34.142Z" }, + { url = "https://files.pythonhosted.org/packages/a5/a7/a67c733254d6e7373f7822f8082d8d6beade791e0cf12a7611f376fa61c7/cffi-2.1.1-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a6e721d4b0e45d5b65e87534470e67b18dcd092c83f68fba09f152b9cbc061af", size = 204907, upload-time = "2026-08-03T21:19:35.174Z" }, + { url = "https://files.pythonhosted.org/packages/f7/a4/4399daaf8f7dfee9d7c3327fdb0426ee041cc63edc358b93911ceb2bfc7a/cffi-2.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:34e261f78cb6ceaaa36f42f2613f4380d94d9c759a9c73c769ee6e0247364632", size = 217807, upload-time = "2026-08-03T21:19:36.286Z" }, + { url = "https://files.pythonhosted.org/packages/28/f7/dabe6da2466ecbd82dc62e7342dc6b1065dad990c06f00f0ede9ebf2a0ed/cffi-2.1.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7225e4514edb64eb6740324353e0da0711954fd8d7da4576755b1c6e09b697cd", size = 221252, upload-time = "2026-08-03T21:19:37.416Z" }, + { url = "https://files.pythonhosted.org/packages/ce/87/616202d8e51342c07d2534c510111c4cc37201775ce8f60802c9335d1edd/cffi-2.1.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:df913725b79db7bcf03448f36b7bf8815363417d5b58deecf9305e3e30f0f21a", size = 214214, upload-time = "2026-08-03T21:19:38.507Z" }, + { url = "https://files.pythonhosted.org/packages/b4/c6/ab025d75d2c26c19b087c0124e75ee31cb65032f4fe345d356d8c507ab97/cffi-2.1.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f5cfbc5fe74540d335175b656c725d74d90e3730c626d92575eea35029d9afaa", size = 219408, upload-time = "2026-08-03T21:19:39.809Z" }, + { url = "https://files.pythonhosted.org/packages/db/e2/7e8109f65445bdc673a7b54f02c677de462db75674220fd1335efc8eb598/cffi-2.1.1-cp311-cp311-win32.whl", hash = "sha256:f8ec5e643a9a937f64e1999eb9f75d072263751912dc5cd06d3c85f8f44be7c3", size = 174470, upload-time = "2026-08-03T21:19:41.246Z" }, + { url = "https://files.pythonhosted.org/packages/73/c0/77ba02423c2f7d7091143c45cd49e0e6575c4c1967394bb542bd923a9b74/cffi-2.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:42f6930c31dc7f50732c9ae793c2786c7b6b044195967bbdde40bb9be81c4cc0", size = 185096, upload-time = "2026-08-03T21:19:42.615Z" }, + { url = "https://files.pythonhosted.org/packages/7c/47/9f1f85f9672ceda4984dc6c4f8824e8558992a2972c3d3c81fb8eb28d4ba/cffi-2.1.1-cp311-cp311-win_arm64.whl", hash = "sha256:c7659f22557c5a0bc4855cd635f55edec690cc008a40768527762cb9fb263455", size = 179941, upload-time = "2026-08-03T21:19:43.747Z" }, + { url = "https://files.pythonhosted.org/packages/10/69/43965eccfdead3b9220015fd1320e117be8c6ed01a62ffab76eeb752f5d5/cffi-2.1.1-cp312-cp312-macosx_10_15_x86_64.whl", hash = "sha256:c8c69575568085ba0b1b10c0249d779a214aea6f6522e949a0fc9fb0fcb449d0", size = 184821, upload-time = "2026-08-03T21:19:44.887Z" }, + { url = "https://files.pythonhosted.org/packages/54/7d/16e5a096677b5e313ca80cd5e5170efa3ea44624a82bb111925522da64b1/cffi-2.1.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f81b3b8f3d4e343550fa4baa0e479bba9f2d29ce9c2e9b51d1ce1718d7442fcf", size = 184719, upload-time = "2026-08-03T21:19:46.129Z" }, + { url = "https://files.pythonhosted.org/packages/56/e6/8941622732edec876dd17d0453dce07317ae96db34f2ec1436c9d3785986/cffi-2.1.1-cp312-cp312-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:811bd1e21d32de12efca32393a0ab3f5133b54fce9bd44b8bd77ab07da14bf6a", size = 214799, upload-time = "2026-08-03T21:19:47.218Z" }, + { url = "https://files.pythonhosted.org/packages/44/de/f98430906df1545ffde0d543dd124a7a439bc2cd32b36b9c53f805df7333/cffi-2.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:68e62fe11f30d5ca8289242866f0a5291402d8529ca2178ab8afc5c9694ae890", size = 222389, upload-time = "2026-08-03T21:19:48.331Z" }, + { url = "https://files.pythonhosted.org/packages/6a/5b/717f1526b9957b34456313c31645c5b82b8fb5c3fe9e4752999be7128bfc/cffi-2.1.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:4a7c934f7360e8cd64fe9efadcbd10c7c6364f531e432b9a4bf5ccbc9e0e8b50", size = 210249, upload-time = "2026-08-03T21:19:49.543Z" }, + { url = "https://files.pythonhosted.org/packages/64/b3/f8aa4f3e34986c7e4ec45072d1b1b9dd295b6b18007b45518d79726dd725/cffi-2.1.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:3143d81e29e1e20a9ce10901ec369012947876596f75a222235965f2b7ae832e", size = 208775, upload-time = "2026-08-03T21:19:50.918Z" }, + { url = "https://files.pythonhosted.org/packages/b1/db/dceb9dd5b231e1da801793f8acc9f3c52a7e1afe40bb1aae37e02b0faad5/cffi-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c1453022f490d2459a11819d83ad1d586e9ff65a12ac3e705ffebd46d3685dcf", size = 221822, upload-time = "2026-08-03T21:19:52.054Z" }, + { url = "https://files.pythonhosted.org/packages/a0/d2/6cd24ae3be000a634109c247d1475d62e5616d0dc78c82770942ec384248/cffi-2.1.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:208f941bb9d18e768138677f0a6d2ce01f590df56043dda1df1535ac57c88517", size = 225232, upload-time = "2026-08-03T21:19:53.109Z" }, + { url = "https://files.pythonhosted.org/packages/cb/52/3fa190537004dd7f0ab860a6dc7c0175b8667f68d1e618a46f5498d30250/cffi-2.1.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:210019b6c7cf07f081b4c54635c8cf744377001350e29cc0f81c4377b4797735", size = 223597, upload-time = "2026-08-03T21:19:54.515Z" }, + { url = "https://files.pythonhosted.org/packages/80/fb/0bb75b7039588c074b37ae99f40d9bfddf990ecb2fbc346ebccd2e56b9be/cffi-2.1.1-cp312-cp312-win32.whl", hash = "sha256:046bfc24911b37851ee1b51aab8bffe713d89c68c6a057b09484ce9fd5f69b4e", size = 175292, upload-time = "2026-08-03T21:19:55.566Z" }, + { url = "https://files.pythonhosted.org/packages/d9/79/615cc094e2fb508cade7de88d3b4f6c4ec2bab695c97bce9153dc65aadf5/cffi-2.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:f53e442b08449d42821fa4a4fba000095af9f62742a500f978a9f557ec44339a", size = 185919, upload-time = "2026-08-03T21:19:56.89Z" }, + { url = "https://files.pythonhosted.org/packages/70/c6/d0ea84713fe46b243a436a18fcd47d639732747e21635c8a27191b06dc30/cffi-2.1.1-cp312-cp312-win_arm64.whl", hash = "sha256:7bde5e4cc5c10140859842b9d383af292b22639a4dffb725314baf45968cef80", size = 180093, upload-time = "2026-08-03T21:19:58.155Z" }, + { url = "https://files.pythonhosted.org/packages/9d/f4/035513d4117049066b4779dc3b7c0c0fdad175fa13731c9f4003f1cd1478/cffi-2.1.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:b5bdfd1c873d4e093aabc0ca84c4ca6dbc4f752afb5c86f146d9742580c9da2e", size = 194248, upload-time = "2026-08-03T21:19:59.399Z" }, + { url = "https://files.pythonhosted.org/packages/76/af/2aeb4dbb5fc41a04161ae9ff1518de7cec08e164f44a8ce6a4cf7fd2cd1d/cffi-2.1.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:31348097ff5bbe827ccc41795d4dd099d9f0625e7def00ee653c137a490c2a6c", size = 196908, upload-time = "2026-08-03T21:20:00.746Z" }, + { url = "https://files.pythonhosted.org/packages/a7/46/2e5fdde8555706dd98139a910ca11be02809f3f605ce956f655d0214e100/cffi-2.1.1-cp313-cp313-macosx_10_15_x86_64.whl", hash = "sha256:9d2055050ea716bd38b7f7f1579c275386646b4894c155a3e2f3cd62ed41b7c6", size = 184805, upload-time = "2026-08-03T21:20:02.02Z" }, + { url = "https://files.pythonhosted.org/packages/55/41/4c7042f317b9217502988f0873af87e16ad606dc20f84e546e3e6ce9764c/cffi-2.1.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:19ee6127ee34de7d83ce3d371ebc5ed91addbdcc39f9ab15ce4eb35a4e534971", size = 184764, upload-time = "2026-08-03T21:20:03.141Z" }, + { url = "https://files.pythonhosted.org/packages/43/1f/1c3d90d91811c8f86ced9ed637956c54bfe5b79ca98fe976d7f8c8979f6b/cffi-2.1.1-cp313-cp313-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:6a8dddef476fab96d066d578fc88526767b836ab5ab21754e1d5bf3879c31c7c", size = 214722, upload-time = "2026-08-03T21:20:04.377Z" }, + { url = "https://files.pythonhosted.org/packages/37/6f/3b5ce4c3b2192d250f04908f2bfd91ef34552ec8f7716a5d4abdb8d67bb2/cffi-2.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:f16c709686a78c727bbbf059f92b0bf41c6fc60deec706d2dc19f529175a6125", size = 222369, upload-time = "2026-08-03T21:20:05.544Z" }, + { url = "https://files.pythonhosted.org/packages/02/10/4b3c75dde3d9663c9e02ba05c2668b954f671d4bbe346413ca8c696b295a/cffi-2.1.1-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:fcd22650c908d7b7da162bbfaab594a1227a15d1643a98c68b122ac642fa2264", size = 210175, upload-time = "2026-08-03T21:20:06.75Z" }, + { url = "https://files.pythonhosted.org/packages/df/62/14f74b9543e605d17701dc797b815958b8bb70b7624ce1b832ddad48ed6c/cffi-2.1.1-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:aa9511c62d14da7aacc9b4bf51f3f697a621e83b2d6919008243c3aad168eea3", size = 208670, upload-time = "2026-08-03T21:20:08.04Z" }, + { url = "https://files.pythonhosted.org/packages/95/95/86342356ff5953b3fb06f7ef7c5bee212d45e770abc7218d451b9148313c/cffi-2.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a931079504ecc49efed7744c476a5c343a92fabf66dec2db95edb1b2fdc770e2", size = 221824, upload-time = "2026-08-03T21:20:09.274Z" }, + { url = "https://files.pythonhosted.org/packages/eb/ff/7b3429ff53aafe931ed8a5fc69f481bbef7ba6de87ddcbb63d08f483f613/cffi-2.1.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a2d7755bef5a12ed488f4ef1f1b69ee9191d7396083b755a5d2295f6edb4768b", size = 225148, upload-time = "2026-08-03T21:20:10.7Z" }, + { url = "https://files.pythonhosted.org/packages/34/34/a95870b9221e09cf4f2ce3178b1a210abdfe63a1bd357da940418d7b8d15/cffi-2.1.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e0bcb7e0f677f543555d2adff3bf19c05f66cdb4796e5ff602442ab2fe3c4ef7", size = 223564, upload-time = "2026-08-03T21:20:12.165Z" }, + { url = "https://files.pythonhosted.org/packages/70/ea/839b50531021a647fb5e929f72cf97bc1ff702b5472166164b5b6e76b851/cffi-2.1.1-cp313-cp313-win32.whl", hash = "sha256:334644fbac4eff73d985a17a91226df55d0f394160c4cfb880e084c8f7161cac", size = 175263, upload-time = "2026-08-03T21:20:13.559Z" }, + { url = "https://files.pythonhosted.org/packages/60/a6/8b149b2c3f2e11aaa1618ef64500b45f50f22c57a977a4dff1aff1f91042/cffi-2.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:1aa5645c30469b09530c4ebca77ebf8f17618293c58f8549cb1a543a50236e7d", size = 185688, upload-time = "2026-08-03T21:20:14.69Z" }, + { url = "https://files.pythonhosted.org/packages/01/9a/11f687cb39d6a3504060d5242f04f48c735afb4d3d533958a20594890cb2/cffi-2.1.1-cp313-cp313-win_arm64.whl", hash = "sha256:63bbfd5ded17c4840ac07cd8f1c21ba9d9708141f840b324f422f41b207e3973", size = 180078, upload-time = "2026-08-03T21:20:15.917Z" }, + { url = "https://files.pythonhosted.org/packages/d3/7b/d6bbf82b8b96e7391438898c42f5bd96dd02030fd5b64937d248220003e2/cffi-2.1.1-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:7dbb61fe3a7699468030f71bbe5f8a0e326a151daa91beb11a6fc1f980c55e1c", size = 194064, upload-time = "2026-08-03T21:20:17.148Z" }, + { url = "https://files.pythonhosted.org/packages/94/e6/bcc91b283be94735e268487a054004f0aa19947b6348fa367db53230abc8/cffi-2.1.1-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:f24fb43132a4c6b4cb4eb029492919b2db645be6808d738f244fd146c03c32cb", size = 196720, upload-time = "2026-08-03T21:20:18.268Z" }, + { url = "https://files.pythonhosted.org/packages/d9/99/c4b0c17cacdc9c3b8f280026286a9826d6a208c0f047591a3c3ce99b91fd/cffi-2.1.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:d28630f5854ab07ab1fd4aba756de52326c82e6be15d414b12793f1975048b54", size = 184964, upload-time = "2026-08-03T21:20:19.708Z" }, + { url = "https://files.pythonhosted.org/packages/b3/a9/9db617d05d7367c1ad0ab00b3aa6e6f9281edd689b4ee9ea0e5a84e89c97/cffi-2.1.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:661c298b4821edebead0c91edd2b00374d67ad7c5a1f7a91d4442633b79d6a72", size = 184962, upload-time = "2026-08-03T21:20:20.833Z" }, + { url = "https://files.pythonhosted.org/packages/67/b8/b42132ca113dc567d37684437b46ca1dafc885902b02a110a02d5b511857/cffi-2.1.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:58acb8ab8e295e6c5ea12f888cbb13cf21511ef2a3303a23f4325c29d17fe5c1", size = 222328, upload-time = "2026-08-03T21:20:22.118Z" }, + { url = "https://files.pythonhosted.org/packages/80/10/c5c0cbf0a657aecf59ef511409734230bf556f05a0d6c9eed7aa5c0a0166/cffi-2.1.1-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:456a61fa52d579ebf9df2e9552ead5129855dbaff6c1e5a9b1bc408809bdc062", size = 209985, upload-time = "2026-08-03T21:20:23.401Z" }, + { url = "https://files.pythonhosted.org/packages/d5/6c/bfa0b87b03b9238148beca990292843c9396ba069b54496596594173de7b/cffi-2.1.1-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a4f00aa42f75d6e4595e8866e748cc1705adc0cddfeb2ca86d0d03993d63ba03", size = 208530, upload-time = "2026-08-03T21:20:24.628Z" }, + { url = "https://files.pythonhosted.org/packages/e9/02/4e7d553a7ac4b4238b38b3c1b80d486e9d4436f8d2acbf87a0997fe3f402/cffi-2.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b0431303acaea1089ad4b3e9ce4e6518193def1118d4073ca848635ee4ea2e96", size = 221525, upload-time = "2026-08-03T21:20:25.758Z" }, + { url = "https://files.pythonhosted.org/packages/82/1d/a4aaf9babd75acb4d5f223bff71533bee748dd770a382619a798960ee9ba/cffi-2.1.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:64faea20f4e2613363a1a9b9c7dd73058f3ecd00133a511e72ad7c511658f527", size = 225053, upload-time = "2026-08-03T21:20:26.985Z" }, + { url = "https://files.pythonhosted.org/packages/81/10/5dc0e7bdd18e22107054288283380fc97a06ae3f1656a106908d666a3c88/cffi-2.1.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5c58fe613dc5e5336357eff555824a314d8e43282600435c8d1cb6a7a2fedd13", size = 223213, upload-time = "2026-08-03T21:20:28.277Z" }, + { url = "https://files.pythonhosted.org/packages/0b/e9/d0061c364cde06ee43168a0d076ac1da512cbc380d44767b844ba34fe2b6/cffi-2.1.1-cp314-cp314-win32.whl", hash = "sha256:1a18a57b58cfb21fc28d72e876acf10eaed67a1ed96226f92af4df681d571c4c", size = 177682, upload-time = "2026-08-03T21:20:44.288Z" }, + { url = "https://files.pythonhosted.org/packages/a7/06/1c3e01e3ba14c39f6d10bfbac52753b7e22259e38088e5cfe1d704918690/cffi-2.1.1-cp314-cp314-win_amd64.whl", hash = "sha256:3222ba5d678f80a030e6afbcc33dc1ae5cb45facabb61cee2c7016b8432fde48", size = 187949, upload-time = "2026-08-03T21:20:45.623Z" }, + { url = "https://files.pythonhosted.org/packages/87/5b/da4e39efe18eeb89cf580ea9cfc66b6a7c3eadb808fc0cc1d3a295cb5a5d/cffi-2.1.1-cp314-cp314-win_arm64.whl", hash = "sha256:ab36d55f9ed2d067327667c2fea18dda018eb628dd6347aa01dda6cf1f5d3836", size = 182947, upload-time = "2026-08-03T21:20:46.955Z" }, + { url = "https://files.pythonhosted.org/packages/23/59/40338bf421c5accea1d45158170c87006ef1cd371b05c077e76476949728/cffi-2.1.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:7750c6449dff7864bb9bb27ddfb0267756189201a3afc911d82b3caacd70dfc3", size = 188504, upload-time = "2026-08-03T21:20:29.495Z" }, + { url = "https://files.pythonhosted.org/packages/7d/47/5ecf1023850036e674c77ec4de86182d309ae344e39e7cba984b7df5d647/cffi-2.1.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:0beceaabe56af686895136a2de78db54ecd8e4046b236b8fd6d6cb61389e9bf2", size = 188259, upload-time = "2026-08-03T21:20:31.291Z" }, + { url = "https://files.pythonhosted.org/packages/2a/9c/92934c3bea9f785b23eba304538c0b4d37a2a96d2431eb3a1bc87a11aa19/cffi-2.1.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:49cbc70e6542d4ccccb936558d1064a8012541e78f821f955cff24e357776c94", size = 223864, upload-time = "2026-08-03T21:20:32.571Z" }, + { url = "https://files.pythonhosted.org/packages/4d/45/ba4c93527bc38616a8bd36488acb69a2212d60486794f0c1f318949bbb76/cffi-2.1.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:e2d65b31f36619cda3999b78b2aa9632e76b78448e7a56fc4240824200e7c4fc", size = 211538, upload-time = "2026-08-03T21:20:33.808Z" }, + { url = "https://files.pythonhosted.org/packages/80/e9/b6ef565e452acb932fb0cb5443f44a78efbd1233e566f02b5a83855e9115/cffi-2.1.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:28907ab9bfb6aa13184cfc17c6b8e1023c5ab6fd7076d8c20a35e59fe04f8f29", size = 210688, upload-time = "2026-08-03T21:20:34.974Z" }, + { url = "https://files.pythonhosted.org/packages/9a/95/eff5f0cee78d2eabc7eebffec40d3fc1876b5f3c95582e018bb4b99601f2/cffi-2.1.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:51b31d1c98274844cfd7838ce00bfc27c7423a4dc00fc0772fc3331c2cc90676", size = 223803, upload-time = "2026-08-03T21:20:36.564Z" }, + { url = "https://files.pythonhosted.org/packages/fa/01/579d39fb8bef00a335a23d83757b44feb24cd6345a2c451b64cb67b9c362/cffi-2.1.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:5e7cecbaadb83884793e05828cee59b210b24583b9c7425d0ba6a754fe22eb4e", size = 226763, upload-time = "2026-08-03T21:20:37.816Z" }, + { url = "https://files.pythonhosted.org/packages/8d/b0/0b44f47c60b01b57b6e2bbd92343f13a85a1d93bc46ccf6e47e244acd99c/cffi-2.1.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:25792eac27877609e7bb06d42ff88278a6624fff2ba9bbb523c09616b117e80f", size = 225688, upload-time = "2026-08-03T21:20:38.959Z" }, + { url = "https://files.pythonhosted.org/packages/eb/d2/3b7176cb570a1d3e27faf67b72f591af508036e0d8b2be2ef9af9e8c84bb/cffi-2.1.1-cp314-cp314t-win32.whl", hash = "sha256:8ef53b2de9bcb9197d31854256575d59dbac0cba72ac627bb291ef5eceb74be4", size = 182868, upload-time = "2026-08-03T21:20:40.388Z" }, + { url = "https://files.pythonhosted.org/packages/56/78/31f00c1bcd97c9bbf55f1bfdf5bc809a5de8887473e90bb9960dca825e80/cffi-2.1.1-cp314-cp314t-win_amd64.whl", hash = "sha256:616f097f2fe415bc92a247f02e11f634e1f9e9a83d327e3c915c15089c87869e", size = 194104, upload-time = "2026-08-03T21:20:41.725Z" }, + { url = "https://files.pythonhosted.org/packages/7b/1b/58496f2ed0a35de575250c02a43ab3cc2c04d494a88fed31c1cabc0fd176/cffi-2.1.1-cp314-cp314t-win_arm64.whl", hash = "sha256:ad2c86c495b899d862ea0f4b42891b8713a3bd45dd4105c7fd51c2a72f39f3a5", size = 186402, upload-time = "2026-08-03T21:20:43.042Z" }, + { url = "https://files.pythonhosted.org/packages/c1/8f/9ebe220eab48a093d1a5a5e339ab0dc7316eef3bb04d63c42f0251b61f50/cffi-2.1.1-cp315-cp315-ios_13_0_arm64_iphoneos.whl", hash = "sha256:dddad92b554513a31f272570678ba307fb9f618f05e3d4a5eacafff9eae03e1d", size = 194043, upload-time = "2026-08-03T21:20:48.179Z" }, + { url = "https://files.pythonhosted.org/packages/ff/69/844bad3ece306c4782c2ecb93597035b6690d48704b803914c199da1e8b3/cffi-2.1.1-cp315-cp315-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:da0e573f9f97159390c89d9f1a9e41908b66d408cc5b58d08cf3847d844c531b", size = 196737, upload-time = "2026-08-03T21:20:49.457Z" }, + { url = "https://files.pythonhosted.org/packages/1b/8a/af668013284634733f02d683458a0728739c7d6ddb5e14cb0c20832266fe/cffi-2.1.1-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:fb92203a88b3d3053034db775110081c49d28be6551923805e039924093761e4", size = 184933, upload-time = "2026-08-03T21:20:50.639Z" }, + { url = "https://files.pythonhosted.org/packages/0c/75/2f5207ff6d1a613133b23a5203cc0c2a628313b5eb3974d7956ae3c57950/cffi-2.1.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:2ae64be792b8966f2c69538199728b290e34726562896df1e5dc8ffd8d8188e8", size = 185002, upload-time = "2026-08-03T21:20:52.173Z" }, + { url = "https://files.pythonhosted.org/packages/e2/31/9e1313b0a6e30e91b3b3d3fff51ae99c857c07738e3afcce1f7334e1b7ab/cffi-2.1.1-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:507a24c282e0f42f8ed737cf048572cbf580468da5555764a8331735e9c736b6", size = 222271, upload-time = "2026-08-03T21:20:53.462Z" }, + { url = "https://files.pythonhosted.org/packages/50/e3/f6234a833e6e08c7007003074723c406559eecf9b48dfc97471e5a8eb7a0/cffi-2.1.1-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:246fa40ce8645a614ff682e0b70f37134e460eaf93a775e0cbe3cca585a67a80", size = 209919, upload-time = "2026-08-03T21:20:54.783Z" }, + { url = "https://files.pythonhosted.org/packages/0d/fc/5f74e293fced6edb51af3a46c4ccf6c23c9943774ecb375ddbd522c76add/cffi-2.1.1-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:471cee653ae88de62096552e6d24ccb4a5adb8c8c9f10b5054d0122c15bf2779", size = 208529, upload-time = "2026-08-03T21:20:56.066Z" }, + { url = "https://files.pythonhosted.org/packages/44/16/29e6d01b388bef055ecd6ca8244b3f4d336bd09e92d5d892187b9601084e/cffi-2.1.1-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:aeae0e330c9f6acd681f647d46cefd30c29f93e3392882e792e82080c9691399", size = 221630, upload-time = "2026-08-03T21:20:57.336Z" }, + { url = "https://files.pythonhosted.org/packages/a4/18/fa7f1f6857d5eb88a4ca99ffcbfb7c387a287ccc154c64a73e86314745d7/cffi-2.1.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:42a494cee34437f05546455144f2b5d9ac09b1face62bcfce597d2e521066688", size = 225134, upload-time = "2026-08-03T21:20:58.675Z" }, + { url = "https://files.pythonhosted.org/packages/e0/9f/e8e3dfa04a1b4c241f8c91faacad872b4d4efd051d49764ad4e2fd4b9fea/cffi-2.1.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:cc572dace3f60ef98d7b12ff411d20f5362feb31a0439eab0085bbfd349982d7", size = 223197, upload-time = "2026-08-03T21:20:59.968Z" }, + { url = "https://files.pythonhosted.org/packages/f8/7e/8debeb04f1ab9fe2a6963964cd6f1aaf7192627b83926586a6a4e089c9fa/cffi-2.1.1-cp315-cp315-win32.whl", hash = "sha256:4f42141fc14250de6dde5ee7ea4432be017252d91f19c5ad043c084cea629cac", size = 177683, upload-time = "2026-08-03T21:21:14.901Z" }, + { url = "https://files.pythonhosted.org/packages/e0/31/5158704cc474ab65c1647932e88be78dc0873f47130e253be38bcaf13d01/cffi-2.1.1-cp315-cp315-win_amd64.whl", hash = "sha256:e6e8cff14d6fb0be70a09c0bdc58096f501952d04624ebf867e0e56da2df8960", size = 187897, upload-time = "2026-08-03T21:21:16.108Z" }, + { url = "https://files.pythonhosted.org/packages/cc/4b/b3a2da8570c704ffc0f9762cdc3ec0f02c8573798e0b5cf7f11c82bbb70f/cffi-2.1.1-cp315-cp315-win_arm64.whl", hash = "sha256:27350daa11d4f10c540e6e89dada4c54feb7256ad03e9a4dc075ebad7ba360d1", size = 182935, upload-time = "2026-08-03T21:21:17.271Z" }, + { url = "https://files.pythonhosted.org/packages/d0/ef/5443574510a1207e6f6bc38ba6e1f1de36cb48fef07b2728bb896a21f430/cffi-2.1.1-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:c26608d2222fb1e94487e4a387d85f13eb55d5ed725cb25a0c589ac4ee60e7bc", size = 188464, upload-time = "2026-08-03T21:21:01.163Z" }, + { url = "https://files.pythonhosted.org/packages/7e/ae/a56fa8c4686ad50e148fcbc8d3ae0d03915ff5c30d795058988c24118cef/cffi-2.1.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:4be96343e422f2dfcd12ab5c9f5aebe03f82f737c6bffeca6830b3875cb44aab", size = 188262, upload-time = "2026-08-03T21:21:02.382Z" }, + { url = "https://files.pythonhosted.org/packages/53/b2/6187f46f2912276a3ae284076109cc5c8680482f11f766ccf26db4a86427/cffi-2.1.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:937c0052c05a31ca1daf18de3158eed4dbfcb9cc107adbea227728d647be701e", size = 223779, upload-time = "2026-08-03T21:21:03.553Z" }, + { url = "https://files.pythonhosted.org/packages/8a/f6/c3ad28bd19f77047a03084424fbd4cbe997303267c14423737324be0385d/cffi-2.1.1-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:df423d40ee8654634421812bc3b196da3f9bd7d32929da813f8394c4348a5358", size = 211520, upload-time = "2026-08-03T21:21:04.863Z" }, + { url = "https://files.pythonhosted.org/packages/a0/cd/ccac9013a5bd9fd764de118674ab9c805b5ca10c19270d90ee273f8b2240/cffi-2.1.1-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a730a083190634c65cca36ba5f489531576ebd79bcd5c8e172130f6453127231", size = 210673, upload-time = "2026-08-03T21:21:06.223Z" }, + { url = "https://files.pythonhosted.org/packages/52/86/2976131c639aead931c5bee5aba67e4b09fbeb8018b6f282f70803f923a7/cffi-2.1.1-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:363e05fa78e15116c3c32c210ee36884fd6b9afa6d440e47112c3bd511d64cb6", size = 223835, upload-time = "2026-08-03T21:21:07.539Z" }, + { url = "https://files.pythonhosted.org/packages/ac/0c/33a7aeab2f9c76918c52e084beb39c570db3588133412929e8ec06fab90b/cffi-2.1.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:770de9db11e84213beec501cfcaa013b019820ca881e03344dea5844f7876d94", size = 226705, upload-time = "2026-08-03T21:21:08.774Z" }, + { url = "https://files.pythonhosted.org/packages/e3/26/2cde30fdde421130bfc18f70395731a6e6b2053c6a1978a5258ff04e72fa/cffi-2.1.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:7da0c5eff80f0197f3b3d1232ec5a682a9325f4ae9016a78f5f5ca35f9ced1f5", size = 225539, upload-time = "2026-08-03T21:21:09.911Z" }, + { url = "https://files.pythonhosted.org/packages/6d/cd/a361394c94b2129d604bb846f624a8e88255a3ee33129c434a00d715e64f/cffi-2.1.1-cp315-cp315t-win32.whl", hash = "sha256:06c72bb76605a4b0cd0aad6930b69d4baf7dd5d806cfc409b824191099700e66", size = 182707, upload-time = "2026-08-03T21:21:11.226Z" }, + { url = "https://files.pythonhosted.org/packages/9b/b5/ba2b299993c26577d529b6ae29841f9e15b9fcf004d65f423f4fcf94ade9/cffi-2.1.1-cp315-cp315t-win_amd64.whl", hash = "sha256:d9c275eaacd24aa73f94ffd6de08fc3f932424d8b6c376f4bed7cde376fe7bc3", size = 193772, upload-time = "2026-08-03T21:21:12.39Z" }, + { url = "https://files.pythonhosted.org/packages/aa/29/35e016098c814cd93de9cd320c66b5bfba14dc6ecedd3cb518fa7c408c69/cffi-2.1.1-cp315-cp315t-win_arm64.whl", hash = "sha256:d18e5ac0f2f03f4f518d3e23db0f0cad7faa1da8620e9c09461d443bbf6e6692", size = 186360, upload-time = "2026-08-03T21:21:13.636Z" }, +] + +[[package]] +name = "click" +version = "8.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/45/37/edbf1b0707709013c0cf2e8317e03d97ed29bf4cac709fe328904ae92a38/click-8.5.1.tar.gz", hash = "sha256:9bbfada76703fd1d784b83eea012e3e8c6a001a876543ef104fa56aaaeb072b4", size = 399151, upload-time = "2026-11-06T17:37:01.021Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/31/7d/164b7ffc8624fe9efb4221bf9af485d5c1e41b9ae118045d2b6dc5457d8b/click-8.5.1-py3-none-any.whl", hash = "sha256:8bb5376d2006950386f8c6427613334a2acadc5f559cb80e638d00b4df957e37", size = 126163, upload-time = "2026-11-06T17:36:59.287Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "comm" +version = "0.2.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4c/13/7d740c5849255756bc17888787313b61fd38a0a8304fc4f073dfc46122aa/comm-0.2.3.tar.gz", hash = "sha256:2dc8048c10962d55d7ad693be1e7045d891b7ce8d999c97963a5e3e99c055971", size = 6319, upload-time = "2025-07-25T14:02:04.452Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/60/97/891a0971e1e4a8c5d2b20bbe0e524dc04548d2307fee33cdeba148fd4fc7/comm-0.2.3-py3-none-any.whl", hash = "sha256:c615d91d75f7f04f095b30d1c1711babd43bdc6419c1be9886a85f2f4e489417", size = 7294, upload-time = "2025-07-25T14:02:02.896Z" }, +] + +[[package]] +name = "cryptography" +version = "50.0.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi", marker = "platform_python_implementation != 'PyPy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9d/af/182eb91b0df3fe75c4d9f26fe70684569566745f6ba7e5c9c73a862c5252/cryptography-50.0.2.tar.gz", hash = "sha256:7b46165bb56eb4704e2eaaf86f3c940d19154535d9b0ca7d6d590b04060e00d5", size = 880623, upload-time = "2026-09-30T15:30:04.884Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/56/d194340cc4a57535e82e1bee9e89667ac4b7c13b5d3f59686deae3094dd5/cryptography-50.0.2-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:fa8f5efb344d6908a1ce62f4a24e2e5780f825d6f53f5f50ec5ffacac72936cb", size = 3914904, upload-time = "2026-09-30T14:43:44.339Z" }, + { url = "https://files.pythonhosted.org/packages/d9/69/c9bd862c3bf43d6399c433caf002df16e2dffd4be49bdf515cda38038711/cryptography-50.0.2-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:79def8d059362e7831389ed3be0ecdf58a89386e1271e35dd9f5af84e81bffd0", size = 4731146, upload-time = "2026-09-30T14:43:47.113Z" }, + { url = "https://files.pythonhosted.org/packages/21/69/64cef1f702bf6657e0cc186ed1a2891d50d29fb41586b254e1c07adea261/cryptography-50.0.2-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:630ebfea3bf689d075f82316324ff7433dc447fe6bc1bfc76524b74b4a9567d2", size = 4719841, upload-time = "2026-09-30T14:43:49.01Z" }, + { url = "https://files.pythonhosted.org/packages/38/6b/61a3f8d8c5e1e49a6cddccafc4015cc1c0021360ab0acb4080e7a423644a/cryptography-50.0.2-cp311-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:f9f6143a8c75945eb960d9eb98905a441394abfa24afaae239d514ffb2586480", size = 4738340, upload-time = "2026-09-30T14:43:50.932Z" }, + { url = "https://files.pythonhosted.org/packages/7b/2e/7212ca32fd43dc91f2f41db20160b268098874b4c9a0e7be94d6835f5b2e/cryptography-50.0.2-cp311-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:a582ab2ae1d34f67112cadc86702774c9ea4374df6bca6afe672817203c99134", size = 5367029, upload-time = "2026-09-30T14:43:52.911Z" }, + { url = "https://files.pythonhosted.org/packages/1a/f1/b474e930c4d910328780e3940da76f5aa5cbc48ce1fc14e44d239d9ea9db/cryptography-50.0.2-cp311-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:4061c0079120205fb760c58acab6443e217307dcf05e3702cf970e0689972856", size = 4753050, upload-time = "2026-09-30T14:43:55.272Z" }, + { url = "https://files.pythonhosted.org/packages/7c/52/9af10e80ac16b0fcc2123f9cbd5e7afbd0fd5075bb7a607c592258a39cda/cryptography-50.0.2-cp311-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:ac9ed99d81760c62fe89d5f0815cdfa1ba9a35141cf30f1c2d044f04b4803d2e", size = 4376724, upload-time = "2026-09-30T14:43:57.24Z" }, + { url = "https://files.pythonhosted.org/packages/71/37/6202e488cc1eb625ea110c292c6bda92823176e023f427d8d5660ce8d632/cryptography-50.0.2-cp311-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:87e9ce85beb6b328ba370cc6e6aea483c92617b4c95b1d33a49297eb662bfb04", size = 4737859, upload-time = "2026-09-30T14:43:59.541Z" }, + { url = "https://files.pythonhosted.org/packages/8f/30/e86d7d518489b0ae2497091a35287abcb1a2ce4037837a34afbe9b1d6964/cryptography-50.0.2-cp311-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:f265528741e048bce55c3463ed721fb0aa45a5888d8add8cfeccb3035451bbdc", size = 5324103, upload-time = "2026-09-30T14:44:01.901Z" }, + { url = "https://files.pythonhosted.org/packages/d3/69/2c833a049475e0a3444e94c7d0aca0aa51d166374a449b09e92ac98138de/cryptography-50.0.2-cp311-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:9dab55f57c74c3cad24c323bacbbd04be4705ba6eb0d92e920b1fc4837ed5079", size = 4752576, upload-time = "2026-09-30T14:44:04.545Z" }, + { url = "https://files.pythonhosted.org/packages/6c/5d/906970b83bbfc1f5bbfb677a143c181f2801f23b6a7204a3b47c42c97e65/cryptography-50.0.2-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:25784ce8b9621c90c643efb9e1e2162ab3b0224cae446ad5e70e7fcb1ce18b51", size = 4870819, upload-time = "2026-09-30T14:44:06.884Z" }, + { url = "https://files.pythonhosted.org/packages/68/e3/f2298d3bb55e0c4a91841ec4d01b3f020ba8c5fbf15ccdcc6dcf03f97025/cryptography-50.0.2-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:85d0d9a31b9098e98534226d5686b47264b95e62ce459dc2e62fdfc809f9fe93", size = 5030152, upload-time = "2026-09-30T14:44:09.443Z" }, + { url = "https://files.pythonhosted.org/packages/9a/4f/adfc442765721292fff86d314ce385d3249d22db42295c0dd057727b60f3/cryptography-50.0.2-cp311-abi3-win_amd64.whl", hash = "sha256:7afa5a6602a9f29af1f3a2965f831bae7c9d5d597b7cbb716d41ab3b7d89879c", size = 3824692, upload-time = "2026-09-30T14:44:11.671Z" }, + { url = "https://files.pythonhosted.org/packages/ce/cb/52eb3770c0d0be2702a98c6e96065ddc0a2877cf0845aa9c23397c142cd4/cryptography-50.0.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:f785f6161f202ab04d8ca194158968798e480ca058943907972da5f12e2881e8", size = 3892731, upload-time = "2026-09-30T14:44:13.485Z" }, + { url = "https://files.pythonhosted.org/packages/19/8e/aa1fc533d4546b127b45de8aa024eb5933d23eff9debfe25931e56861095/cryptography-50.0.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0ecbc5652bdb6fc9eaf89a7d196e20941adfe812f43bc4ca05d9150496821047", size = 4710431, upload-time = "2026-09-30T14:44:15.427Z" }, + { url = "https://files.pythonhosted.org/packages/6a/64/72bc3f75176e7e406b748a3e3830432b8c51297b38368713df04dc04898a/cryptography-50.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ab50ee449bf968271e820086f10a33d101dd060370abc10bcd22279be2656539", size = 4694824, upload-time = "2026-09-30T14:44:17.69Z" }, + { url = "https://files.pythonhosted.org/packages/4e/c6/62c77550edfa5ca3f14bf44a1e6739b9fa09d6e998a11d97ed8213bccc98/cryptography-50.0.2-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:a9f7355e6fab51f6c369b86fb7571cffa05edee2c2121e0380a37fb9ac1cd5c1", size = 4716967, upload-time = "2026-09-30T14:44:19.661Z" }, + { url = "https://files.pythonhosted.org/packages/f4/37/cce70f150c432914460157a6ecc161752e053aa5ec0ef3b3f7dc6e31039a/cryptography-50.0.2-cp314-cp314t-manylinux_2_28_ppc64le.whl", hash = "sha256:94e5e9f108ee10471288214d3d233fbfbb492840a8457eb85178d643ddeb32c7", size = 5328676, upload-time = "2026-09-30T14:44:21.744Z" }, + { url = "https://files.pythonhosted.org/packages/aa/9a/6f2f0304d634ceafdeaf23e84537336664ac419b5d07611675c2ad3f6b7a/cryptography-50.0.2-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:241449bf940a5d27309bd317e6f9a2af6932113818bb2b8f5c59ddc7ef16da18", size = 4727698, upload-time = "2026-09-30T14:44:24.178Z" }, + { url = "https://files.pythonhosted.org/packages/1d/de/66bcf9244d118663b2e1aaded8990f4640e3d7b7411870a5765f252074d2/cryptography-50.0.2-cp314-cp314t-manylinux_2_31_armv7l.whl", hash = "sha256:d8947001be83df1394050758ce0e745dd74fb134eef0a4b5124208dfc3a68c37", size = 4354821, upload-time = "2026-09-30T14:44:26.263Z" }, + { url = "https://files.pythonhosted.org/packages/bd/e6/db28a28c7b6c676addce89136de3d8db49ea825a8c863472e36e42ead4ad/cryptography-50.0.2-cp314-cp314t-manylinux_2_34_aarch64.whl", hash = "sha256:4a20ce1e5cb4284a86692fdcba7cb8754185c6b2e5c56fcef3751cf451d3cdc2", size = 4716748, upload-time = "2026-09-30T14:44:28.447Z" }, + { url = "https://files.pythonhosted.org/packages/30/96/01546c7f69ea0e2ab790a2e4f0934a4052fb9b388147fbf83c2fd72f1e57/cryptography-50.0.2-cp314-cp314t-manylinux_2_34_ppc64le.whl", hash = "sha256:84f964e537f916e2cc85199e5a88742e964939b575ac8598b3f9d6cc416cdaf1", size = 5285085, upload-time = "2026-09-30T14:44:30.704Z" }, + { url = "https://files.pythonhosted.org/packages/6c/01/03263395f74d50b071e9e66daace3f8bef80493e5d410726f2ba8554736b/cryptography-50.0.2-cp314-cp314t-manylinux_2_34_x86_64.whl", hash = "sha256:828d49b0ff5a0e3975865571c5d91dbbdd0d38d8289b249a163e9425413a5e05", size = 4727268, upload-time = "2026-09-30T14:44:32.92Z" }, + { url = "https://files.pythonhosted.org/packages/eb/94/2bfe8f29ec0cc9c0d99359c4161adf32858e4934b72c6d100d2ac0bbe962/cryptography-50.0.2-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:deb9fde5c60e437ee4821bc9bc39ff31b42135c27e1dc61ef0a629389c1de62e", size = 4849503, upload-time = "2026-09-30T14:44:34.969Z" }, + { url = "https://files.pythonhosted.org/packages/54/44/e80651ecbf0e42b62e2bb5f5768916e07eea72e1297338956a61df361f88/cryptography-50.0.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:8c71ba2cd31fc93748c38e1b613200ff1c2665cbfd5341fe3a61cfde35a1430e", size = 5004057, upload-time = "2026-09-30T14:44:37.064Z" }, + { url = "https://files.pythonhosted.org/packages/f8/cc/1d33befb3cd7ea7e77d2d73f43f2066471da1b21f24a6156efcaabf6d2e8/cryptography-50.0.2-cp314-cp314t-win_amd64.whl", hash = "sha256:78198641e5be9521beea5aa782bb551a58068d10e6eb04c9c680c1b69f2e7d45", size = 3795868, upload-time = "2026-09-30T14:44:39.71Z" }, + { url = "https://files.pythonhosted.org/packages/2d/49/93f6a6e7a87c9aa68d44d3e1cdb5fe8f60c90d5d2f46acae9a56892816b8/cryptography-50.0.2-cp315-abi3.abi3t-macosx_11_0_arm64.whl", hash = "sha256:edc3342adf8f697fc5f59c887a304356f147b397809440ed64e2fa6af2f50f37", size = 4133708, upload-time = "2026-09-30T14:44:41.807Z" }, + { url = "https://files.pythonhosted.org/packages/8c/75/32ac2a56243d778805c16ca6a32b8f74fb757df7e28d7ecb560afafb59cf/cryptography-50.0.2-cp315-abi3.abi3t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d370b8d1dfcdf7130178137f6fbee6140774a1acc6cacefc4b42643ec11d0a3a", size = 4956267, upload-time = "2026-09-30T14:44:43.693Z" }, + { url = "https://files.pythonhosted.org/packages/aa/a4/2c8d734e43d97f0842ee9f1b7b4bfb3d0cf5e19edebf43c2afe6675c2320/cryptography-50.0.2-cp315-abi3.abi3t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f2f9bd7f90c64fe89253f0a2c05e3c4856072660429ce8831b4235bf29403a67", size = 4966465, upload-time = "2026-09-30T14:44:45.769Z" }, + { url = "https://files.pythonhosted.org/packages/c2/58/ee288c829a6f41f6235ae9dd33d82fd19b45442b65b4c8a3da36963d9f7a/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl", hash = "sha256:e275096ea1e60cc595cda2836fd4a6c725d1125108b868be17f53684d164e2cc", size = 4959356, upload-time = "2026-09-30T14:44:48.211Z" }, + { url = "https://files.pythonhosted.org/packages/92/20/9ded6d51ddd9897f6b6e81fb9ebea7951d7cc5d6c890b0ed8abf77a51a80/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_28_ppc64le.whl", hash = "sha256:b13478603dcd0a2479ff8e87e2c19a7d525734686fe3c49542472293a204212d", size = 5548822, upload-time = "2026-09-30T14:44:50.86Z" }, + { url = "https://files.pythonhosted.org/packages/02/a8/8df951850d6b31d2a00218f19e2b3f999523437ed7a819df7fa427942fca/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl", hash = "sha256:58a0c478eeca76fe5e07993c5a0703def34a6dc6a0cda4f5564639b33112ffe7", size = 5001199, upload-time = "2026-09-30T14:44:53.379Z" }, + { url = "https://files.pythonhosted.org/packages/8b/f9/36b3022218ce75b7cdf068fb95f809f9bd0d820e4955ef43b90c255cc7ac/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_31_armv7l.whl", hash = "sha256:d38cdff612d06fa6a32840d5e1b1f7a27cee4a349aa9085d94a67789d6bfd408", size = 4629333, upload-time = "2026-09-30T14:44:55.635Z" }, + { url = "https://files.pythonhosted.org/packages/8c/72/20f99a219f6af47cdd1cbd978c243b92d71496e168a746138af44ded4f29/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_34_aarch64.whl", hash = "sha256:fdd28f912fccfec1846a94e2e1e8f9b0012f557f0c46fe4f3eb0d7a87afcf90b", size = 4958822, upload-time = "2026-09-30T14:44:59.639Z" }, + { url = "https://files.pythonhosted.org/packages/f2/20/196f112617fb08eb4d608a2a6c422373d46f9cc2857f38fc0667033c0899/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_34_ppc64le.whl", hash = "sha256:cbc8738fd8526d80f35cb3a40d41f41a2e7030bb3b18b09a6778ef63d291c2fd", size = 5506351, upload-time = "2026-09-30T14:45:02.267Z" }, + { url = "https://files.pythonhosted.org/packages/24/95/83378121ef3eaaaf71d4b781577ff794acb39b9e1b87a3f156898c8497ed/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_34_x86_64.whl", hash = "sha256:e105ab60406787da31fccc883fc0f733af1efd78f0136a4599692c4083a73d0c", size = 5000859, upload-time = "2026-09-30T14:45:05.009Z" }, + { url = "https://files.pythonhosted.org/packages/22/f7/70fd7ae4d1dbfa7ba29b02e1b9068771519a86027756510b700ce81086a8/cryptography-50.0.2-cp315-abi3.abi3t-musllinux_1_2_aarch64.whl", hash = "sha256:6f8700550aa1474a91e5dc07049c46f98b423b5b1ddd0483e0b51362eeeaf5be", size = 5092151, upload-time = "2026-09-30T15:29:15.932Z" }, + { url = "https://files.pythonhosted.org/packages/d4/be/688367b74de86984bd58d8efacfc7c9e68b89a6a22ced0fb4f38db50254a/cryptography-50.0.2-cp315-abi3.abi3t-musllinux_1_2_x86_64.whl", hash = "sha256:c71be1cbfa5cd9a41ee452acf1eccd82b2c05950358b106ec8ceb83411d1a020", size = 5286120, upload-time = "2026-09-30T15:29:18.309Z" }, + { url = "https://files.pythonhosted.org/packages/39/d1/55f8a3f2ef5d1529e16835ef10cf0fe3d559ce237b46dddc440c0bba3649/cryptography-50.0.2-cp315-abi3.abi3t-win_amd64.whl", hash = "sha256:c423ab384a46c4dff7217b2ea5ba2e11cffdeab6441acd04cf65a369caf0366c", size = 4111557, upload-time = "2026-09-30T15:29:20.155Z" }, + { url = "https://files.pythonhosted.org/packages/23/ad/ac987755d00e1e64273760228d2635ae38dae2be83e3c6e0d3289d91dec3/cryptography-50.0.2-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:0ec5f09541743261e66e291b4a0cbf0fb2997aeaab6d9e9c740b9dba1b58d1c2", size = 3943588, upload-time = "2026-09-30T15:29:22.265Z" }, + { url = "https://files.pythonhosted.org/packages/d5/8d/6d585339bedf85d45044c85d8412dac53f2bb6f918e8b7777efba1787844/cryptography-50.0.2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c5e67125c7dca78d199ec4e116aa93dbb83494808ecbb8211a2cb09b1bf41dbd", size = 4756166, upload-time = "2026-09-30T15:29:24.58Z" }, + { url = "https://files.pythonhosted.org/packages/bf/f1/1c1f6874e8550cfddd4b688ceb38cefb6ed15ceed224d56f133f3d88c214/cryptography-50.0.2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ee247f5c245c9a2fe7c8e2214e295918838e44e00a45a6718451e4004219e767", size = 4749145, upload-time = "2026-09-30T15:29:26.807Z" }, + { url = "https://files.pythonhosted.org/packages/c1/63/61b15dc1a8de03fe0adbe3fd7608b3ad5c73bf50993bbcb1faaa930afe33/cryptography-50.0.2-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:dfe9763530994147d9af1def057a5b9658b00e8f8fe8743d144d1e0911c2e454", size = 4763638, upload-time = "2026-09-30T15:29:28.588Z" }, + { url = "https://files.pythonhosted.org/packages/fc/35/b345bdfa40c9126df1a9d33236aa98418367931b8725f84fc3ae2b98dc59/cryptography-50.0.2-cp39-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:58ddb5a8e3179d12f19e4ea34d2d32e9d63a4baa142c875c1eb59f41b7243acd", size = 5382217, upload-time = "2026-09-30T15:29:30.589Z" }, + { url = "https://files.pythonhosted.org/packages/4f/87/ef344a9e616871f2519c22d6afcda79ddd5d35e9592d95eb6e677608d055/cryptography-50.0.2-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f21e8a22c8605750c7af886bab299a363721264061b4ac0a30efb73cfd58efc5", size = 4781387, upload-time = "2026-09-30T15:29:32.605Z" }, + { url = "https://files.pythonhosted.org/packages/90/5b/f2fdb13cd0b96f6f932c8627bb292a45f11c64d21620a8e120aee9a3b848/cryptography-50.0.2-cp39-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:9c8402a82ea0dc4ceeab793db05f0fafa8ca139ca34fcde5df0f596103c74107", size = 4403790, upload-time = "2026-09-30T15:29:34.374Z" }, + { url = "https://files.pythonhosted.org/packages/bc/ce/7e4f662b1e3c393513569e402cfc85ac7da0bd3d5435e122a3140219eb2d/cryptography-50.0.2-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:0ddc924c04591c2811ca024d62ecad4f7f6f08af8939c211438f48a16bd23602", size = 4764319, upload-time = "2026-09-30T15:29:36.149Z" }, + { url = "https://files.pythonhosted.org/packages/3c/3f/86ff33ce34cc0de6847fb96e035a1a760d81652e38643f617c02ad32ef7a/cryptography-50.0.2-cp39-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:a6557e5f38e065ca9fbdaf7cfc7435ecb1d113aa81a022d1b51921ee7432e227", size = 5338560, upload-time = "2026-09-30T15:29:39.053Z" }, + { url = "https://files.pythonhosted.org/packages/40/cf/6b5c8e2fd9202d98988ab7cb5cc5c991704c4ad55f492ff408e4969f83f1/cryptography-50.0.2-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:1981f1db4630889b9ef7803fadef12b056f428cb6b85c27ba57b774793b6093c", size = 4780973, upload-time = "2026-09-30T15:29:41.251Z" }, + { url = "https://files.pythonhosted.org/packages/10/bf/8d6ebc7dded797bd0f0160d52188021211f011a2b164ef0ae1dac4587465/cryptography-50.0.2-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:7a8701d6b584d76e909e3d305b7d126b41439876a5aaf76cddc67fc230eafa2e", size = 4897738, upload-time = "2026-09-30T15:29:43.106Z" }, + { url = "https://files.pythonhosted.org/packages/d4/aa/f3f6e0de7e6253b8baa8b2d8fb9d50924fa75cee3d4624bd4bc1208ee923/cryptography-50.0.2-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ce47f66801c20ec6c6632453bb5960fe38939e9306970b48b3a5a26de7745d94", size = 5058280, upload-time = "2026-09-30T15:29:44.827Z" }, + { url = "https://files.pythonhosted.org/packages/f6/b6/a1faf3a27ae9405fb34b1713cc73b2d8a26b04d5c561578fa2e6ef3e5bb9/cryptography-50.0.2-cp39-abi3-win_amd64.whl", hash = "sha256:4e81d95e5bafc2d6e34e4bed780e53e4d5b9a2f928573428aa4d35fbec1eb0de", size = 3854095, upload-time = "2026-09-30T15:29:46.782Z" }, + { url = "https://files.pythonhosted.org/packages/1d/7a/f08d34ce09d60f89ebd391e2ebc6ba2b995e6dd7552f41820f8085f94e53/cryptography-50.0.2-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:92e665960f25fcdc73725b9cec7a3824f279ba97a98653afe9ffac2e43668f67", size = 4716035, upload-time = "2026-09-30T15:29:48.681Z" }, + { url = "https://files.pythonhosted.org/packages/45/67/e18fb65592451a2acb76e9f2fbe14e0f47a8318b4c5430f1633851d03daa/cryptography-50.0.2-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:eef4c2f3423810b3070ab391f85436d2f8bbfcb286ac15cbc73190b3563b1f1a", size = 4726917, upload-time = "2026-09-30T15:29:50.608Z" }, + { url = "https://files.pythonhosted.org/packages/83/28/38fdce17e60f6b825e69fc3b7f75e70a6612759980704697e1de4cbfaf6e/cryptography-50.0.2-pp311-pypy311_pp73-manylinux_2_34_aarch64.whl", hash = "sha256:7c6d0330c472d96f6a6afe24d80dfdf15176c33096f0a4397ae4c60f3dd3be48", size = 4715341, upload-time = "2026-09-30T15:29:52.522Z" }, + { url = "https://files.pythonhosted.org/packages/b6/b1/d9121a717e0f893c64bd6ca7702614778d7df2a5c309128a002421788516/cryptography-50.0.2-pp311-pypy311_pp73-manylinux_2_34_x86_64.whl", hash = "sha256:1ba34f04897fcdaa73f74145c25f3ec146fbd56593853e88adc2e811303c5f42", size = 4726322, upload-time = "2026-09-30T15:29:54.263Z" }, + { url = "https://files.pythonhosted.org/packages/36/8b/e6d153808bf353e152abd2fd4d8f09670d956ac78379ac46e60d7efbf04c/cryptography-50.0.2-pp311-pypy311_pp80-macosx_11_0_arm64.whl", hash = "sha256:3dc4fd8058cea1644971207d530e1a03a184a805ffc8ebdddf0599d78a331b81", size = 3873097, upload-time = "2026-09-30T15:29:56.097Z" }, + { url = "https://files.pythonhosted.org/packages/ca/1d/1271f287ff7170ddafc2aad36260c4eec20ccd2fea70f38455e9d56d427b/cryptography-50.0.2-pp311-pypy311_pp80-win_amd64.whl", hash = "sha256:7b75de3c8b3be1cdb1052747c929440c3eea46c1bc2cb8a6e3a48388e9b7b452", size = 3805376, upload-time = "2026-09-30T15:29:58.729Z" }, +] + +[[package]] +name = "debugpy" +version = "1.8.22" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/44/9d/3cb6693342acf96802dba89934a5b8da43c201d764ebd1f2c0514a3d42bd/debugpy-1.8.22.tar.gz", hash = "sha256:e489c7268e1c7b41e13b438d9c533d2a7af73fb59bf8cd30fead8286c1c39c4e", size = 1710877, upload-time = "2026-09-15T21:44:02.578Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/26/4a/8c24c588088c622df6dacdc0110e9cc81b44781fe7a408113441e76aa955/debugpy-1.8.22-cp311-cp311-macosx_15_0_universal2.whl", hash = "sha256:66e4ac3d6e7026e83e7d93d7ee2f51dd4a4e8dff673578d424e60796893e5b2c", size = 2217799, upload-time = "2026-09-15T21:44:11.57Z" }, + { url = "https://files.pythonhosted.org/packages/c7/14/1c9ff33eba51da70a8dfe2277cc13153bb3ffec79282b9acfcdbe1641d30/debugpy-1.8.22-cp311-cp311-manylinux_2_34_x86_64.whl", hash = "sha256:192b73e8d53bbd60225220c0943627bf249ac93d0ea3090e23c45f3e0ceb6a35", size = 3074375, upload-time = "2026-09-15T21:44:13.349Z" }, + { url = "https://files.pythonhosted.org/packages/10/e8/1fa16a94af7d8b86c3ca336d7d32b78cb2c475266d0bb889732d2bc50310/debugpy-1.8.22-cp311-cp311-win32.whl", hash = "sha256:745e1800ec2961e5660c1a317c0a20e28c0fef4de36c04f17a21c33f2b37a92a", size = 5258392, upload-time = "2026-09-15T21:44:15.182Z" }, + { url = "https://files.pythonhosted.org/packages/32/1a/c086b883a4561017bfdd83c1bc70bf2b05ab6540ff767dedf207cadab938/debugpy-1.8.22-cp311-cp311-win_amd64.whl", hash = "sha256:1e76339d5510bc17e9181dba9577508afcb21aad5728f1a55ef74d7d97d255f3", size = 5277955, upload-time = "2026-09-15T21:44:16.986Z" }, + { url = "https://files.pythonhosted.org/packages/73/21/5c7f5c66eaeee57c9dadb0bbff22efddc8d99cdbd3d036c806175f1828cc/debugpy-1.8.22-cp312-cp312-macosx_15_0_universal2.whl", hash = "sha256:4ad076f4f66cb8acb79e4384d48b1ea60a0b1957aa0b1112d4887ea3a4df60e0", size = 2499375, upload-time = "2026-09-15T21:44:18.478Z" }, + { url = "https://files.pythonhosted.org/packages/7e/ec/7389798843643ea5bc6a08480ba1b855377c70e2ed90189c0a03594e401e/debugpy-1.8.22-cp312-cp312-manylinux_2_34_x86_64.whl", hash = "sha256:8a697acec45dbc70d17fb5d9f4f61989fc294d273c69de487fd10cb35fdd75eb", size = 4000941, upload-time = "2026-09-15T21:44:20.245Z" }, + { url = "https://files.pythonhosted.org/packages/20/f4/64ce7a2499550929e08654360b270409eeda3e321b7c27027d9c919aa36b/debugpy-1.8.22-cp312-cp312-win32.whl", hash = "sha256:12bc7f368182b517cf26c76a2393fff65354e365fa1552b6241e66edff17997b", size = 5359040, upload-time = "2026-09-15T21:44:22.218Z" }, + { url = "https://files.pythonhosted.org/packages/4b/fe/e7d3b72874cdd327bda295d1995a01e426857ae9cbaaba74fd997bc3afbc/debugpy-1.8.22-cp312-cp312-win_amd64.whl", hash = "sha256:371a4ba4a5975eb958393903f3254cf983da7b1c7c178b3f987ee427f42515e3", size = 5398304, upload-time = "2026-09-15T21:44:24.119Z" }, + { url = "https://files.pythonhosted.org/packages/6b/f4/fee6d40f5865aa84e1100c9df1a0f2cf8991776b61f11f433ff277df4415/debugpy-1.8.22-cp313-cp313-macosx_15_0_universal2.whl", hash = "sha256:c21dd7e1ec22556bb41dc3bf6b86c603e440ec889c4acb27d7206354b2106c54", size = 2493531, upload-time = "2026-09-15T21:44:25.835Z" }, + { url = "https://files.pythonhosted.org/packages/bc/4f/8df91270afbf61fc5ab202951f28451194a7eb093704b26da11cb0ecd308/debugpy-1.8.22-cp313-cp313-manylinux_2_34_x86_64.whl", hash = "sha256:c1ffb9953708b648ecf6acd2e5ad2c002bf68785ed618197dd4463a2a7226f39", size = 3994351, upload-time = "2026-09-15T21:44:27.31Z" }, + { url = "https://files.pythonhosted.org/packages/4f/11/2e34a4f21d6155b0c58003fd6fca9819df7d6fe7d7acd83b146b648a57ee/debugpy-1.8.22-cp313-cp313-win32.whl", hash = "sha256:ba810a66b437e3c43ca0ce0892404f010338286263ca8e5108442d76a9485337", size = 5359071, upload-time = "2026-09-15T21:44:29.064Z" }, + { url = "https://files.pythonhosted.org/packages/d0/f5/c2b3e8260388d7b76bc4e5a3a29648a0ca47dca6a2721d6549ff2d944eee/debugpy-1.8.22-cp313-cp313-win_amd64.whl", hash = "sha256:f49b1d6cecf326b63c06d7f517e4a6642777f758c58cb799e7bc5a6dd74721c2", size = 5400362, upload-time = "2026-09-15T21:44:30.857Z" }, + { url = "https://files.pythonhosted.org/packages/ea/95/d97240bb68b86db8d0a07602be068aae9e50f17063d696a4c6f619975311/debugpy-1.8.22-cp314-cp314-macosx_15_0_universal2.whl", hash = "sha256:e6744ac1850c73c2ba7b29a126cf9ab74efd1831190720e8fee17ef5389c8f5d", size = 2493148, upload-time = "2026-09-15T21:44:32.518Z" }, + { url = "https://files.pythonhosted.org/packages/70/9e/994fe1fb23dd4a5a8d059a0dc95da4b0821907200a61c2d5a4fdc21b6cf8/debugpy-1.8.22-cp314-cp314-manylinux_2_34_x86_64.whl", hash = "sha256:0c1104233340196e5cbf5514e7dfdbb98968e730cfd7fdd6f3d72a082be838a9", size = 3961025, upload-time = "2026-09-15T21:44:34.387Z" }, + { url = "https://files.pythonhosted.org/packages/37/e0/66319918883cf6dd6dea3805210c3cafd9e65dfaa6f8b852482cff10a026/debugpy-1.8.22-cp314-cp314-win32.whl", hash = "sha256:feea785c7bbeb8cfd5b01a63f9061c899dc468c8be81671141a29305774fa294", size = 5359408, upload-time = "2026-09-15T21:44:36.128Z" }, + { url = "https://files.pythonhosted.org/packages/94/53/5b4d91f7fffb9393ac907133201d1da0c070d57e463ee8e2ec1db3cb63b6/debugpy-1.8.22-cp314-cp314-win_amd64.whl", hash = "sha256:d593a330297332ec435f3965c448b6d500e03f33675cf2063178bc76377a788e", size = 5397429, upload-time = "2026-09-15T21:44:38.429Z" }, + { url = "https://files.pythonhosted.org/packages/24/71/580df4aed96c9b23c9cbb049907d8ac1347050afdb8f450df20649d51578/debugpy-1.8.22-cp315-cp315-macosx_15_0_universal2.whl", hash = "sha256:a9eca6ab09a61534e923064400081e016f7e1d8430cc6e8b7a9cecd2f59e2b07", size = 2493380, upload-time = "2026-09-15T21:44:40.074Z" }, + { url = "https://files.pythonhosted.org/packages/b0/10/a323945b0966e560c40fe48470d2847bfc7692a8f550d7086e9a28f5b623/debugpy-1.8.22-cp315-cp315-manylinux_2_34_x86_64.whl", hash = "sha256:b7dbde1fb822d100802d505b2aed6d0813b1a0a2015d495cb8798b2215d5d1e5", size = 3975456, upload-time = "2026-09-15T21:44:41.623Z" }, + { url = "https://files.pythonhosted.org/packages/ef/f9/4383635281999c3eaa44bf327de523ba42240b35eb87c1130adac4a829c6/debugpy-1.8.22-cp315-cp315-win32.whl", hash = "sha256:225d063f81708c2546999e7edfac0198b2d5c2f144797dc64858f867948633e0", size = 5359469, upload-time = "2026-09-15T21:44:43.234Z" }, + { url = "https://files.pythonhosted.org/packages/7b/14/4fe9f46a9c825c8cbc6dc4aebc2a885b0bceb37ce2a37699c170482e7a40/debugpy-1.8.22-cp315-cp315-win_amd64.whl", hash = "sha256:b17a4896520f1c6da09ce76ec8215df0b85b0b6f3617526a4c65c2315340875a", size = 5397869, upload-time = "2026-09-15T21:44:44.783Z" }, + { url = "https://files.pythonhosted.org/packages/56/3d/c7dc9f35bc9e22cdb53679f844bee40fd5cff871862f60595869a433400d/debugpy-1.8.22-py2.py3-none-any.whl", hash = "sha256:a9e9d3550e15ca479c59333e90845029190531f0cacfedab3b815a57bd913947", size = 5374857, upload-time = "2026-09-15T21:44:54.454Z" }, +] + +[[package]] +name = "dualect" +version = "0.1.0" +source = { editable = "." } +dependencies = [ + { name = "jsonschema" }, + { name = "mcp" }, + { name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, + { name = "numpy", version = "2.5.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, + { name = "oct2py" }, + { name = "pyyaml" }, + { name = "ruff" }, + { name = "tree-sitter" }, + { name = "tree-sitter-matlab" }, +] + +[package.dev-dependencies] +dev = [ + { name = "mypy" }, + { name = "pytest" }, + { name = "ruff" }, + { name = "types-jsonschema" }, + { name = "types-pyyaml" }, +] + +[package.metadata] +requires-dist = [ + { name = "jsonschema", specifier = ">=4.23" }, + { name = "mcp", specifier = ">=2.3,<3" }, + { name = "numpy", specifier = ">=2.0" }, + { name = "oct2py", specifier = ">=5.8" }, + { name = "pyyaml", specifier = ">=6.0" }, + { name = "ruff", specifier = ">=0.8" }, + { name = "tree-sitter", specifier = ">=0.24" }, + { name = "tree-sitter-matlab", specifier = ">=1.3.3,<2" }, +] + +[package.metadata.requires-dev] +dev = [ + { name = "mypy", specifier = ">=1.13" }, + { name = "pytest", specifier = ">=8.3" }, + { name = "ruff", specifier = ">=0.8" }, + { name = "types-jsonschema" }, + { name = "types-pyyaml" }, +] + +[[package]] +name = "executing" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/52/92/8a611141e42930c0f194f7504063ab87dfe970cf1a5af28e7703df448734/executing-2.3.0.tar.gz", hash = "sha256:15919cb5d667e5cb4e099511971d00d659573fff2dd5c4e6cd8b71636c7858d2", size = 1338003, upload-time = "2026-10-10T14:06:04.64Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4d/dd/8bc67e7d5ffc1d88aa5af511189dfb76dc4e1e5b808fab186146ef2663e5/executing-2.3.0-py3-none-any.whl", hash = "sha256:736e859c9f8701f11fcf516856f26f562e04776387824b43a35a1dfe21c84122", size = 29393, upload-time = "2026-10-10T14:06:02.777Z" }, +] + +[[package]] +name = "h11" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, +] + +[[package]] +name = "httpcore2" +version = "2.16.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "h11" }, + { name = "truststore" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c0/61/afa9d6b7452f9eca73f73d45324eb0bb52f098fd5e6049bf6b8263be9b4e/httpcore2-2.16.0.tar.gz", hash = "sha256:c72cd0413563b17e1cd8354677dff887466f8ec2551679759e93126534428643", size = 69886, upload-time = "2026-10-21T07:09:45.31Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/af/c2/ce417c397afa5181f0e3c6ff01a4d01639414e1adef08730d97571297151/httpcore2-2.16.0-py3-none-any.whl", hash = "sha256:5c4358319f2602d984ad93182c9fee5160f22e9da7babdda870a5e7c4e2dc34f", size = 85070, upload-time = "2026-10-21T07:09:42.802Z" }, +] + +[[package]] +name = "httpx2" +version = "2.16.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio", marker = "sys_platform != 'emscripten'" }, + { name = "httpcore2", marker = "sys_platform != 'emscripten'" }, + { name = "httpx2-jsfetch", marker = "python_full_version >= '3.12' and sys_platform == 'emscripten'" }, + { name = "idna" }, + { name = "truststore", marker = "sys_platform != 'emscripten'" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/43/73/5ca2cedf5e4e50423d1c258877865a6b62793633b561c58499f8aeb33b7e/httpx2-2.16.0.tar.gz", hash = "sha256:0d54c98128e8f2ff7fbbde0fca8c359e5f032edeaaaac443cdb7f31f685bcd7f", size = 103116, upload-time = "2026-10-21T07:09:46.348Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7b/3d/2e4bc4fd1ef9770871669adb348d612a6e4786b303a23f9935b81c48dd60/httpx2-2.16.0-py3-none-any.whl", hash = "sha256:fd2c5d7909e8d86fe92d53020c310ca0e4e431b838c207c5754b9bbf0308d49a", size = 97880, upload-time = "2026-10-21T07:09:44.01Z" }, +] + +[[package]] +name = "httpx2-jsfetch" +version = "1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cd/c4/0e5636363151a2a1795e0a77617168b9ca438e1748ec05fc9b5687f93d64/httpx2_jsfetch-1.0.tar.gz", hash = "sha256:70a0e3eabfef7cce5ad9c629f7d01ca05e418f586646f4ddf14782e4c1454c60", size = 6872, upload-time = "2026-08-07T00:13:07.492Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9b/43/832f631d32e4f1211caa2ba368317739fe71f0b8530e4c9d15dc454bac2a/httpx2_jsfetch-1.0-py3-none-any.whl", hash = "sha256:cb916b707601e69a07721aabc8f3f6659be3a6893bc1ff5c6f9e02241df2da32", size = 6382, upload-time = "2026-08-07T00:13:06.567Z" }, +] + +[[package]] +name = "idna" +version = "3.20" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f5/08/8eea9d4b8302028f3abb2c0813953f7aec26d33b7a8960ed760e65ff29fa/idna-3.20.tar.gz", hash = "sha256:a7db850025b95ded1eae8a46181a1a6c56c92c96f0e2b005d9ff8dc0210cab44", size = 216463, upload-time = "2026-09-17T14:11:04.752Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/58/a2/bb081bab032533a855d44de1d56f8e8426114ff1ba5d1f07a438a0a654f8/idna-3.20-py3-none-any.whl", hash = "sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c", size = 69583, upload-time = "2026-09-17T14:11:03.168Z" }, +] + +[[package]] +name = "iniconfig" +version = "2.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/e1/2069291243c926a2ff1cd706c7f3eeb9b62144bf60f77c9fb9ff2fb26bd3/iniconfig-2.3.1.tar.gz", hash = "sha256:67f4b9c50da0dedf52af349e7749a80a9057a5031199791b906c3bb3ae878960", size = 21209, upload-time = "2026-10-06T22:48:38.076Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/56/43/4ca9e49d27a1fcf6bece6f6aec0ea46bb9112489b93d4b688fb415457bdb/iniconfig-2.3.1-py3-none-any.whl", hash = "sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7", size = 7552, upload-time = "2026-10-06T22:48:36.959Z" }, +] + +[[package]] +name = "ipykernel" +version = "7.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "appnope", marker = "sys_platform == 'darwin'" }, + { name = "comm" }, + { name = "debugpy" }, + { name = "ipython" }, + { name = "jupyter-client" }, + { name = "jupyter-core" }, + { name = "matplotlib-inline" }, + { name = "nest-asyncio2" }, + { name = "packaging" }, + { name = "pyzmq" }, + { name = "tornado" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7a/05/e5499c8b762387d83926bf0389e8fff888c9bf6e7af30566a8527bc12f4a/ipykernel-7.4.0.tar.gz", hash = "sha256:4330114d22b9b33575b2c7c68753fc8faabbbcfbc60b0cdff9f14dd4ce63742f", size = 192731, upload-time = "2026-09-29T16:33:11.468Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a5/f8/8b5c10c7f36ab5a3b5c4703669e5b14e44e98782b58e535dd30670e8799a/ipykernel-7.4.0-py3-none-any.whl", hash = "sha256:a6757f790ddc5a6006b813d82da1a9dbb65b3a00f2b6607df776418c6566ec1c", size = 123184, upload-time = "2026-09-29T16:33:09.612Z" }, +] + +[[package]] +name = "ipython" +version = "9.18.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "ipython-pygments-lexers" }, + { name = "jedi" }, + { name = "matplotlib-inline" }, + { name = "pexpect", marker = "sys_platform != 'emscripten' and sys_platform != 'win32'" }, + { name = "prompt-toolkit" }, + { name = "psutil", marker = "sys_platform != 'android' and sys_platform != 'cygwin' and sys_platform != 'emscripten'" }, + { name = "pygments" }, + { name = "stack-data" }, + { name = "traitlets" }, + { name = "typing-extensions", marker = "python_full_version < '3.12'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/38/04/0d945c72d5b77527273ecb4c66aa2436de7a3b3bbe3da345bf053232b886/ipython-9.18.1.tar.gz", hash = "sha256:6319c0f5372c196397899479e6db1783dd7937abae06815d1317e8d5d51aaaaf", size = 4437314, upload-time = "2026-11-02T09:19:55.55Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bb/1c/91da4a1c541b75e97eb99d09c6a9b0534de55bb4a466669d1170e39b915c/ipython-9.18.1-py3-none-any.whl", hash = "sha256:997ce9140d374531a61069c70c0f9ef299d6dd3559ea0f94b8af589726e3c1d5", size = 649819, upload-time = "2026-11-02T09:19:53.32Z" }, +] + +[[package]] +name = "ipython-pygments-lexers" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ef/4c/5dd1d8af08107f88c7f741ead7a40854b8ac24ddf9ae850afbcf698aa552/ipython_pygments_lexers-1.1.1.tar.gz", hash = "sha256:09c0138009e56b6854f9535736f4171d855c8c08a563a0dcd8022f78355c7e81", size = 8393, upload-time = "2025-01-17T11:24:34.505Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d9/33/1f075bf72b0b747cb3288d011319aaf64083cf2efef8354174e3ed4540e2/ipython_pygments_lexers-1.1.1-py3-none-any.whl", hash = "sha256:a9462224a505ade19a605f71f8fa63c2048833ce50abc86768a0d81d876dc81c", size = 8074, upload-time = "2025-01-17T11:24:33.271Z" }, +] + +[[package]] +name = "jedi" +version = "0.20.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "parso" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a3/a4/4692ecd7fa700ac1066b1c1f6cadef60aa2e01e5e364710235137d823e0a/jedi-0.20.1.tar.gz", hash = "sha256:2f71208c3f9c1bca057c0e90d3f272aba44ace88fc4067d7587e9e069331b7e5", size = 3121738, upload-time = "2026-10-12T17:42:24.361Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/be/c7/71eb0d51cdcbb63b857c931aa4e9218b078b5d9f8ecd383b234f28fe7b0f/jedi-0.20.1-py2.py3-none-any.whl", hash = "sha256:0fb16d86c4a4c73c37ba518c77419975e30fcc620658a8d14fbb5720cdd34142", size = 4885980, upload-time = "2026-10-12T17:42:21.585Z" }, +] + +[[package]] +name = "jsonschema" +version = "4.26.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "jsonschema-specifications" }, + { name = "referencing" }, + { name = "rpds-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b3/fc/e067678238fa451312d4c62bf6e6cf5ec56375422aee02f9cb5f909b3047/jsonschema-4.26.0.tar.gz", hash = "sha256:0c26707e2efad8aa1bfc5b7ce170f3fccc2e4918ff85989ba9ffa9facb2be326", size = 366583, upload-time = "2026-01-07T13:41:07.246Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/69/90/f63fb5873511e014207a475e2bb4e8b2e570d655b00ac19a9a0ca0a385ee/jsonschema-4.26.0-py3-none-any.whl", hash = "sha256:d489f15263b8d200f8387e64b4c3a75f06629559fb73deb8fdfb525f2dab50ce", size = 90630, upload-time = "2026-01-07T13:41:05.306Z" }, +] + +[[package]] +name = "jsonschema-specifications" +version = "2025.9.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "referencing" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/19/74/a633ee74eb36c44aa6d1095e7cc5569bebf04342ee146178e2d36600708b/jsonschema_specifications-2025.9.1.tar.gz", hash = "sha256:b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d", size = 32855, upload-time = "2025-09-08T01:34:59.186Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", hash = "sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe", size = 18437, upload-time = "2025-09-08T01:34:57.871Z" }, +] + +[[package]] +name = "jupyter-client" +version = "8.10.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jupyter-core" }, + { name = "python-dateutil" }, + { name = "pyzmq" }, + { name = "tornado" }, + { name = "traitlets" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c5/2a/906772148a06e48885039e0250c340b770a55bbf37b08d6ee0449df369c3/jupyter_client-8.10.0.tar.gz", hash = "sha256:9f7116294dca55f1785be880057d44544db9b1567718d92cb33c58886afb9497", size = 360653, upload-time = "2026-08-28T12:17:10.854Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0f/88/7c548de1f6c2ade7c931a3282da73f9274fa6a1531091be682f89c85efb9/jupyter_client-8.10.0-py3-none-any.whl", hash = "sha256:5f73f24f22fa25192cfff6b23c051932a2473a797b05734aff495b392103e14e", size = 110184, upload-time = "2026-08-28T12:17:09.028Z" }, +] + +[[package]] +name = "jupyter-core" +version = "5.9.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "platformdirs" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/02/49/9d1284d0dc65e2c757b74c6687b6d319b02f822ad039e5c512df9194d9dd/jupyter_core-5.9.1.tar.gz", hash = "sha256:4d09aaff303b9566c3ce657f580bd089ff5c91f5f89cf7d8846c3cdf465b5508", size = 89814, upload-time = "2025-10-16T19:19:18.444Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e7/e7/80988e32bf6f73919a113473a604f5a8f09094de312b9d52b79c2df7612b/jupyter_core-5.9.1-py3-none-any.whl", hash = "sha256:ebf87fdc6073d142e114c72c9e29a9d7ca03fad818c5d300ce2adc1fb0743407", size = 29032, upload-time = "2025-10-16T19:19:16.783Z" }, +] + +[[package]] +name = "librt" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/04/f5/9dc696772d241814bacac7880bac32f2930b5a6ebc1f85317b83161a011c/librt-0.16.0.tar.gz", hash = "sha256:ac38d6d8d66bf3d744148dbbc0b8e193e195a51e364ed55e224631f5721891fc", size = 219839, upload-time = "2026-09-29T00:55:32.891Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ba/0e/b04fd2d76b6a78a02286938251b2c119fb36ddece92c76cb4886ef7d44b8/librt-0.16.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:fe4372c52d4849096c6cc1cda2817d293ec51440c890474ed59ef38d46556f18", size = 148058, upload-time = "2026-09-29T00:44:40.903Z" }, + { url = "https://files.pythonhosted.org/packages/a3/fc/e1ed24aadb32d38603c0c07f579d739eb4d90e64e90d525b024e4a999b4d/librt-0.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c72c5295a84bd249526da9bdca38f2e176d15c31c13bb0063c5053f4ca023421", size = 153073, upload-time = "2026-09-29T00:44:42.165Z" }, + { url = "https://files.pythonhosted.org/packages/be/38/133ab655409420e0c34a9a9836a7f4e5ae75fba758d7fe177099130d58ba/librt-0.16.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:be56ba9c884143495b517f23fe794ae367d58cd89ea0fdd6d437e3c024a87f9f", size = 493052, upload-time = "2026-09-29T00:44:44.043Z" }, + { url = "https://files.pythonhosted.org/packages/94/42/aaa663bc9421f5bf7bbbe9d3316d7219749698ec7688ac3b519770a89c04/librt-0.16.0-cp311-cp311-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:ef46c1a29ffb8c72e882e22618ec618778eacd0578fb22c6e7cf9c11d15f357b", size = 485506, upload-time = "2026-09-29T00:44:45.479Z" }, + { url = "https://files.pythonhosted.org/packages/7b/59/83a6eb5087ba8b45b083859e2085256963e06d4c2531944cdd962670bfb5/librt-0.16.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:d3c94211ee0c4f8d649ec06b7c115c0ec4eadb873a0e3154ca15cef3f814b071", size = 498708, upload-time = "2026-09-29T00:44:46.916Z" }, + { url = "https://files.pythonhosted.org/packages/a0/e4/15a8d62b2bc12935080ec7277e2e0b9b233047781eb784a51d3e25af669a/librt-0.16.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:94aed6a8308818b91677957d1bd03188869cd7aeb23c5dba7912a6c0402f7602", size = 515981, upload-time = "2026-09-29T00:44:48.316Z" }, + { url = "https://files.pythonhosted.org/packages/46/4f/287cc282ac5dd815204c0779e79401bb0a568c3a1335fb319bf0838fb566/librt-0.16.0-cp311-cp311-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:349c0bcb87ebd07481b6ff781e25cdc699723dbe2212e57dabb27f7a13b7b87d", size = 508670, upload-time = "2026-09-29T00:44:49.726Z" }, + { url = "https://files.pythonhosted.org/packages/bf/5b/ab7292add898ade0d2b5b75d32a923aae315861671aa5c39f5491309f7ae/librt-0.16.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:001bfd59a7d45b17e3e75f2a8c6405280b35e7b84471792778e718c4f368950e", size = 530393, upload-time = "2026-09-29T00:44:51.356Z" }, + { url = "https://files.pythonhosted.org/packages/7a/9e/8e6bcf027d4bcbc16a4e864b3d158a1d3e5f55ffa53af0238020cad89271/librt-0.16.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:28e038895b998d7a0c7798922ce8a1dc157675df5cf1c9ef0aca809ed804b7a1", size = 534302, upload-time = "2026-09-29T00:44:52.893Z" }, + { url = "https://files.pythonhosted.org/packages/96/a4/8c5ab4f3b3a8e905ff8305d76976a2e666f52fe049edd398aed2402beb36/librt-0.16.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:0dbe4096a7ecc00fa835d24510ad8545a4efef738dac96e0e63516783ccde905", size = 536150, upload-time = "2026-09-29T00:44:54.421Z" }, + { url = "https://files.pythonhosted.org/packages/ea/5e/7c4bc267e3cd4b8bd288de9f62d61fff203829c9cc649ea2aa12e9218cf0/librt-0.16.0-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:5cd5b092441053364af968ea12084692cb9d4a22f3ce9524e377880bf028761e", size = 514316, upload-time = "2026-09-29T00:44:55.998Z" }, + { url = "https://files.pythonhosted.org/packages/e0/75/c8bc6b50f43c73819334233f5a3259c81216742cef56d2140c3dd377c3f0/librt-0.16.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:3ddeb3c9dedb461bb457c6c7d9aa7fbf35329da313d1a7543d00c8d0f3473c96", size = 557731, upload-time = "2026-09-29T00:44:57.581Z" }, + { url = "https://files.pythonhosted.org/packages/93/fb/e241f91bc8de6c7ac1c6a20ea6dd381bc52312b44d711ffcd97140db1e57/librt-0.16.0-cp311-cp311-win32.whl", hash = "sha256:e05108e0849966f53a8d2d3112a7af881d0efaa479bc735bba91108f9f2350a7", size = 104922, upload-time = "2026-09-29T00:44:59.078Z" }, + { url = "https://files.pythonhosted.org/packages/d1/38/c892383d2bb1a6a80b2ec8ede84970a265a792c56614a06282bf3008517c/librt-0.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:5f49cff01bd608ef7d97104cb035c75455e79c2d70bf4a506cf773338ac1860d", size = 125093, upload-time = "2026-09-29T00:49:01.621Z" }, + { url = "https://files.pythonhosted.org/packages/e4/56/8bbde1ed0b21480163617648f638fdaec9374cf5e9c846ebcee34ec02a42/librt-0.16.0-cp311-cp311-win_arm64.whl", hash = "sha256:1d28ae980ae2218f9c5b95d191e947296f918c9bf0b400d467a9430275bbe678", size = 115910, upload-time = "2026-09-29T00:52:40.131Z" }, + { url = "https://files.pythonhosted.org/packages/ad/76/bbdaeb87b7c47b5c7343e90222b9bfa4e4a8a83f647e02933ad0129225b1/librt-0.16.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:fe52bf4641069e7978a14253b036cb9002def1926317e710f2e249f8a8c47742", size = 151028, upload-time = "2026-09-29T00:52:41.508Z" }, + { url = "https://files.pythonhosted.org/packages/fd/0c/ab8ed3dab0085931aec4a792c7eaac8dc6c5ff4691fda3a5360d9d8a9cd2/librt-0.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5bcc2c4726ced915b00de0c9856a4eeabfb3fddb93e10e0b8f735b7709358b6d", size = 155283, upload-time = "2026-09-29T00:52:42.873Z" }, + { url = "https://files.pythonhosted.org/packages/eb/36/494e79d460c80c1f030661e8287c9eca5e1ad652dc2b2180b6cd42abce0a/librt-0.16.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ff7baa55f8e7c69851419e50a666015d02a74198716fd45c0125a2112e0a389f", size = 503185, upload-time = "2026-09-29T00:52:44.638Z" }, + { url = "https://files.pythonhosted.org/packages/9b/34/a8464038dd9db6e4381fa2b6eb73dc9a50888d77102c4c139304ac35cddc/librt-0.16.0-cp312-cp312-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:b95d5d92ab83d39e760a52091bb1baba664f3a2351e39b1e16801e5747c2f0e9", size = 496738, upload-time = "2026-09-29T00:52:46.441Z" }, + { url = "https://files.pythonhosted.org/packages/6a/53/e0e5e334ef0c6ed27039d323819368b9ef6712be87d55ee2bf9799398afd/librt-0.16.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b6d085d70bce51d43c5c7c36d63490770180d8779e71c49305c87b4213918de7", size = 513818, upload-time = "2026-09-29T00:52:48.068Z" }, + { url = "https://files.pythonhosted.org/packages/ad/f7/7ce72cbf19d0addd05090b339152fd0548a02562c2866a603e6e3b3da2df/librt-0.16.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:36e53948e99bbe3ffea257124cfcae1cfb01831555c9a9c903c9f9a72db7fd07", size = 531952, upload-time = "2026-09-29T00:52:49.816Z" }, + { url = "https://files.pythonhosted.org/packages/83/22/0b1bcb6a8e723c8b4fd60dfc8ae8ec6461c54073fbc8685efeb8d900d407/librt-0.16.0-cp312-cp312-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:54d11f726aae9df5a6ffbbf0a03a52449bbac84a53ef03669cb41cdfd4ae41bf", size = 524465, upload-time = "2026-09-29T00:52:51.354Z" }, + { url = "https://files.pythonhosted.org/packages/64/2e/e9c23b8b9df1813da1be205deca9606beb7ddd033972246cd426d05374a0/librt-0.16.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:4323193ac0cd025f85af531df8ba91bf24d1973b401697347a6282e8fd3fcf5e", size = 543191, upload-time = "2026-09-29T00:52:53.284Z" }, + { url = "https://files.pythonhosted.org/packages/bc/e5/6a8b21b342c03ed7e230fa3afbfd2edc58e6e87ef1f0d11fa2b9a748c252/librt-0.16.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:e42f8e098b9c5396fefa05fb1cc7e33b0e08fc51da106b5de4a45fd22aac6743", size = 546979, upload-time = "2026-09-29T00:52:54.932Z" }, + { url = "https://files.pythonhosted.org/packages/84/9e/b5129023eced1be01e01c22757f53be551d463b1bb7264f787927404c1d6/librt-0.16.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:39ec1d5a14e37baf1450a6cabf03fe552340808bf1ad9d71824ab90117716459", size = 555317, upload-time = "2026-09-29T00:52:56.869Z" }, + { url = "https://files.pythonhosted.org/packages/71/89/28bba5938c725fe91f06bf93f7fa6c6b150229df53a87b454b0d5c2a796e/librt-0.16.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:d1aabe3925cbb4a08d15b7b20ba4011b53019da0c4173a25155139b7b1baed65", size = 535846, upload-time = "2026-09-29T00:52:58.475Z" }, + { url = "https://files.pythonhosted.org/packages/22/92/63773026614f888c5d4e370e395ce42ca604b89f70b3acdfedbf94851b80/librt-0.16.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:300c3ffdc459f4a779a8411ecb188e3ac0b1ff3a3a7b099642555dedae06c69b", size = 573700, upload-time = "2026-09-29T00:53:00.127Z" }, + { url = "https://files.pythonhosted.org/packages/66/8f/347d4677eefb57cd9f8e01d95a1dcee9a91b4e44e664173c32ff6f3752e5/librt-0.16.0-cp312-cp312-win32.whl", hash = "sha256:c17194318e4c0c0348b36f36c2ec7534436fe0a4c15582403162a4f08c80797a", size = 106158, upload-time = "2026-09-29T00:53:02.031Z" }, + { url = "https://files.pythonhosted.org/packages/f0/2c/5193dc81127cd5ddfad031391b046bf32dda219b38463ab872407ca30646/librt-0.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:25a58a19ea8d83b68209f04912df765e9260635ef77646542ed4b4abe6bc7940", size = 126176, upload-time = "2026-09-29T00:53:03.445Z" }, + { url = "https://files.pythonhosted.org/packages/ff/3d/9668a400c8dd81d162eba38b33fa49fa6205f1a64493570a13fbb815c3ee/librt-0.16.0-cp312-cp312-win_arm64.whl", hash = "sha256:f7be7cf555bc30ec12622e9447299cc4a9b8ff307548b634794353db0c2065dc", size = 116572, upload-time = "2026-09-29T00:53:04.815Z" }, + { url = "https://files.pythonhosted.org/packages/46/cd/ae5e0e9dba45d1399aa04a5395bcc0bead40d9fa06dc903634a7b4d7473d/librt-0.16.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:c5e6144e68b577f157519f2ba88ca20e3ed61c29b00e5cdfa76cd2d45acf059a", size = 151036, upload-time = "2026-09-29T00:53:06.284Z" }, + { url = "https://files.pythonhosted.org/packages/41/5a/48a16e323c5f9447a94cce7b59babf60fa04e62c3365ecf060c77ed8b320/librt-0.16.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:33f41443a1f4e1f099331b3d8120e409fbff84b9760bc1cc9ea496f37ddaa5cc", size = 155211, upload-time = "2026-09-29T00:53:07.72Z" }, + { url = "https://files.pythonhosted.org/packages/3f/29/0f59299eb4251a409b2e690ad4b7d9f8a676db829d7817ec961f32b44f7e/librt-0.16.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7e510b7770bee609617a3374a96548eb114cae048023e3f049ee449e7ff2db32", size = 502587, upload-time = "2026-09-29T00:53:09.191Z" }, + { url = "https://files.pythonhosted.org/packages/de/ba/d6fb4ef8d1537c396079d72289f16be7cd35a366e5065c51253fea2760b6/librt-0.16.0-cp313-cp313-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:efc49c462d4516b8a58b00b490078fa64689fd1fe66970cc190131d7afb8027e", size = 496146, upload-time = "2026-09-29T00:53:11.016Z" }, + { url = "https://files.pythonhosted.org/packages/52/fc/8c50dd4d7cc97c0ee8f252c8a3104980f234391cf1519b554e8b9de08b60/librt-0.16.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:92caf82ebef5e12d21c72242b70d1e92536f1711cf2a727a4c276de4b4469087", size = 513336, upload-time = "2026-09-29T00:53:12.655Z" }, + { url = "https://files.pythonhosted.org/packages/a9/59/16c409c56f708eda2db9a0553662845d45e3871c77d70a240dae3f3bdc56/librt-0.16.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:17bac7f7a16b328fff77e440287693eb017abde913595b5827ebccbc21ecd8a6", size = 531689, upload-time = "2026-09-29T00:53:14.39Z" }, + { url = "https://files.pythonhosted.org/packages/88/82/d34772a6c29d1446dcca6e64d74062efd508523ab351aa16625a4689d5cc/librt-0.16.0-cp313-cp313-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:5b976054553670829985ed767feb78fb6bcede0175327c4844dd5c281c1be659", size = 524537, upload-time = "2026-09-29T00:53:16.064Z" }, + { url = "https://files.pythonhosted.org/packages/77/8f/24c5631313746131ccee53bc91fdc8374f9cf25e0082a1fee9c93bb98acc/librt-0.16.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:0058f9d68721094105917254c72ac0569117bb7b13b9769cf45d26d89f9d21cd", size = 543231, upload-time = "2026-09-29T00:53:17.939Z" }, + { url = "https://files.pythonhosted.org/packages/f2/cb/5f8e0d41dbd8b499c2265e939c31acc9ba59845565bf99539ad1c06aebcf/librt-0.16.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:30b7beaf3f4487b7d8adef1f158b49067cb4d5a19fa7a3bf31a4e7a820e435c5", size = 546499, upload-time = "2026-09-29T00:53:19.666Z" }, + { url = "https://files.pythonhosted.org/packages/be/61/063052de441d1385f59cea4223f184bf9e5d125de1ae3239b490aa1e486e/librt-0.16.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:468df902df016a06eb0e40b0747dc8d14e47d7a38b18b63b1fb167d85cb94d63", size = 555261, upload-time = "2026-09-29T00:53:21.292Z" }, + { url = "https://files.pythonhosted.org/packages/14/11/a2ada0529372268d6401afa9d457a095b68cd7753532b6f7f33049a19b43/librt-0.16.0-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:aea7b1f2b125dad5de85f049136651bff256c883c65e6b9209b2da0a1ac3cdef", size = 536029, upload-time = "2026-09-29T00:53:23.07Z" }, + { url = "https://files.pythonhosted.org/packages/23/9d/5bb6d38853382986dca702fc7e06c8256d30f5fa0676d882773b744610dc/librt-0.16.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a8afb6557920860b7a3a596eb804cf37e09e7cf8a803db2478c202acc72d8c2e", size = 573748, upload-time = "2026-09-29T00:53:24.696Z" }, + { url = "https://files.pythonhosted.org/packages/99/f6/0025cde35ff7f607684dc775a2b2d732cce2561cec050a6ee1fb2e1fc6fe/librt-0.16.0-cp313-cp313-pyemscripten_2025_0_wasm32.whl", hash = "sha256:77c7a2b4fe2c1369e0d5aa1cade26740a7b14be32fbc9a5535d617d20065c39d", size = 79861, upload-time = "2026-09-29T00:53:26.089Z" }, + { url = "https://files.pythonhosted.org/packages/93/93/303b8592909bd583f83f02818ffbea3f7647ca1e22b1cd5465d04b8145fe/librt-0.16.0-cp313-cp313-win32.whl", hash = "sha256:02d89c813d5ff74b17df72d3a34819d132cd168e56b81bf755b809bd9e46b8c4", size = 106236, upload-time = "2026-09-29T00:53:27.43Z" }, + { url = "https://files.pythonhosted.org/packages/cf/24/80bbb463c60ed18e29cb26aba386ddb76609580e4e7160710e550587018c/librt-0.16.0-cp313-cp313-win_amd64.whl", hash = "sha256:14ed6ebe3e4f85f326d7920011ad30ff49ed9334e62cf88caef9ba973d9e3a92", size = 126180, upload-time = "2026-09-29T00:53:28.7Z" }, + { url = "https://files.pythonhosted.org/packages/43/80/b1a6fbdd7da825cdd55c71aa81eb6cfa82c513c360774152eacb50b4a771/librt-0.16.0-cp313-cp313-win_arm64.whl", hash = "sha256:83d4041a3d9b2fd053a8a4e1f22878b3e5833e2712956382d5c048d791454e91", size = 116557, upload-time = "2026-09-29T00:53:30.012Z" }, + { url = "https://files.pythonhosted.org/packages/1e/93/9e0cf7da129a93c3dc7f45bc3cd4a660f2aaa995aa8a6f95c2583ef41239/librt-0.16.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:931a0bb0fcac88f263e269e46eb30ba8e21402cd3c62ca40cb97034c0693fab1", size = 149844, upload-time = "2026-09-29T00:53:31.391Z" }, + { url = "https://files.pythonhosted.org/packages/8f/26/8a90d2a8f2b2e471bb486b7aec117b8ae622715ed6c39853aec48ea20073/librt-0.16.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:1bc17e54e5305f8d40b7ca203671ff5a9e59c1d0f8ea0f625dcca53a3984de11", size = 154111, upload-time = "2026-09-29T00:53:32.718Z" }, + { url = "https://files.pythonhosted.org/packages/35/ce/67abb46258da4d3e42ff5b141db6f38c59357bef84c7979f183b22f924f1/librt-0.16.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:877698bf6bca5721d8be345f2fe09778e40ecadea8b58c73075f2b1a53666bf2", size = 494234, upload-time = "2026-09-29T00:53:34.466Z" }, + { url = "https://files.pythonhosted.org/packages/12/f9/ea7162414a16f8f1bbd3b493ad6d22b926c5471916e078350bdbca8c4e5f/librt-0.16.0-cp314-cp314-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:5981c011b306781ce561e18e14230a14524a3d8109b97553666c942c18f31a96", size = 491173, upload-time = "2026-09-29T00:53:36.124Z" }, + { url = "https://files.pythonhosted.org/packages/b1/09/9b3e869060dd33f9989b80ba4fea306f6db8cecefcdfe6d7346ef0603f65/librt-0.16.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:afced3dfc17cd805ecf7a3d77996a71cf5f2c75aa66eb0c21a9930f4fc992f86", size = 505547, upload-time = "2026-09-29T00:53:37.686Z" }, + { url = "https://files.pythonhosted.org/packages/50/07/79007d2165f649ea93e08c0962d1d62c70af9cde77965255095bf9d96f9a/librt-0.16.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ca8052401c55d7511dda6760719fda7618067e83535d7d0010096d216c34b667", size = 523057, upload-time = "2026-09-29T00:53:39.301Z" }, + { url = "https://files.pythonhosted.org/packages/61/0c/8fbaff66d0ba376d8864653f5acce1569bae27e89648671f26f7eca67ab8/librt-0.16.0-cp314-cp314-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:1e511762a074005bb0aa569166779834e75e438370226930d0ce1866d4b6a33b", size = 515158, upload-time = "2026-09-29T00:53:41.012Z" }, + { url = "https://files.pythonhosted.org/packages/df/2e/23ff0dece76f07a4124413a57682efa0bbeb5765ac0122bc0955513f82ca/librt-0.16.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:f1e8591bd8a5a628cd7f07954c6a1592359a878bf032957a8e9057a41d644311", size = 534183, upload-time = "2026-09-29T00:53:42.451Z" }, + { url = "https://files.pythonhosted.org/packages/26/c4/e11dea21d9a29486eba78887380374189d472734fa32cc50cb37ca44d3d0/librt-0.16.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a4aaefb4ba6c07e1aeebb2795c8958148f1d6f9af3b555b53d23d766edb6d67a", size = 540663, upload-time = "2026-09-29T00:53:44.272Z" }, + { url = "https://files.pythonhosted.org/packages/44/75/e873ae158a8b7f5359be33e7fd6c1fbe02d9a78a3e89a77de6b0e837f476/librt-0.16.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:d92db7a0f6aee44f1baee94750457e8d2d1c6ccea41842de6268d34e8dc7eddd", size = 545908, upload-time = "2026-09-29T00:53:45.812Z" }, + { url = "https://files.pythonhosted.org/packages/ba/36/8939d3f6a93e11bd9592e6fe28d2b44f1c2dc4bed6e22e72359a91e18ffb/librt-0.16.0-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:378dfaffb38e59c24a87cde5713cd865d51ff7383fa12947f3907f306ea1ca55", size = 523302, upload-time = "2026-09-29T00:53:47.596Z" }, + { url = "https://files.pythonhosted.org/packages/71/14/35309f44a077f0f42ade0e2e7cd88c0cea760c661af205c01ea90d3c0e1f/librt-0.16.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:3e0c39bdc85370422e8b637be76eb1fd07d30967551b03e62267dd156f553152", size = 565911, upload-time = "2026-09-29T00:53:49.278Z" }, + { url = "https://files.pythonhosted.org/packages/78/0c/df6255b94967f3159ebc46f08d8e783c12da6ee269ddb74b2efed63c640c/librt-0.16.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:1b384b90ab79a7bc30b566895809a636e0666f21f3cf12b54823d025b7e83839", size = 79119, upload-time = "2026-09-29T00:53:50.938Z" }, + { url = "https://files.pythonhosted.org/packages/6b/44/d30d5a5461378c9d33f36736c6791c3b4c4ba4b1ffe0da7350aedcb2c9a0/librt-0.16.0-cp314-cp314-win32.whl", hash = "sha256:52327da75a94012e7f932f913d20d3876bed3c102be00e6c3e8600ff7bdd58a7", size = 100140, upload-time = "2026-09-29T00:53:52.205Z" }, + { url = "https://files.pythonhosted.org/packages/c2/98/769712f356a1e897df3581bb0c3100375d054a000de26099360ea65b5111/librt-0.16.0-cp314-cp314-win_amd64.whl", hash = "sha256:3f0b8114c44b2ac06ff5dacd08e07e8e807ff4f46083f2a1602685122559be41", size = 120464, upload-time = "2026-09-29T00:53:53.495Z" }, + { url = "https://files.pythonhosted.org/packages/bf/d3/ae2abccc8bdc8b063c1613a77686e17b74e9d3d60cfe6f12c63fa2821b9f/librt-0.16.0-cp314-cp314-win_arm64.whl", hash = "sha256:8caf96a4ef8fb27d0ac0d1ad8337d26a240acd4a02fe4345d0a8f264753e8f99", size = 110889, upload-time = "2026-09-29T00:53:54.817Z" }, + { url = "https://files.pythonhosted.org/packages/e4/26/0737d4be058dd6376eade7dd8b380d4b869b6394cee929393a5a431c45bb/librt-0.16.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:953107e2f68d0f3512c48f898b0dbf0ce5cc52bba0f318d847c985dc555ee4cc", size = 159838, upload-time = "2026-09-29T00:53:56.22Z" }, + { url = "https://files.pythonhosted.org/packages/01/96/9bc96531d7c620e9949af904470f02e3fa8f35129ab8e8f281c51eaa3788/librt-0.16.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:ad37d5b9abd49c9a655dcda7ea52a8a752884062ef1ee71ae17c2f2a0f81fe6a", size = 162018, upload-time = "2026-09-29T00:53:57.532Z" }, + { url = "https://files.pythonhosted.org/packages/0e/fa/b0289dcb186eb3f97221ba00da5f4bd3ba7fa5e99752d48aa8d336615334/librt-0.16.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2c4aa329c17bd1aaea4f6e89335d8ccd494b3a5830b6654462273e50e11023f0", size = 703983, upload-time = "2026-09-29T00:53:59.024Z" }, + { url = "https://files.pythonhosted.org/packages/d9/ab/05ebbbde7530fc5eeb58fbd1581522a9f64f132fa703c4c595eed6e14760/librt-0.16.0-cp314-cp314t-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:0ead24d2562a49473dddd9efef8581f020007eb0054389c3ee3ffad38b1ca4c9", size = 683847, upload-time = "2026-09-29T00:54:00.671Z" }, + { url = "https://files.pythonhosted.org/packages/a3/75/f52aeecd4dbadbddf80725ba7de126d8bd5d0eb66247eae17a81ed90dd4d/librt-0.16.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:02118f56a9c36ddd07dfd9b919d9ecc117ba20a90987d56aa4c429fa34509188", size = 698045, upload-time = "2026-09-29T00:54:02.247Z" }, + { url = "https://files.pythonhosted.org/packages/e6/55/fa277a835cd6eb42380591ceb85f48c5b4d2b2d7e2cb9869e1e17d24d237/librt-0.16.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4e29522c62e28595ff7e324c6834ade51127707f0e255b18d1c1cf03d39c1048", size = 724640, upload-time = "2026-09-29T00:54:04.078Z" }, + { url = "https://files.pythonhosted.org/packages/25/e4/2cf64354f3fde8ebd591b3b48f96510bee24ac5f7d1e567adbbe210abdbd/librt-0.16.0-cp314-cp314t-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:3ff4b2367926b69c6215635902cccb04048e73094e9862900d27cb2c6bbff143", size = 731748, upload-time = "2026-09-29T00:54:05.741Z" }, + { url = "https://files.pythonhosted.org/packages/f8/c9/c180af3e94e01aa529fa93d7733fec2abc47f222345400cf21d5481d5f8a/librt-0.16.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:c6f1b27bf1632a7e016af9f145f82be95e1edd7721a646505c21059257cb5a04", size = 754960, upload-time = "2026-09-29T00:54:07.38Z" }, + { url = "https://files.pythonhosted.org/packages/95/d6/01073aa78c58f356b10d9c57b3fe9abb143df338142bcd316df417b89db0/librt-0.16.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:5696d7f52e7b37217cb3a8f92c744fe835942602fdd4c1a8bc4741d3bfdce15e", size = 747000, upload-time = "2026-09-29T00:54:09.06Z" }, + { url = "https://files.pythonhosted.org/packages/f7/d8/1de3783908658d697a8cfc00582f61299ffba7796d7260c112e4700b1109/librt-0.16.0-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:6072e92dd876ff6ceeb6cf371e35e51f479349837391341f479b08df4564242b", size = 749569, upload-time = "2026-09-29T00:54:10.702Z" }, + { url = "https://files.pythonhosted.org/packages/b7/32/e817f66c96d6caa8bb8435ff93c4c220624d59efc506be59ab98fcd01d0c/librt-0.16.0-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:39ca4f2f2fe05de8e63493da592d84311adabe5bef52b193851981da9816b302", size = 729483, upload-time = "2026-09-29T00:54:12.25Z" }, + { url = "https://files.pythonhosted.org/packages/7c/c9/23992ccd2b9d22798fdd0f61353183a47414e651da782ad83eb680f50833/librt-0.16.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f9807485a908f00355820f18e91e045ffdcdc5adb68aaec40a1e2b88c5f7bba1", size = 776584, upload-time = "2026-09-29T00:54:13.837Z" }, + { url = "https://files.pythonhosted.org/packages/67/3b/e8af957f08e6e2e8e566b099e43d2748418aa565df6ee1d9d3331209fdfe/librt-0.16.0-cp314-cp314t-win32.whl", hash = "sha256:94be5cb7bca4df6201f4183e9e4fa2086c655283d20b38cd84500a69057575a7", size = 104402, upload-time = "2026-09-29T00:54:15.568Z" }, + { url = "https://files.pythonhosted.org/packages/ca/1c/946e6443d7cd32347a086043395e421e52fd603c9163d2ec970ceab8eed6/librt-0.16.0-cp314-cp314t-win_amd64.whl", hash = "sha256:d46ca272b251d033dd4527b0dec5f261a28a52bd5fa0f99c117b0a1f8588cc2d", size = 126227, upload-time = "2026-09-29T00:54:17.165Z" }, + { url = "https://files.pythonhosted.org/packages/c2/a3/bc4f9959d3c62bcbf9e5fd3470a8bbd8bf33224ed4c25d7fba173201b8ac/librt-0.16.0-cp314-cp314t-win_arm64.whl", hash = "sha256:b9d6d4b14e92d876f8026b54c20c445f36425214c1081dc76f74e40db386b82b", size = 116493, upload-time = "2026-09-29T00:54:18.567Z" }, + { url = "https://files.pythonhosted.org/packages/b6/4b/10fdb42dfab4c1533e1570e686b18e86ff4328b406361b39fb3016667638/librt-0.16.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:6fe436af2eaf630474f491af5d032cbe45f93fcff5c3b9fe4ab194a7255b20ff", size = 149829, upload-time = "2026-09-29T00:54:19.933Z" }, + { url = "https://files.pythonhosted.org/packages/8e/30/a90ca13f1d3d91af1680000a4038536907018fbd51764767287a05d28b8b/librt-0.16.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:8ff5d26c529336be9bd7ae04483235d77778ee7d6444a95353102b542601ce81", size = 154522, upload-time = "2026-09-29T00:54:21.306Z" }, + { url = "https://files.pythonhosted.org/packages/5c/dd/bcf364eacfa070bb1fc88d503111ae7177914197ba1fa717c748926e7930/librt-0.16.0-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:909d8e3c1faee44cb762b1c519ff8613dcc5ceae5c99987a00917b5a31fd1d6a", size = 497593, upload-time = "2026-09-29T00:54:22.798Z" }, + { url = "https://files.pythonhosted.org/packages/18/c1/2c4e81e347bdabfe8346bfc6dc37ae5e154d61c88e30848ec0606025a5e0/librt-0.16.0-cp315-cp315-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:6d4a64283ee61824b5790de882bc68e2d9d7a5143537cb7a966f7354f71646d4", size = 480459, upload-time = "2026-09-29T00:54:24.364Z" }, + { url = "https://files.pythonhosted.org/packages/ab/d7/fef2a3cb8400701be496f6e459876f650b3451f407e30cb243de571ae615/librt-0.16.0-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:5810ba811297fdf37a1531a57667cb8ace0842013ca8606bf9eb7c24cf4be154", size = 507814, upload-time = "2026-09-29T00:54:25.997Z" }, + { url = "https://files.pythonhosted.org/packages/e1/6f/53762927a32e9dc9eb1d1c1f3528da281290c86d96929a8af652f671266e/librt-0.16.0-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e56aaf8c167548dc8e5d6f3bd0f48dcdd299a23c73be3f744aab79d99e9c7f5d", size = 525114, upload-time = "2026-09-29T00:54:27.747Z" }, + { url = "https://files.pythonhosted.org/packages/6c/67/0b9d031f303c4e8c691a9a8ef9d272f13b530c11cc563b819df621b6a348/librt-0.16.0-cp315-cp315-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8f36c58e33b304b525c6c9c5076399c6ebf1109e17b9051a05a407b091b9215b", size = 520465, upload-time = "2026-09-29T00:54:29.331Z" }, + { url = "https://files.pythonhosted.org/packages/ae/d5/2056a3a85864e882eb17a203a10ddb26fa748bc9718ec67e79059ab46cae/librt-0.16.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:242e00b3d4fa37c3d3c1ca5f5c9adb7d909ddb1eac9c41f2787320d00caa0af2", size = 537257, upload-time = "2026-09-29T00:54:30.915Z" }, + { url = "https://files.pythonhosted.org/packages/54/57/e0d79790c163cbc0909e209a6f62e30bb713b647f905a176cdc64848fd4d/librt-0.16.0-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:0253721561787b8df8443eb347b7a6461015354e5bdd37ee38a41fef220d2bb0", size = 527442, upload-time = "2026-09-29T00:54:32.478Z" }, + { url = "https://files.pythonhosted.org/packages/aa/50/1c0c95aba7af51f4752ea34fbf2eb79b36e7cae3a72536248e8c735de735/librt-0.16.0-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:3e483a8d69ede8067db70c0e83007423b6925de6fd53afed01d66160f2e9398c", size = 548139, upload-time = "2026-09-29T00:54:34.183Z" }, + { url = "https://files.pythonhosted.org/packages/98/91/a8a43dd5138d4f55f88846b8f0c85454a4fad69952cebfcff9948f831290/librt-0.16.0-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:69ba927445cfaaffb4081003ef5224c55a5c2ab67ef956f416ef744916e44121", size = 529708, upload-time = "2026-09-29T00:54:35.761Z" }, + { url = "https://files.pythonhosted.org/packages/2d/41/d5226881ab2b7c20d9d587b37bdd4a0ec8775a96d00ca87ac9f385587db4/librt-0.16.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:d6a365f2ab45a984d0e00eee0dd17f599ceab8cadab6ea07b6111c8132fc0e42", size = 567781, upload-time = "2026-09-29T00:54:37.409Z" }, + { url = "https://files.pythonhosted.org/packages/bb/bf/2345ba57a626e8c78c4ddcc724636a8df5a593fe46c1ee76bbf477e32b0d/librt-0.16.0-cp315-cp315-pyemscripten_2026_5_wasm32.whl", hash = "sha256:f01f3805f2dae4781c0c34b440e31740d082950bdaf89a6f601ad589a28af57a", size = 79177, upload-time = "2026-09-29T00:54:38.792Z" }, + { url = "https://files.pythonhosted.org/packages/1e/40/99e77936cc9207f629b077bf7cbc5e2f0827cddd7c29792f04ef881bd2c3/librt-0.16.0-cp315-cp315-win32.whl", hash = "sha256:b0e3e721c75d2e79a76d4422c79d7ba705fe1bbafec907037fe7a657a480a0e3", size = 100127, upload-time = "2026-09-29T00:54:40.251Z" }, + { url = "https://files.pythonhosted.org/packages/56/1e/801fe26bc622061b9dfd010e166d94142cb774b733217e6d98d1c0cf2638/librt-0.16.0-cp315-cp315-win_amd64.whl", hash = "sha256:bc02954b1295de798bbdb0b4e2d8a28c2117de8b5c73dcbeb27dc32572dfb971", size = 120480, upload-time = "2026-09-29T00:54:41.722Z" }, + { url = "https://files.pythonhosted.org/packages/bb/a9/d533983055bd36e112627384c2c038845d1df882540b8bcefb566475640b/librt-0.16.0-cp315-cp315-win_arm64.whl", hash = "sha256:c5db585d43449a5f54303d4b2774e45e1babd975cfe1630a3d708c0b80c3e560", size = 110915, upload-time = "2026-09-29T00:54:43.052Z" }, + { url = "https://files.pythonhosted.org/packages/55/fe/d62238fa9c653b0e0613290349467cb65711b5800e8e474f45e942a0ad95/librt-0.16.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:f06c689cb14afd9b612727553a5ec5a40febf113ca41c4413a2b0b334285884b", size = 159714, upload-time = "2026-09-29T00:54:44.497Z" }, + { url = "https://files.pythonhosted.org/packages/f3/ac/f31efe7818700be72ba4f9af8a80fa67c39808c8d26dacc55dc1f6f35172/librt-0.16.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:13b4e8aba90b0b1c82474e9844aa9ffe7ad3faa484350e1da64cb8188d903134", size = 162086, upload-time = "2026-09-29T00:54:45.968Z" }, + { url = "https://files.pythonhosted.org/packages/d9/16/4d7487bf86a9d7e8e18f37ba5538789233ea693637379b75701bd35ec9de/librt-0.16.0-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5a269c46ae327d8e6f8c1f85f7516cb52c0fa48127565a1105a4f4a05ff2a0b4", size = 712727, upload-time = "2026-09-29T00:54:47.486Z" }, + { url = "https://files.pythonhosted.org/packages/77/74/50cd550ccc1a517b9ed62347625c01ddf8c4afad66490312677c011458f6/librt-0.16.0-cp315-cp315t-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:a33e0dae1f8592146a4764d54ce842b278732d21a84e17c3bbe6b1bc158a2248", size = 681106, upload-time = "2026-09-29T00:54:49.126Z" }, + { url = "https://files.pythonhosted.org/packages/df/5d/7293f712975ee6fdd2251411fd9ef1c62bc99c7b83ecbe62dbc999b1fab7/librt-0.16.0-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:47ada6ea32636492c61aa8ad27ae3b9404bfe7a97e3ba946d1984236cc741da0", size = 705921, upload-time = "2026-09-29T00:54:50.905Z" }, + { url = "https://files.pythonhosted.org/packages/67/f7/8aab946f11d59d1bece9ffc65d994b200c789a8ca5a95c17e17e609f912a/librt-0.16.0-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c43bd6e642d8a248c114327f98dd25ac5a7cb5aa168ef02f0559b91874df16b8", size = 731786, upload-time = "2026-09-29T00:54:52.584Z" }, + { url = "https://files.pythonhosted.org/packages/43/76/1c42ab31e7cb8384ebf6d3af607213c495222474f4940443ae7639ab7685/librt-0.16.0-cp315-cp315t-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c3d1bb7841a816ace6449bb26d3f9560dbfa20e71c568d23f0f62bf1e68f50b1", size = 744964, upload-time = "2026-09-29T00:54:54.217Z" }, + { url = "https://files.pythonhosted.org/packages/6f/2e/4b19982d933d2dfced671e840b219e4c1cd3f507df6e6dabb51bbd4e3850/librt-0.16.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:3931f7a3db322e7f44e02a280e3949326ce9579ad388ee8d691dc7c76da9fb70", size = 765305, upload-time = "2026-09-29T00:54:55.815Z" }, + { url = "https://files.pythonhosted.org/packages/b8/1b/e872583de2dcb3ac7746e7a2321aeeb168274f3952a87dc66e05ddb29faf/librt-0.16.0-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:f4462528b6000afe8f16907b5c7c2553abf1df005ba5140e6eb394541c3624c3", size = 744959, upload-time = "2026-09-29T00:54:57.532Z" }, + { url = "https://files.pythonhosted.org/packages/10/de/a18c6bcfb297af2674233e90b3c3661c3a0af0f1434a0c966d2ef708a835/librt-0.16.0-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:80039ba9b6a7d5f1a0175a4cca6bbefead87bd854c80abad1cb30afe47a830db", size = 758138, upload-time = "2026-09-29T00:54:59.484Z" }, + { url = "https://files.pythonhosted.org/packages/22/1c/0df1d732539c297bb1a093e1fe3204d2faf76a9022cf4e1d1c2fce059790/librt-0.16.0-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:7a1d272724b581bb6bc769dfdafed6da2ecc9886ba2450311de55a4ac2e1e9cd", size = 744268, upload-time = "2026-09-29T00:55:01.179Z" }, + { url = "https://files.pythonhosted.org/packages/a2/f7/ccaf31331f20c91a5bd9bd48ffc3f743f9c81bb5720cc7b2a720ca204f0a/librt-0.16.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:fbe4fb8c5445f7496d7f7f6bb0807875d09d47e6771ffa175fb2df2895fb86ba", size = 785783, upload-time = "2026-09-29T00:55:02.938Z" }, + { url = "https://files.pythonhosted.org/packages/c1/ea/7421d9e6db894cd6cd788b604b3394a163ded6b942052b6f96c23ccf08e1/librt-0.16.0-cp315-cp315t-win32.whl", hash = "sha256:375bfe6b572a8f6cfc398709356046173bf27e64c4c5edaf5f7062f051fb4bf9", size = 104355, upload-time = "2026-09-29T00:55:04.533Z" }, + { url = "https://files.pythonhosted.org/packages/85/6d/7c31a506eb847bc58aeb2402d58e17605e821f68ab5df5e66fe274a6df41/librt-0.16.0-cp315-cp315t-win_amd64.whl", hash = "sha256:bd3150023d3dc2bc70f3784e59ffa1140d56ddba3d8125b3d6f9f85221279bfc", size = 126134, upload-time = "2026-09-29T00:55:06.017Z" }, + { url = "https://files.pythonhosted.org/packages/36/69/7a5d10ac409c4da0355e054a14371871da9b5557fcc42772cd00181c6cce/librt-0.16.0-cp315-cp315t-win_arm64.whl", hash = "sha256:8ceafb70f2a4f0826f11031942e59c0728fd98da112dc346d4352bde1e486866", size = 116391, upload-time = "2026-09-29T00:55:07.484Z" }, +] + +[[package]] +name = "matplotlib-inline" +version = "0.2.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/bd/c0/9f7c9a46090390368a4d7bcb76bb87a4a36c421e4c0792cdb53486ffac7a/matplotlib_inline-0.2.2.tar.gz", hash = "sha256:72f3fe8fce36b70d4a5b612f899090cd0401deddc4ea90e1572b9f4bfb058c79", size = 8150, upload-time = "2026-05-08T17:33:33.49Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/41/09/5b161152e2d90f7b87f781c2e1267494aef9c32498df793f73ad0a0a494a/matplotlib_inline-0.2.2-py3-none-any.whl", hash = "sha256:3c821cf1c209f59fb2d2d64abbf5b23b67bcb2210d663f9918dd851c6da1fcf6", size = 9534, upload-time = "2026-05-08T17:33:32.055Z" }, +] + +[[package]] +name = "mcp" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "httpx2" }, + { name = "jsonschema" }, + { name = "mcp-types" }, + { name = "opentelemetry-api" }, + { name = "pydantic" }, + { name = "pyjwt", extra = ["crypto"] }, + { name = "python-multipart" }, + { name = "pywin32", marker = "sys_platform == 'win32'" }, + { name = "sse-starlette" }, + { name = "starlette" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, + { name = "uvicorn", marker = "sys_platform != 'emscripten'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9d/8d/e0d339616f4810e9051d4aba6887afab289ab1f81875fe908b606cdfd0e3/mcp-2.3.0.tar.gz", hash = "sha256:8b147a50441cf059dc88c684e0aeed3687f0aa0f39c6cde7b90330effd2b34d8", size = 4171955, upload-time = "2026-10-02T22:06:56.091Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/d7/4a2878f128df729db3ca04e71bfce26405cc2e0c9ebe19c592feeb4c61b9/mcp-2.3.0-py3-none-any.whl", hash = "sha256:dd0c44c089d16453e8ae31a3877a0054d7a2314caaa81f5e0541b9b1734b2377", size = 368664, upload-time = "2026-10-02T22:06:52.119Z" }, +] + +[[package]] +name = "mcp-types" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pydantic" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9e/2d/7c251e34207f6c51000312fc8839111ac45cfe02023f90b44e7f1051dd8e/mcp_types-2.3.0.tar.gz", hash = "sha256:d1e46549edb35ee19a94940fcee6d1addd7e589ab7ea92dda83f5d84781fc362", size = 65898, upload-time = "2026-10-02T22:06:57.863Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ce/48/32583066b155bb5d4507e7887dc88ee23118cc4de8e2a12870c49719e2a8/mcp_types-2.3.0-py3-none-any.whl", hash = "sha256:968efdbdaedfab06adae40d378a34395f1090c5921d4be3c9cde283aaf76d91d", size = 69108, upload-time = "2026-10-02T22:06:54.099Z" }, +] + +[[package]] +name = "metakernel" +version = "1.0.7" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "comm" }, + { name = "ipykernel" }, + { name = "jedi" }, + { name = "jupyter-core" }, + { name = "pexpect" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/94/95/c3e6312e8135ac099d755d50b4f579b3c7c359c2fe5d04828f7b8479643e/metakernel-1.0.7.tar.gz", hash = "sha256:499a0e399e353e0fb4a74e105ea2ad2aed89a15053a299f5fa93c027d721743a", size = 238525, upload-time = "2026-08-17T11:06:45.408Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/16/17/53bdb8b19607336d15b1004dc0b8f032c47aa08d8bc31a6f1fab26983207/metakernel-1.0.7-py3-none-any.whl", hash = "sha256:75318777e5b7e80c59e9732e9b9b1ac11c85b337f7c9375dfb7a3acce03b936a", size = 206177, upload-time = "2026-08-17T11:06:43.984Z" }, +] + +[[package]] +name = "mypy" +version = "2.4.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ast-serialize" }, + { name = "librt", marker = "platform_python_implementation != 'PyPy'" }, + { name = "mypy-extensions" }, + { name = "pathspec" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/4a/3c/78ecece71ee4b5445389a4ccd11627cfb9c69e4de554d11060171f376305/mypy-2.4.1.tar.gz", hash = "sha256:63b590965691e540a335fa74dadf31a7069142f6b72e234689bbd244edf55623", size = 4066728, upload-time = "2026-10-28T19:23:13.286Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4b/8b/2bc7f489528db504221ad7eff6b3f83979ee57d066103c72a85d09046a30/mypy-2.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:79a1e79199e980fb41f219cb3d4746d25c64b0b623840d3ed57df1cdc13a6502", size = 14321495, upload-time = "2026-10-28T19:21:16.612Z" }, + { url = "https://files.pythonhosted.org/packages/18/9a/b2f037b4982dce33645296e4394b031ade60f697f468761fa3ea8e2f8ece/mypy-2.4.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4e18d0da3898b3bcd16192f15a206e7b8b8dd0f4a0b3e51aa5bd5c2afe749e2c", size = 14467468, upload-time = "2026-10-28T19:22:10.629Z" }, + { url = "https://files.pythonhosted.org/packages/c4/5a/379f9bfa18bf3f8d43668fbd9ae4f2922dd027a559c461ca9d41cde1d32e/mypy-2.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b69a15fc2e75858d6b15e91ed3a0dcff1a533265183b64734138791fe0f49aa5", size = 15421496, upload-time = "2026-10-28T19:22:48.005Z" }, + { url = "https://files.pythonhosted.org/packages/83/50/3bde18a2824ec296432cebe01752ccd0ab8a2ad784abe4390040d019b3bf/mypy-2.4.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:70971cc0bcb1d3f03d2eb68fa430a6481ccc03558dc001d9534d7e5fa274c392", size = 15670425, upload-time = "2026-10-28T19:21:57.026Z" }, + { url = "https://files.pythonhosted.org/packages/6a/36/8b722b88c325d317354de7d10d8fb9d4dc0f958433e873a91fc4ed21a06e/mypy-2.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:6f7225951a277dd0d6add900731d487174b7d24ac133c09d670ed63b4d8cb90d", size = 11300972, upload-time = "2026-10-28T19:21:48.724Z" }, + { url = "https://files.pythonhosted.org/packages/c2/d6/fb2bab1245658d68af8abfe776362a780c621fe0f364f2c7b53039a945ee/mypy-2.4.1-cp311-cp311-win_arm64.whl", hash = "sha256:be4c03f33c55500191df2ed4a9b5e7edbdd1fff067fe361a5a9b1b5d3262da6e", size = 10873349, upload-time = "2026-10-28T19:21:32.104Z" }, + { url = "https://files.pythonhosted.org/packages/c0/1a/0be9dc6af5e0e04128f18a5e36b4ca44bfb0085857d37aa6a7de1ac2b0cb/mypy-2.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d63737426a048a27705a4eedb828669f4bc0873612a1b46b0b9fe892b2ebaaaf", size = 14381321, upload-time = "2026-10-28T19:21:54.223Z" }, + { url = "https://files.pythonhosted.org/packages/0d/a6/7907e36711a8a8c703f961f076fab61793383694140bd1fd87589f3f68d4/mypy-2.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7344869cad05f073b8cae2826774fa0161e3eb2f5c685b76813574008d77d750", size = 14466373, upload-time = "2026-10-28T19:22:25.211Z" }, + { url = "https://files.pythonhosted.org/packages/5d/b8/7313212b29de570c25c9859d7c8e4ef2251a6d34338a1e20031d94297721/mypy-2.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a20ff6cd2af7a670c64f089bfa5fbcebe8ff3bf896c5e6ac7c9862c7960e4494", size = 15553666, upload-time = "2026-10-28T19:22:36.511Z" }, + { url = "https://files.pythonhosted.org/packages/23/8f/92966b6082ff49da9142e1e527eb9af4359a9a61632a1cfc313da96b37fe/mypy-2.4.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9ed1195502cca32be5ef756b1693477f4991db2f2e34eaa90cc4ad6bea4f9531", size = 15802641, upload-time = "2026-10-28T19:21:13.421Z" }, + { url = "https://files.pythonhosted.org/packages/b6/b4/874f6fd54b005020ad63e2cf7a59b178d16a771d478849b29b842cb0cf14/mypy-2.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:4c194c5d878130fca1ae662dfb1feb6274afbab0b40032c80147377e0ea803d5", size = 11383067, upload-time = "2026-10-28T19:22:03.516Z" }, + { url = "https://files.pythonhosted.org/packages/b0/41/5ae8e6528c2faa96e4a921a999d2c7ac7c565bee184b4282bf62ffa76b5d/mypy-2.4.1-cp312-cp312-win_arm64.whl", hash = "sha256:71eda06e5bae51976ce869fda429159c9cec678bd02f25bb197f0265c8f991be", size = 10946882, upload-time = "2026-10-28T19:21:39.51Z" }, + { url = "https://files.pythonhosted.org/packages/6a/65/cd19bc06b67d2df4828220245fd98569ba40fac00c60ba48bef1817d8ac3/mypy-2.4.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3f1613bfe6726169a5680ec3dad5fe1f6d96285c12aded51ad432eadedd39d45", size = 14214179, upload-time = "2026-10-28T19:22:27.49Z" }, + { url = "https://files.pythonhosted.org/packages/c9/db/4d54ca4f49a0113d0c956980272aefdc6eec5458f7a72b350785b9ef2249/mypy-2.4.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:680ba5d9f0e3fe0c746b3d14df15f2a718e4bc308a1145616a1ea691ce7c354b", size = 14376217, upload-time = "2026-10-28T19:21:08.019Z" }, + { url = "https://files.pythonhosted.org/packages/a2/45/089b4724b85f0f408941be5298f817ee89181c1ce031a73d60ebb150c2c7/mypy-2.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fb70621535c22fd4b1a0450d37ed1d6c5eb39656a1cebfb189084c12de54ba7", size = 15467623, upload-time = "2026-10-28T19:21:21.555Z" }, + { url = "https://files.pythonhosted.org/packages/27/4c/15edbc64b0b1412bfe94c74192b3b56554ab642b85a31bb06cef6313101f/mypy-2.4.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4af5ad558033bf71a44a1be149ed61633522824f84c1b6bc2445d3fe2d2a5296", size = 15729867, upload-time = "2026-10-28T19:21:37.557Z" }, + { url = "https://files.pythonhosted.org/packages/76/5b/7d160fb685994b65b0ca86d352f3afb5424f96a9e6914719f7b861fb6701/mypy-2.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:acdd82cb3a2eb10720e87706a128d75785d005a8c47e36a4973221524f41fc56", size = 11390802, upload-time = "2026-10-28T19:22:18.081Z" }, + { url = "https://files.pythonhosted.org/packages/9a/ea/453d27f8d531f57c5f14aa73094eaa48e3fb77f680bdede2045cb64fa58b/mypy-2.4.1-cp313-cp313-win_arm64.whl", hash = "sha256:133886ef1a7a8cf673df55d865e41580c6c46aa9b8e31e1325dfe315c038f745", size = 10950427, upload-time = "2026-10-28T19:22:59.003Z" }, + { url = "https://files.pythonhosted.org/packages/7d/75/282d43d6fea7be984ac63e75ffd8eee146ba2f3b077bb1ca5bf3f973e0c4/mypy-2.4.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c45485061ba08f700acc12cfc8b177e6997e6bc353605babfc0abb081e079456", size = 14233251, upload-time = "2026-10-28T19:22:44.977Z" }, + { url = "https://files.pythonhosted.org/packages/ac/a8/9021263cc7e761451c7d8131bdfab3c0a5c2d67aa2d694670019e1ab86a7/mypy-2.4.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:727890a32f1858c09549eb55a8b234fe990d460450b28f03e8213ef925f1247c", size = 14394953, upload-time = "2026-10-28T19:21:29.492Z" }, + { url = "https://files.pythonhosted.org/packages/16/10/4192a5cea09ebbc41c534f57bd0d8f0fb42a8e810632cda6e37f072c59fd/mypy-2.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:beb254fec368c4e7f7f82a5f310c6470b893ec88a90b66426da971c6826b0453", size = 15442824, upload-time = "2026-10-28T19:22:42.068Z" }, + { url = "https://files.pythonhosted.org/packages/99/e6/d3b0a7474aa4f696594a47a218b6796d9c4346fc81ed288904278cddd9bd/mypy-2.4.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:ec416d5d2ae689e681f5727e328723f18d8b5dc8c903a146b7851dc5727aad8a", size = 15717227, upload-time = "2026-10-28T19:22:54.026Z" }, + { url = "https://files.pythonhosted.org/packages/48/6a/2ec530dacd4f77ca50d0fa05b854098f2d75e5d18c587d2612b44f10d68c/mypy-2.4.1-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:0e95ad0bec03ced9a73b42514208abd24c789e67f0e1eba476e276dd7a2dea3a", size = 7898637, upload-time = "2026-10-28T19:21:41.709Z" }, + { url = "https://files.pythonhosted.org/packages/cc/56/de9d7bad12e3868d5f1f4279aed20b1b568b2c5e166f2d3a05b211dca0b1/mypy-2.4.1-cp314-cp314-win_amd64.whl", hash = "sha256:51f742d4154824837ca6e92aa81f00eec222700a3c337bd258e5562a3880d75a", size = 11576656, upload-time = "2026-10-28T19:22:13.232Z" }, + { url = "https://files.pythonhosted.org/packages/b8/12/4fa9883b9b59e5c96ff62845ad019dc47786031c45d67eaccf452cffffd8/mypy-2.4.1-cp314-cp314-win_arm64.whl", hash = "sha256:f44dd4c5ab22df21206dd926c98381ebdbf5bfd696df37dd38ded2d23143fcb6", size = 11174403, upload-time = "2026-10-28T19:23:01.346Z" }, + { url = "https://files.pythonhosted.org/packages/3f/f2/827e356fc4f74c60b8da42663336e035b49d948a3c11224b0fc7543086b1/mypy-2.4.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:2875280687e64740e6ddcef43bd4c5852ad45ff34549740f6aea3f0373870b93", size = 15713427, upload-time = "2026-10-28T19:21:26.757Z" }, + { url = "https://files.pythonhosted.org/packages/a2/fa/e58a4fcae1d238189eac758036c0921992a86e3e6209190efd96d61fc5d4/mypy-2.4.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ea0714d2bccaf6d010c970e1d3ba2c9c2add79d2030aad2ef03167d788948276", size = 15938481, upload-time = "2026-10-28T19:22:34.371Z" }, + { url = "https://files.pythonhosted.org/packages/a1/54/a20f881801b88900923f2be1541a4b438ad0f0883e03836641fdc3d7adf4/mypy-2.4.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:63c6ff0e7ea546943001a91639c9f0c64b60d239268fa5d29e4a6c87f82c2373", size = 17243006, upload-time = "2026-10-28T19:22:39.425Z" }, + { url = "https://files.pythonhosted.org/packages/de/1c/ff84a6133a6e89c390bff6b25d9bad6598e7891b205f4b30b496906d636d/mypy-2.4.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:a5b5da107dc2c93fb0a22f7a45dbaea5dc131afc7056b5468d78e819f9a138e6", size = 17557728, upload-time = "2026-10-28T19:21:43.607Z" }, + { url = "https://files.pythonhosted.org/packages/15/4a/effa47d39b8fadf679c08e7c78559e523f9769a42a75662d2d15b2b9cdd6/mypy-2.4.1-cp314-cp314t-win_amd64.whl", hash = "sha256:c3a4d0c47053cc90035dd3a2c321112b593ad42935d0cbfd747288e1564fa8ca", size = 12370826, upload-time = "2026-10-28T19:22:29.779Z" }, + { url = "https://files.pythonhosted.org/packages/46/9f/b214ececb1a97fbb61ab3dfd48ae3cffd92ae2c148af4c9dc94c6c56772b/mypy-2.4.1-cp314-cp314t-win_arm64.whl", hash = "sha256:0c5bf267645351887b72903fd2f5fbddcf85234e0e6c4ad94e2fcfb4f0c3f971", size = 11851083, upload-time = "2026-10-28T19:23:11.288Z" }, + { url = "https://files.pythonhosted.org/packages/57/5b/e44a2edb0b25a9f1429de770e1d0238af23302671dd40c77ac5efeb0c559/mypy-2.4.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:db599d03e7d60d15f2e0a11665c18bc52a88699fcab990fdf8cecd5be8ac801c", size = 14243144, upload-time = "2026-10-28T19:21:10.975Z" }, + { url = "https://files.pythonhosted.org/packages/59/d4/5c99dc3a28e11d2f0fcbb02df63d2d3e574dedc0f9f69d50901df305a7a6/mypy-2.4.1-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c6c7210e40dd423af7d65cbe428b5906d11dc60659337bdae4e5fdf02ce32ed7", size = 14409316, upload-time = "2026-10-28T19:22:15.515Z" }, + { url = "https://files.pythonhosted.org/packages/c3/c9/3108b38f4c30eabd80194f5d9771a87e27196c5e0ddb5bf4b99c6ed1e97e/mypy-2.4.1-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a2d4a51db92059eecc2c33b2a5194b28585ebfd917292c015fe87a77dbff6cd2", size = 15445573, upload-time = "2026-10-28T19:22:05.635Z" }, + { url = "https://files.pythonhosted.org/packages/dd/12/84a53eceaf11c46dfd7931fb6b8902d01fb33787d3a991e81c461458150b/mypy-2.4.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:01b7718552d017f88d1151f3cc9d6556d778a90bd58060a2c3d87d070f9099fb", size = 15732989, upload-time = "2026-10-28T19:23:06.512Z" }, + { url = "https://files.pythonhosted.org/packages/65/ba/bf017dc2abdf83b2f74e29c43834b7af67dc1f1b20202f02dae60b4781a0/mypy-2.4.1-cp315-cp315-pyemscripten_2026_5_wasm32.whl", hash = "sha256:3467b1d13000812ab85dc2a3834b9379ec77798ca1bcabe434e23fb21fead692", size = 7898932, upload-time = "2026-10-28T19:21:59.366Z" }, + { url = "https://files.pythonhosted.org/packages/76/05/0c22b1f0390120a8592d31209cb6b9f932b6a0b426fe643e550de15139e3/mypy-2.4.1-cp315-cp315-win_amd64.whl", hash = "sha256:080cf64a60b90a73435542feecf4171904cc5710658165b40c6869115d4aa100", size = 11577577, upload-time = "2026-10-28T19:22:01.302Z" }, + { url = "https://files.pythonhosted.org/packages/73/fb/ac01e173629697ddac2f11e51efd10347d673f9a7311b03f4aba710ebccd/mypy-2.4.1-cp315-cp315-win_arm64.whl", hash = "sha256:f9118a3f50de264b614861bb11814833a742138ac3c8e2e49a860b6977fb2704", size = 11173540, upload-time = "2026-10-28T19:21:46.444Z" }, + { url = "https://files.pythonhosted.org/packages/5b/e4/b9b9c8eb09e70927ee65b1456cfed35710b6e4ff0b07f364ceaf2202307c/mypy-2.4.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:9d7dafd56179d296651df9e1844b91c9517c379398f017a2a435d077a28943c1", size = 15706623, upload-time = "2026-10-28T19:22:20.528Z" }, + { url = "https://files.pythonhosted.org/packages/26/74/1ceb1ca884add0565e618d013dd24333039100dc0fcc42661561f2e1cae5/mypy-2.4.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d923cec43316f0e6736b8298fd00abeaaf348a091c20e7296b3aebceecb63eca", size = 15944095, upload-time = "2026-10-28T19:21:04.779Z" }, + { url = "https://files.pythonhosted.org/packages/2b/68/27bcf9b4efa22733b6050485ae37845b94c9b8851abe4fc60632d905c32d/mypy-2.4.1-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d6e081b466e88d4343adffe11aff0f02df34b5b9070b4b700053a0b7294c0be1", size = 17223065, upload-time = "2026-10-28T19:23:03.724Z" }, + { url = "https://files.pythonhosted.org/packages/1a/a3/ed5724b317bf585c29f3c8be2792e97d45925d65a9c8af40ceeb267072e6/mypy-2.4.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:70196470ac300f444a302a738541101893c2c57804078b33690286a7899149e9", size = 17560589, upload-time = "2026-10-28T19:21:34.539Z" }, + { url = "https://files.pythonhosted.org/packages/42/2f/005185e6ab4752fd6cc2d1a6d1421fe21979770afe2490c00c555f34a913/mypy-2.4.1-cp315-cp315t-win_amd64.whl", hash = "sha256:de95648e0a6d46fa9929b956ed2c87c5dc9933d4d59945e6390e9d753c74e7c1", size = 12353324, upload-time = "2026-10-28T19:22:51.481Z" }, + { url = "https://files.pythonhosted.org/packages/a1/d6/20420cc9c780087139662534d128c2f3274361f8bb7e9cf0d5495a846ed5/mypy-2.4.1-cp315-cp315t-win_arm64.whl", hash = "sha256:ef8d5be90032261197ac388d945d8ff4f476c95880798a1911760af64ddfe71f", size = 11845599, upload-time = "2026-10-28T19:22:23.136Z" }, + { url = "https://files.pythonhosted.org/packages/21/5c/6e8010f8f2c4ad817364592d4b3883633417269b913fc9d5174fdeb7e565/mypy-2.4.1-py3-none-any.whl", hash = "sha256:1784648d6ec8c2b5465e3f26241b845a0b3cb4e56c993c64abe16989e7698999", size = 2801286, upload-time = "2026-10-28T19:21:19.516Z" }, +] + +[[package]] +name = "mypy-extensions" +version = "1.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d0/6f/43edf3be2748d0e40974a5ee046a8bb4c9961a4bdd3e7d5c6dcbf32d1af6/mypy_extensions-1.2.0.tar.gz", hash = "sha256:c6e275a07f1c2fc096b62940452d0eaa3f3af7de45d704787866240a7c6d5a51", size = 6566, upload-time = "2026-11-03T16:26:33.692Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b5/99/7b1adac7e97ce7bbda34792dc6e9b2f5cc5cffd1875883f78a818b2a2687/mypy_extensions-1.2.0-py3-none-any.whl", hash = "sha256:993e7a20aa5671eb41a7132cf555af30062da99729601601b9a8382b11cae768", size = 5114, upload-time = "2026-11-03T16:26:32.731Z" }, +] + +[[package]] +name = "nest-asyncio2" +version = "1.7.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/32/2c/70e3b6bb2189cfd260280b7e1042bd622949a258663f95e887fada4ac1e6/nest_asyncio2-1.7.4.tar.gz", hash = "sha256:995b1409d926ec55e0876ea39a69bffdd8852cf1db3652c177e8c8ffdbcaf3cc", size = 16891, upload-time = "2026-10-07T22:31:50.507Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/09/ed/559d2915dce85794bc0c36064043da170da50cd98746dcbddd85d5932017/nest_asyncio2-1.7.4-py3-none-any.whl", hash = "sha256:86e77b52c3d1496b294af3c944b44213b9b82a12a5ee590c0acc4ca4692ef6c7", size = 8543, upload-time = "2026-10-07T22:31:49.245Z" }, +] + +[[package]] +name = "numpy" +version = "2.4.6" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.12'", +] +sdist = { url = "https://files.pythonhosted.org/packages/d0/ad/fed0499ce6a338d2a03ebae59cd15093910c8875328855781952abf6c2fe/numpy-2.4.6.tar.gz", hash = "sha256:f3a3570c4a2a16746ac2c31a7c7c7b0c186b95ce902e33db6f28094ed7387dda", size = 20735807, upload-time = "2026-05-18T23:37:14.07Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b3/49/ec46835a70be8fa6446c495126ac84fdb28cb2558e1620ffb87a10c8b64c/numpy-2.4.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0280e0356c0829a18d9de1cb7eee50ec22ca639878d7240307ca0943d73cd2c4", size = 16969194, upload-time = "2026-05-18T23:33:13.503Z" }, + { url = "https://files.pythonhosted.org/packages/0e/0d/f5957185c0ee2f3e12f78715aa9e3b353fd83633316c8532b38faa37e3f6/numpy-2.4.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:110f8b71aacb688ec69062bb7f6938a0f8acb01b7c1c4beb453c65b6d234584d", size = 14964111, upload-time = "2026-05-18T23:33:17.795Z" }, + { url = "https://files.pythonhosted.org/packages/ad/40/40a40ee0ddf7ceb782c49af278894b686e586d65d8c1889c8b5da01a3d7d/numpy-2.4.6-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:4cfe66903cc32a9921a6733d96b19bb6abf310397581bbad89c228f5abaf0ee8", size = 5469159, upload-time = "2026-05-18T23:33:20.654Z" }, + { url = "https://files.pythonhosted.org/packages/63/13/f9a8046535cb21deae82f8d03de9617e08882d274fad2539630761888228/numpy-2.4.6-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:8155154c7c691289fe18f510b5d4657c68c67989f293f0535a91360392ff6538", size = 6798936, upload-time = "2026-05-18T23:33:22.987Z" }, + { url = "https://files.pythonhosted.org/packages/33/a8/6fa8c1a345a8c85dbb21932c447bee07c30a2c2a3f31e369c0a84b300147/numpy-2.4.6-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0ab0a9c4ffb1a6d95ef519fe4247dba8eb6b18ad93999f76b7f657039acabd47", size = 15966692, upload-time = "2026-05-18T23:33:26.62Z" }, + { url = "https://files.pythonhosted.org/packages/02/03/74fe2a4cb3817d94d86402f2506554130a2f01414e299b5a843e5a8a957f/numpy-2.4.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:89cd468399cfd2504718f0ba50e410dca55a170b61a02ad92bb18c8a65186e93", size = 16918164, upload-time = "2026-05-18T23:33:29.955Z" }, + { url = "https://files.pythonhosted.org/packages/c5/80/3615be3313f7e7696609bc194b9f0101da809df79e859bdb84e0cd043f46/numpy-2.4.6-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:c2d37ab77531417474168eb79d6d80b14f821a966818505d03013d0833edb7a8", size = 17322877, upload-time = "2026-05-18T23:33:34.724Z" }, + { url = "https://files.pythonhosted.org/packages/ca/ac/a691e0fe2675e370d0e08ff905adc49a1c8830e8cae03efe4477e92cd55d/numpy-2.4.6-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f407cb6b8e9d6d8c626bc73c945db1706035af8fd632295547bf1c9e46d092d6", size = 18651487, upload-time = "2026-05-18T23:33:38.217Z" }, + { url = "https://files.pythonhosted.org/packages/15/a7/9bc1cd626d7bf6869bfedf27b91b6ab5dd607758bf8e959d6fa80c6a59cb/numpy-2.4.6-cp311-cp311-win32.whl", hash = "sha256:ddea102b48f9e339f3948bf22040944184627a30fdf7f858667673b9c5f033c8", size = 6233945, upload-time = "2026-05-18T23:33:41.331Z" }, + { url = "https://files.pythonhosted.org/packages/c5/31/7fc6239c12bce7e931463251cca4426c465e1876ba3cc785402ef4dd8f4e/numpy-2.4.6-cp311-cp311-win_amd64.whl", hash = "sha256:1e254a00cdf42b1e4d5b3d68d33af63268d41340d8885df2ab6470f2e1500147", size = 12608406, upload-time = "2026-05-18T23:33:44.131Z" }, + { url = "https://files.pythonhosted.org/packages/27/83/140f85a466595a16382996a1bf06b2b54bcd597488921b0c9daaeeda72af/numpy-2.4.6-cp311-cp311-win_arm64.whl", hash = "sha256:ed9749eef4cbd126da3dc1d6bcb3a57f5eb7ac6a6484146bdbf743f552dfc577", size = 10479528, upload-time = "2026-05-18T23:33:50.725Z" }, + { url = "https://files.pythonhosted.org/packages/95/2a/3d7b5ac8aac24feaf9ad7ed58f45b0bbc06d37e4338ae84c9f2298b570f9/numpy-2.4.6-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:001fbb8e08d942dd57599e781f2472269ee7f2755fae407b4f67b2f0b17da3f1", size = 16689119, upload-time = "2026-05-18T23:33:54.065Z" }, + { url = "https://files.pythonhosted.org/packages/ea/12/92c4c131527599e8288d6918e888d88726f84d805d784b771f32408aeaef/numpy-2.4.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ebfb099f8dcf083deef3ac1ca4c1503f387cf76296fcb3816b66f5ecb5f54fdb", size = 14699246, upload-time = "2026-05-18T23:33:57.621Z" }, + { url = "https://files.pythonhosted.org/packages/ad/fe/c0a6b7b2ca128a8fb228575147073b660656734b8ebe4d76c8fd748dcc79/numpy-2.4.6-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:3213d622a0283a39a93d188f3cf72b26862df52fbb4ca3697f51705016523d41", size = 5204410, upload-time = "2026-05-18T23:34:00.302Z" }, + { url = "https://files.pythonhosted.org/packages/f3/d4/9770d14ba719432bb90a421bfd443872ed0f70f7264b64bec12ea363d5fd/numpy-2.4.6-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:357cc07a6d7b0b182ff02249616a03742827ebb1277546b5c7cd7f7620a45698", size = 6551240, upload-time = "2026-05-18T23:34:02.852Z" }, + { url = "https://files.pythonhosted.org/packages/c9/c6/50a46a6205feba2343f1d6d17438107c5dc491ed1c736e6ea68689fd906b/numpy-2.4.6-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5f9fb9157b4ce2971008323afe46053787b526ef624fea915b261468a8421a0f", size = 15671012, upload-time = "2026-05-18T23:34:05.485Z" }, + { url = "https://files.pythonhosted.org/packages/99/60/14115e6364fa676c5397c2ad3004e527e9aa487abf5d0706ec81bbd08529/numpy-2.4.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:90f9849678c75fe7afa2d348ac842c168b0a4d3d61919687216dfc547976d853", size = 16645538, upload-time = "2026-05-18T23:34:09.265Z" }, + { url = "https://files.pythonhosted.org/packages/ae/c5/693cbe59e57db94d2231fa519ca3978dc9e19da5a8f088588f5c6e947ff2/numpy-2.4.6-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:c1a2af6c6ef86344a6b0db6b97834208bf598db514f2b155042439b62605601a", size = 17020706, upload-time = "2026-05-18T23:34:13.053Z" }, + { url = "https://files.pythonhosted.org/packages/ef/fc/85b7c4eff9b4966ade25c2273cf7e7012e92366c032058653934b37de044/numpy-2.4.6-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e5805d5a22fd19c8ccff10a9561f9df94436b0545619ea579db2d3c35294bce2", size = 18368541, upload-time = "2026-05-18T23:34:17.024Z" }, + { url = "https://files.pythonhosted.org/packages/f6/81/e1b27545deedce7f4a0b348618c6b62d74e36a4dc9ccd42f3eb2f85eee32/numpy-2.4.6-cp312-cp312-win32.whl", hash = "sha256:e3eeb0aabd6bd5ce64faae67e9935203a6991b4bc2a485a767fbafb2c5125f45", size = 5962825, upload-time = "2026-05-18T23:34:20.3Z" }, + { url = "https://files.pythonhosted.org/packages/ab/ca/feab00bd44aa5fe1ad2c18f08b4d3bb92e26484b0b1d1443897809ed528c/numpy-2.4.6-cp312-cp312-win_amd64.whl", hash = "sha256:d8e8286dd7cea7895157318d1b91cdacac64c479f3cbc8dce548331728484751", size = 12321687, upload-time = "2026-05-18T23:34:23.095Z" }, + { url = "https://files.pythonhosted.org/packages/63/cf/5a6d34850a39d1093558564f77ee8e8e0bee5061151b8f05a55711001ec7/numpy-2.4.6-cp312-cp312-win_arm64.whl", hash = "sha256:4081eb135ac24158bd51cdfbef16f1c64df7063b1143f24731387137c092bec8", size = 10221482, upload-time = "2026-05-18T23:34:25.876Z" }, + { url = "https://files.pythonhosted.org/packages/fb/82/bdab26d7438c6791ca31b7c024ca37c1eab8b726ba236129005cd4a06e45/numpy-2.4.6-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:511dbaf848decaaaf4b4ca48032619fb3138710c4bf7da7617765edad1ef96b0", size = 16684648, upload-time = "2026-05-18T23:34:29.41Z" }, + { url = "https://files.pythonhosted.org/packages/1b/30/a80189bcc7f5e4258b3fbc3968d909d1756f54d023299ecc39ad6fdb9ef8/numpy-2.4.6-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:bf162abab1c1a736333192707cef898e735a5ca00f38f27eeedf44b39d9e85eb", size = 14693902, upload-time = "2026-05-18T23:34:33.013Z" }, + { url = "https://files.pythonhosted.org/packages/97/12/70b5d0d7c15e1ebb8a6a84a8caa1d19e181d84fb58bb6d70aca29099dec1/numpy-2.4.6-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:043191bfa8eab18c776647b62723ac9dddece59743b13f49b2016094129c2b3f", size = 5198992, upload-time = "2026-05-18T23:34:36.132Z" }, + { url = "https://files.pythonhosted.org/packages/ba/8c/ebd2a8f8a83541f8d38cc5667e8c2b69cecfd30da6e45693e8158857d44b/numpy-2.4.6-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:6180d8b35af935aed8ece3a85e0a43f87393ae0ac87c8d2c8bd2c993f7270ef3", size = 6546944, upload-time = "2026-05-18T23:34:38.484Z" }, + { url = "https://files.pythonhosted.org/packages/bb/c5/7b863a97a91671a0338f4253bd3b5a3d3852f0692dae91711c9f4a10e787/numpy-2.4.6-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:72fbe16c6fac95aedf5937fa873445cec2110be35d8a4e9433d7501fd98dae6b", size = 15669392, upload-time = "2026-05-18T23:34:41.257Z" }, + { url = "https://files.pythonhosted.org/packages/a5/9d/3584b9984ca4c047aea75214ce1a4c4c73d849bd71b604264b7f5653f8a8/numpy-2.4.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a7830bab239b79cda9c08c2da014761cafb48da6150e1da17ac06283f43b6089", size = 16633220, upload-time = "2026-05-18T23:34:45.075Z" }, + { url = "https://files.pythonhosted.org/packages/05/ae/7c67fba23bd98caec7c99261f3a16072ade14813486b0282cb29846de832/numpy-2.4.6-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ef4aea96ce4d3b074422cb4f2f64e216bf9e213004bb58ecfdf50ea02ea8eb9a", size = 17020800, upload-time = "2026-05-18T23:34:49.065Z" }, + { url = "https://files.pythonhosted.org/packages/d9/5d/3b6725cb31d983c5e66916f5d36f6d7e5521129e4c4404d64f918292a5b6/numpy-2.4.6-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:dfa20cc6ca228e6b155b11da03825975ce66aea520985dbbddf0f2a5a495c605", size = 18357600, upload-time = "2026-05-18T23:34:52.709Z" }, + { url = "https://files.pythonhosted.org/packages/f7/da/2ccc6c2fe8898dee01d90c75c5f5f914a23daf99e3e0f59516a08760c8b5/numpy-2.4.6-cp313-cp313-win32.whl", hash = "sha256:56b39e5e0622a09a25bf5baf62f4bcf0cb8a41ae6e2819cf49bbc5a74c083f91", size = 5961134, upload-time = "2026-05-18T23:34:55.618Z" }, + { url = "https://files.pythonhosted.org/packages/b5/cd/9cc4dc876fb065d5c220aae4d5e14826b2715331bb7618ce1fb07a679d99/numpy-2.4.6-cp313-cp313-win_amd64.whl", hash = "sha256:c4fc99836233ea196540b17ab0983aff60ed07941751930f5f4d05bc3b3b7359", size = 12318598, upload-time = "2026-05-18T23:34:58.928Z" }, + { url = "https://files.pythonhosted.org/packages/39/1e/c0bcba1f8694116485fe28fd1be698c278fcda4141c5b0e53a2aed8b12a8/numpy-2.4.6-cp313-cp313-win_arm64.whl", hash = "sha256:a7c711e21628b52034bb5ab8d1bce291f752fcc5e92accc615778acee1ff4778", size = 10222272, upload-time = "2026-05-18T23:35:02.167Z" }, + { url = "https://files.pythonhosted.org/packages/63/6d/cc5619247c8f4204e507f5883528372e4ac4bb189e579fb859a12e480b1f/numpy-2.4.6-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:112b06a867b235ef466ed3508ddf0238050df9c727cafb5301ac385b899189a1", size = 14821197, upload-time = "2026-05-18T23:35:05.468Z" }, + { url = "https://files.pythonhosted.org/packages/00/58/f1c39161c87d9e9bed660f1ed4bafc0e403d5ec9650b6dd77aead07d489b/numpy-2.4.6-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:eaf7fa2de5c0be8ae6ff8e9bea2ccd725e980541244521d8d4b5f3354a27babe", size = 5326287, upload-time = "2026-05-18T23:35:08.693Z" }, + { url = "https://files.pythonhosted.org/packages/af/57/3917ab0fd97f271a8694513581b8a36c655f111c446852c302f04ccdb6fc/numpy-2.4.6-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:7265a2f3d436e54ef9f2b52b5c937e6be778781bd97a590319d7348f1c1ca997", size = 6646763, upload-time = "2026-05-18T23:35:11.459Z" }, + { url = "https://files.pythonhosted.org/packages/eb/0f/037e64c494b67581ae18193d770adef354c41f3f2c8ebf865602d949bf8f/numpy-2.4.6-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f74a575920ab21fe304421a3fc28793d82e299cae9eccb37084e9fc7f3617c20", size = 15728070, upload-time = "2026-05-18T23:35:14.79Z" }, + { url = "https://files.pythonhosted.org/packages/21/a6/5d2bae9c9542eb4df16dc9c46dc79c186e9bad53805dfa5399a6023c6db0/numpy-2.4.6-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ede83e07a75dd06bc501566c1eca2afc0d61677c1472ac9ad93fdee6e638a48d", size = 16681752, upload-time = "2026-05-18T23:35:18.836Z" }, + { url = "https://files.pythonhosted.org/packages/92/14/23d1dfb410ae362cd59ce53e936b1513d545eb40db3949ced632e19a459e/numpy-2.4.6-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:68bb27509ac1b9a3443094260f6326150663b06abe40b73a2f81160623da5b67", size = 17086024, upload-time = "2026-05-18T23:35:22.52Z" }, + { url = "https://files.pythonhosted.org/packages/4b/6e/23595a2c642cdf3bc567877064bdd7f91c8b0038a4453cf2daf7248eafe9/numpy-2.4.6-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:a0df0043bdb289bde1f62da130d20df23d58b45429f752bc7a8fc5325a225ecd", size = 18403398, upload-time = "2026-05-18T23:35:26.398Z" }, + { url = "https://files.pythonhosted.org/packages/8a/90/0ac3bc947217e66dec77e7cbc6a1979d1af70b6461b82f620d3bccd5e4c8/numpy-2.4.6-cp313-cp313t-win32.whl", hash = "sha256:29a287e0cf63ff528da061de6b9f64a4618da591ca1046aafc54062e40ca7eab", size = 6084971, upload-time = "2026-05-18T23:35:29.387Z" }, + { url = "https://files.pythonhosted.org/packages/77/71/5673e351671a1d2bd6063b91b44f70c0affea7d1516fa7a6572941ba4aa1/numpy-2.4.6-cp313-cp313t-win_amd64.whl", hash = "sha256:25c692919ac5a01f170a3bfcd62d745b24fd095c353d50812637d6fcab442e75", size = 12458532, upload-time = "2026-05-18T23:35:32.175Z" }, + { url = "https://files.pythonhosted.org/packages/3f/88/19d3503c5046e688f049274b27a3ef3d771152fa80d3ba3d01a3dff61abe/numpy-2.4.6-cp313-cp313t-win_arm64.whl", hash = "sha256:1e978ec1e8bd0e0e4de6bb75de9d30cbb74db6b6a2bb727618613703ca0167dd", size = 10291881, upload-time = "2026-05-18T23:35:35.465Z" }, + { url = "https://files.pythonhosted.org/packages/f8/91/3ab2044d05fd16d343c5ac2e69b127f1b2854040dd20b193257c78028bd3/numpy-2.4.6-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:06ca2f61ec4385a07a6977c55ba998a4466c123642b4a32694d3128fce18c079", size = 16683458, upload-time = "2026-05-18T23:35:38.353Z" }, + { url = "https://files.pythonhosted.org/packages/8e/62/764ce66fa4147ae6d73071a3abf804ffe606f174618697c571acdf26a7c9/numpy-2.4.6-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:38efbc8de75c7a0fc1ac190162d892787f3f47b57cc291231aafee36b80982b7", size = 14704559, upload-time = "2026-05-18T23:35:42.14Z" }, + { url = "https://files.pythonhosted.org/packages/60/61/23f27c172f022e04025b7dc2367f4d63c1a398120607ec896228649a6f48/numpy-2.4.6-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:d581b735e177fdcdce6fed8e7e8880a3fb6ee4e3653a3ac6af01c6f4c03effc5", size = 5209716, upload-time = "2026-05-18T23:35:45.377Z" }, + { url = "https://files.pythonhosted.org/packages/03/71/21cf70dc6ea3e3acb95fc53a265b2fc248b981f0194ceb5b475271b8809d/numpy-2.4.6-cp314-cp314-macosx_14_0_x86_64.whl", hash = "sha256:0a041d3d761dc3c35cc56ce0351506a02bcbc25f7b169f652435141a17db9096", size = 6543947, upload-time = "2026-05-18T23:35:47.926Z" }, + { url = "https://files.pythonhosted.org/packages/d5/91/64288395ee1799bd2e0b04a305dce9666da90c961e1f3fe982a05ee1c036/numpy-2.4.6-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:40fdc1ae7125e518ea98e53e69a4ebc27e1fd50510c47b7ea130cf21e5e1d42b", size = 15685197, upload-time = "2026-05-18T23:35:50.863Z" }, + { url = "https://files.pythonhosted.org/packages/f3/eb/ebffaa97dc55502df69584a8f0dcf07f69a3e0b3e2323670a2722db9aa39/numpy-2.4.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a2c306dea656c12c68f51f4cea133cbe78ca7435eb28c735eac1d3ebe73be6e8", size = 16638245, upload-time = "2026-05-18T23:35:54.752Z" }, + { url = "https://files.pythonhosted.org/packages/b8/0b/54f9da33128d7e350fab89c7455902eeae70349ee52bddb448dc4a576f45/numpy-2.4.6-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:33111801a01c12a8a1e3721f0a9232f8cfc8ae2c6b7098167e6f623c6073f402", size = 17036587, upload-time = "2026-05-18T23:35:58.355Z" }, + { url = "https://files.pythonhosted.org/packages/b6/f0/fdebc1052db1cc37c64beb22072d67cd6d1c71adca1299f53dec2b5e20d3/numpy-2.4.6-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:ae506e6902902557576a26ff33eda8695e7ecb3cb36c3b573a0765dee114ebdb", size = 18363226, upload-time = "2026-05-18T23:36:02.845Z" }, + { url = "https://files.pythonhosted.org/packages/aa/b4/298628d98c72b57e57f7165ae6a481a1deaf6f3c28262a6e4c739c275930/numpy-2.4.6-cp314-cp314-win32.whl", hash = "sha256:aaf159caa35993cb1f56fb9b8e4610d35758e7ca005412eb1daa856a78c9c4b1", size = 6010196, upload-time = "2026-05-18T23:36:05.92Z" }, + { url = "https://files.pythonhosted.org/packages/df/ac/46de6dda46478f7942f839e094970be2d4a861e005c4b3bf07c92e291a09/numpy-2.4.6-cp314-cp314-win_amd64.whl", hash = "sha256:b507f5c4c1d508876d1819b6bf9a49d365b96320b5d4993426b33a23ca4b8261", size = 12450334, upload-time = "2026-05-18T23:36:09.107Z" }, + { url = "https://files.pythonhosted.org/packages/78/92/b8b798ac784102c0da830d2257d59358e3d3d90d1e2b3f2575dad976c5cf/numpy-2.4.6-cp314-cp314-win_arm64.whl", hash = "sha256:6f41ae150c4e32db4f3310cdaf64b1593a03dbabe29eec77fc9b50fe64061df6", size = 10495678, upload-time = "2026-05-18T23:36:12.766Z" }, + { url = "https://files.pythonhosted.org/packages/30/34/ec28d1aa8115971537c01469ab2011ee96827930f0a124de1000cc2a7ed7/numpy-2.4.6-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:ece3d2cfe132e7d51f44a832b303895e6f2d499c5e74dfbdb06ee246147a304a", size = 14823672, upload-time = "2026-05-18T23:36:16.473Z" }, + { url = "https://files.pythonhosted.org/packages/16/bd/f6d1fede4e54e8042a7ff97bb495510f3c220f94bcd9e8b228e87c92cc0d/numpy-2.4.6-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:e3e5193ef5a3dc73bceee50f7fdc2c90dbb76c42df8d8fae3d1067a583df579e", size = 5328731, upload-time = "2026-05-18T23:36:19.767Z" }, + { url = "https://files.pythonhosted.org/packages/f4/f0/e105b9e2fd728a9910103884decd6951d9dd73896b914a98d9a231de02ee/numpy-2.4.6-cp314-cp314t-macosx_14_0_x86_64.whl", hash = "sha256:17f9ade344e7d9b464a084d69bcf18fc691cb1db67c62ed80820bf4926d78f0e", size = 6649805, upload-time = "2026-05-18T23:36:22.266Z" }, + { url = "https://files.pythonhosted.org/packages/82/dd/1206a7ca6ab15e3f02069707ca96222e202af681bb73756da7527f3cb837/numpy-2.4.6-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9cd5ffd25db4e7ba6a375693b3fc0fc1791ec636c17db3720da19bde7180ec43", size = 15730496, upload-time = "2026-05-18T23:36:25.713Z" }, + { url = "https://files.pythonhosted.org/packages/51/e7/38d3ea825dcab85a591734decb2f6c67caa7c8367d374df1a1c3842f9b07/numpy-2.4.6-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7d92c3819208a60205a12a245c91ad70cb0a85336659b19b834205573ac8456e", size = 16679616, upload-time = "2026-05-18T23:36:29.652Z" }, + { url = "https://files.pythonhosted.org/packages/93/b7/caabfdf53edf663e0b4eb74d7d405d83baef09eb5e83bcd32d601d72b93e/numpy-2.4.6-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:e85b752a1e912b70eaad4fafbd4d1238007ab221de2009b9a2f5ae7461239895", size = 17085145, upload-time = "2026-05-18T23:36:33.449Z" }, + { url = "https://files.pythonhosted.org/packages/f9/45/68d7c33a6bcf3e5aa3bdbd57a367e6f615286dfd6482f97e8ffeb734306e/numpy-2.4.6-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:29cb7f67d10b479ff07c17d33e39f78c07f71c40ef30d63c153d340e96cd3fb4", size = 18403813, upload-time = "2026-05-18T23:36:37.369Z" }, + { url = "https://files.pythonhosted.org/packages/9c/50/0753655aa844c99cd9e018aacf76f130f1bd81d881bb74bc0aef5d73a8ba/numpy-2.4.6-cp314-cp314t-win32.whl", hash = "sha256:260a5d70215b61ab4fadf5c7baacd64821842975eea312125ed3c39a6391b063", size = 6156982, upload-time = "2026-05-18T23:36:40.817Z" }, + { url = "https://files.pythonhosted.org/packages/b2/d4/7c67becf668f973cb490cec3e98dfd799d866f9c989a54d355672cfa0db6/numpy-2.4.6-cp314-cp314t-win_amd64.whl", hash = "sha256:81a1cca95ed5bb92aa8b10dd2cdc9a0d3853a50fad926c28b5d7e8ea54389627", size = 12638908, upload-time = "2026-05-18T23:36:43.996Z" }, + { url = "https://files.pythonhosted.org/packages/43/bb/e1c71a4295b1b1d1393d50dbb4f2a36283c6859d9d3892e84f00ec5a91d5/numpy-2.4.6-cp314-cp314t-win_arm64.whl", hash = "sha256:0c9136e14ed34a9e343a31c533d78a9813a69a3148332bce5e9821cb2f996e66", size = 10565867, upload-time = "2026-05-18T23:36:47.114Z" }, + { url = "https://files.pythonhosted.org/packages/de/12/b422cc84439adc0d00de605bf4a308890ae5c26f2c71fbd73e5d08fbb0dd/numpy-2.4.6-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:55cced7c52e981362f708ad635198e97a752dfba412cc03c23bbf3bd8d5cd662", size = 16847511, upload-time = "2026-05-18T23:36:50.673Z" }, + { url = "https://files.pythonhosted.org/packages/44/53/f481bef68011740f8849418d82db07230e825013f31f4eef5ba5b805316a/numpy-2.4.6-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:d6da64deb6b8ed903e7560180a92f2d804ee1ba5eeb849ac2748b8c1aba1f6d7", size = 14889064, upload-time = "2026-05-18T23:36:53.879Z" }, + { url = "https://files.pythonhosted.org/packages/7f/57/42ed575c10ced8af951d426bc4e1f8aff16fd851db33f067036215a7f860/numpy-2.4.6-pp311-pypy311_pp73-macosx_14_0_arm64.whl", hash = "sha256:68a5124b13fa6cc2086764a20005d30bc0548146f7f5322f02fce212ca14317f", size = 5394157, upload-time = "2026-05-18T23:36:57.194Z" }, + { url = "https://files.pythonhosted.org/packages/6a/ef/f66cc724fcc36c1e364c67f51ae9146090b8b584f27d58b97fdae3edd737/numpy-2.4.6-pp311-pypy311_pp73-macosx_14_0_x86_64.whl", hash = "sha256:948424b06129ce883307e8cff868c31396d8dc7630a59c61d70d98dbe70f222c", size = 6708728, upload-time = "2026-05-18T23:36:59.575Z" }, + { url = "https://files.pythonhosted.org/packages/1a/9c/c531f2293b91265d8b48e9b329f54fdd7ffae73cb4134ea10cca4237e9cc/numpy-2.4.6-pp311-pypy311_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5dbbdb29840ca3d91ee0fece42fc29278886d908280bfec0a5846c6f901a3eb0", size = 15798374, upload-time = "2026-05-18T23:37:02.674Z" }, + { url = "https://files.pythonhosted.org/packages/1a/b0/413077f6b1153ed3cba361401c6783bbad6114804a000cc22eb71c13e190/numpy-2.4.6-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8ad03c0965fb3c692200e74d458ca28c1dbb4ce96f9a479a8aa041ad5fabca02", size = 16747286, upload-time = "2026-05-18T23:37:06.327Z" }, + { url = "https://files.pythonhosted.org/packages/15/ce/e5ec180bc41812edcd8daeb8639d205622c0e8c02259d8ab25a0201b3c2a/numpy-2.4.6-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:2803abfebfc990042cd494d8ce2d5f82e9d847af6d35ec486923aa19dbad5e73", size = 12504263, upload-time = "2026-05-18T23:37:09.715Z" }, +] + +[[package]] +name = "numpy" +version = "2.5.4" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.15'", + "python_full_version == '3.14.*'", + "python_full_version >= '3.12' and python_full_version < '3.14'", +] +sdist = { url = "https://files.pythonhosted.org/packages/95/b0/c7453d0b6e2073c3264468b106ee1563750cecc910965e67357e3698c83e/numpy-2.5.4.tar.gz", hash = "sha256:9a94cf751c9ad8ebaa835bcd3d40dacf8534ad086b88c38029b65123c7999d2a", size = 20866315, upload-time = "2026-10-10T20:05:31.422Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d0/97/ba2074e92b7befea137e77ea8471e768bbd87c339b7e8c9f5a931949f977/numpy-2.5.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c6342f54c67093cae5c0227eb0eb772fdb79f2a2c37a6eb278b9909ee06aa356", size = 17001609, upload-time = "2026-10-10T20:02:40.843Z" }, + { url = "https://files.pythonhosted.org/packages/ff/a9/bac826765e971d8e16e2064e9ac7525fd69b40ac17c905033a7f5442023f/numpy-2.5.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b11e8fda06a7d69f15ebf542660b74466c2e51094800c1fb794f47ad4faeef17", size = 12015718, upload-time = "2026-10-10T20:02:43.45Z" }, + { url = "https://files.pythonhosted.org/packages/31/2f/5ea3570fcb8ccd0882bea99436a513b2c85dad8f774a2057849130a8fb99/numpy-2.5.4-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:9cb18a327b49c5c337f972b03682f6a49855525faaf3c0d3e9c96cd0fd8880a8", size = 5451717, upload-time = "2026-10-10T20:02:46.169Z" }, + { url = "https://files.pythonhosted.org/packages/34/f2/b4fc1bafca03868220b5eaf729d2f21ebd7d7b151c0f9e144fe212bbca35/numpy-2.5.4-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:aec3fc4b32ff82421274f5d205c559c51c840c8df66a78efd7f3612dd005a26a", size = 6789926, upload-time = "2026-10-10T20:02:48.139Z" }, + { url = "https://files.pythonhosted.org/packages/dc/96/8319e2457ae4333c62c815c7006b869a4f60985c1e01024c2f8c6c040fe5/numpy-2.5.4-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fe4d21ab149f15e4e6043dfb0de87e6e5f34ac176cde83060e9802981fca2ac2", size = 15695312, upload-time = "2026-10-10T20:02:50.115Z" }, + { url = "https://files.pythonhosted.org/packages/43/a3/c799c62e19c337e6d3770b08e475887fb30ce8477d3c09efca6b2f0228a6/numpy-2.5.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fbde6962867ee75b48b0ee29b2b9372ec5d617799dbaf38e82dc0596f2f7738a", size = 16727283, upload-time = "2026-10-10T20:02:53.186Z" }, + { url = "https://files.pythonhosted.org/packages/39/6b/3604e53fb00314d0dc1b94ec9125a1484f649c0a17480b1f0f0c7a9d6250/numpy-2.5.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:381a7a3d2e65e64c0ec302795ab9dc12bb1e73f150904699c153716177eebdaf", size = 17047890, upload-time = "2026-10-10T20:02:56.038Z" }, + { url = "https://files.pythonhosted.org/packages/4a/7a/e8b58a5289a0d464c52885de47c35a935cdd70c03a4c3ab94a5126416dd0/numpy-2.5.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b89d0aaae2fe498c648f4c4795c084db535af5bd98ef942b2a3681fb74ce8645", size = 18485839, upload-time = "2026-10-10T20:02:59.018Z" }, + { url = "https://files.pythonhosted.org/packages/6f/c9/47094f597015009f310b8c900def59065ef1ff5a6fe7b51fc65ec58ec2c6/numpy-2.5.4-cp312-cp312-win32.whl", hash = "sha256:9968ab7e49b93ac6e1c3b2239732183152c9150f16308d30b66a372cffe3483c", size = 6138936, upload-time = "2026-10-10T20:03:01.626Z" }, + { url = "https://files.pythonhosted.org/packages/12/33/fefe62073dc8acfd0f2b9ed7c003af2f50aa61555e113e6db02b8f79f145/numpy-2.5.4-cp312-cp312-win_amd64.whl", hash = "sha256:a7b1b6353e36a7e50de2973a38d705c88ee93adcf120673cee7f45a4a3fa223a", size = 12573091, upload-time = "2026-10-10T20:03:04.349Z" }, + { url = "https://files.pythonhosted.org/packages/1a/07/161270b0c2eec56e4c905f6d6d22e1b836887b2cb189d3f5820aa588e9dd/numpy-2.5.4-cp312-cp312-win_arm64.whl", hash = "sha256:aa1cce2ff3f8d953de38b76bf44602caeb69f101430208f64a10067f7cb4b1d3", size = 10521630, upload-time = "2026-10-10T20:03:06.767Z" }, + { url = "https://files.pythonhosted.org/packages/67/14/1c3ee0118a8fce08565a5d8482631608426a33af10a01077fada5dc7c119/numpy-2.5.4-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:2377da2dd3ba2c1200956acbab2a358c83b8e1f8531191672d1cd6ad83250d53", size = 16997729, upload-time = "2026-10-10T20:03:09.291Z" }, + { url = "https://files.pythonhosted.org/packages/83/8c/b0ea9477fb1f0d4484bbc5cba21678cc9969704d8d7f3f158d1db35f8e14/numpy-2.5.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:7415db95818b39ec475a5eea54d9e3b6bc83e3912158e46da3438cdce399804d", size = 12009826, upload-time = "2026-10-10T20:03:11.946Z" }, + { url = "https://files.pythonhosted.org/packages/e2/84/6a3d75b3ba3dfe84ac0053450753d1e6d250a8bf80f66474cc46d1fb643f/numpy-2.5.4-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:6d6a71b9d9a97c03633aa12565ef2825ffa036cc1d99cfd50dacf0f128af4fe2", size = 5445803, upload-time = "2026-10-10T20:03:14.329Z" }, + { url = "https://files.pythonhosted.org/packages/61/18/bb993f267ca20b376e07092a16793a5b31ed3138751e9ba480011a14d742/numpy-2.5.4-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:d8200f16437b289a5bb927c6e184eccc3e8389bc0070fea4cd5b9e13c1757959", size = 6786220, upload-time = "2026-10-10T20:03:16.602Z" }, + { url = "https://files.pythonhosted.org/packages/db/b6/135bb0953b61dc21c6cafa14b424ae666944e4899cf140e00c2b322a1a45/numpy-2.5.4-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1c2e71b04c6cad90026e544501bbe0ab9290fa8a4d845e7e8c0d124fb429c988", size = 15689178, upload-time = "2026-10-10T20:03:18.721Z" }, + { url = "https://files.pythonhosted.org/packages/da/24/3bd070f3269dc609d8f26b2643f62ef91bb415841c0b294805aaf7fe06da/numpy-2.5.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6ffa07666f8da0eef81d149934a626d0d95fbd6838432a33e66245423a9062c0", size = 16718044, upload-time = "2026-10-10T20:03:21.386Z" }, + { url = "https://files.pythonhosted.org/packages/c7/8e/9d15bd356b0a019c965312b1a3c6a727cac4cae5bc40045fbc12ce4cff9c/numpy-2.5.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:2fa3328f784fc8277fc48026f6cad516f5c561c5d8e2e39b3c9e0c8f23223b34", size = 17048364, upload-time = "2026-10-10T20:03:24.468Z" }, + { url = "https://files.pythonhosted.org/packages/dc/fe/9d5b560db964f15871885f2250795d15945f8699e17ef90c0c2ff4c875b2/numpy-2.5.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:b86966fbe4ad7de710422175572bcdc75fdedadfb54bc6fab7deabccddd7780b", size = 18474904, upload-time = "2026-10-10T20:03:27.895Z" }, + { url = "https://files.pythonhosted.org/packages/e9/98/d27552990f1bd611ef3e7466adadc78312ea2df63b83aad47fdc3d3ca8df/numpy-2.5.4-cp313-cp313-win32.whl", hash = "sha256:5258bc06526964be5face2fc6f756857a3f24f21ec3e72ca131337a75b165d6c", size = 6134537, upload-time = "2026-10-10T20:03:30.511Z" }, + { url = "https://files.pythonhosted.org/packages/90/8c/140a40398a66b4471211be1affdb6ed24c486d581bd28d07b7f2fcb69540/numpy-2.5.4-cp313-cp313-win_amd64.whl", hash = "sha256:8b4d2fd2d34e5f8c9235ee787de5631a37a28402b15cb80814df973d2be54129", size = 12566113, upload-time = "2026-10-10T20:03:32.612Z" }, + { url = "https://files.pythonhosted.org/packages/34/52/01d205e5e8ccb27b2b0b141e801f22b830198c979111b0fa44771438d9a9/numpy-2.5.4-cp313-cp313-win_arm64.whl", hash = "sha256:bc39ac66a7a9a3fbd6134fda43136b60ffde99c8f4501e64e0d2b24da137babf", size = 10519523, upload-time = "2026-10-10T20:03:35.163Z" }, + { url = "https://files.pythonhosted.org/packages/99/ba/005cb5edd580d2f84d7ca3206b92dc17d4388e56e6f87ffe8f2762f83139/numpy-2.5.4-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:c668b2f0d651605b58892644b0e302c7157f7159544227758c896982ef384b18", size = 17005499, upload-time = "2026-10-10T20:03:37.961Z" }, + { url = "https://files.pythonhosted.org/packages/f3/49/fee7587c33ee35f7977f9051d7f2023d4e7246d62710c80f20c2361ea232/numpy-2.5.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:ffa6ce09a1c6a08e9667dd9c97aa0b14184e8d18f2a14b78b2a2328c9147f076", size = 12019666, upload-time = "2026-10-10T20:03:40.606Z" }, + { url = "https://files.pythonhosted.org/packages/d5/b2/c6ce165acffceb15a82c07b9cc77d391f86b3f379ba62911908ae5d34b91/numpy-2.5.4-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:956555e0603a4d38019ae6925711cb9dc43195c076a928accf7ea5d50bddfe53", size = 5455617, upload-time = "2026-10-10T20:03:43.138Z" }, + { url = "https://files.pythonhosted.org/packages/77/7f/dd85ce260a669a89be06842cf355d7353a33e6cfbc590fb8ebb947d88dc9/numpy-2.5.4-cp314-cp314-macosx_14_0_x86_64.whl", hash = "sha256:2c2c4afffdeb7920e445028dd71eb932cac3e704792e964bc2a232426d4f1255", size = 6791932, upload-time = "2026-10-10T20:03:44.874Z" }, + { url = "https://files.pythonhosted.org/packages/63/d6/34b0a2b0741386a63025a65a2c09caaaaaad6d0ca95b66cd65c30dd7fcb5/numpy-2.5.4-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4054173604cd8658796053f1f3bc0befb68ec1c0762c57fdad61e199256a8617", size = 15710899, upload-time = "2026-10-10T20:03:46.839Z" }, + { url = "https://files.pythonhosted.org/packages/16/d5/928078d2b28f26829b138b4a6c3980045022fb409f570657a224ae60ef4e/numpy-2.5.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d549420b8858885cea8838a727842249218b9c1da24dd517e25c9c7a948310a3", size = 16721710, upload-time = "2026-10-10T20:03:49.489Z" }, + { url = "https://files.pythonhosted.org/packages/f9/cf/673fd1b8f4cd78eb6320e87ec4c90ac19c095644259e3749853a405c70f4/numpy-2.5.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:823874a507a84af050493b622affde94b6f7c3a0dc22cb2801381bc03b871c00", size = 17066182, upload-time = "2026-10-10T20:03:52.25Z" }, + { url = "https://files.pythonhosted.org/packages/f3/92/a77b5061b1b3e2643928c37976d79ee173e1b171ed158b7a3c61056b41bc/numpy-2.5.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4e263278bfb5ee6409db8aedbc4cc32973b1b82bc1e8d3c668551d04d83a7e37", size = 18480315, upload-time = "2026-10-10T20:03:55.39Z" }, + { url = "https://files.pythonhosted.org/packages/bb/1d/1486ef3d3fb2279fd93c4c43c1bbbf1ca389a19816696684409f71babaab/numpy-2.5.4-cp314-cp314-win32.whl", hash = "sha256:cfd73180400042a7c532d30c5e287bdd03c59ff9ee1b4c0316af0539e29dfe23", size = 6185739, upload-time = "2026-10-10T20:03:58.186Z" }, + { url = "https://files.pythonhosted.org/packages/52/9a/e1e512ebc948d5b9dd33b08736760f0ebbed2848fd4eda1f553088a6dcee/numpy-2.5.4-cp314-cp314-win_amd64.whl", hash = "sha256:2ca144f15135b6212a5c47b1e2aeca6e412f102f95a2d5d88d8aec77eb255de3", size = 12703552, upload-time = "2026-10-10T20:04:00.28Z" }, + { url = "https://files.pythonhosted.org/packages/2c/05/de709a982d7bbcd688a3fad71f002e9ff80c2db39e03ee726609b610f1d1/numpy-2.5.4-cp314-cp314-win_arm64.whl", hash = "sha256:468397ba3c64427474706e5c9123fe266395496714dc684294eac75cd4930d1e", size = 10803901, upload-time = "2026-10-10T20:04:02.659Z" }, + { url = "https://files.pythonhosted.org/packages/13/34/083570ada3bb2a30fbe5d77c8c6fef9141144a15d33e6f793a67e9749ab8/numpy-2.5.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1ef3aa6d7e29bb13677323114280b05acc57607fa2300e66432d665d5418a162", size = 12138695, upload-time = "2026-10-10T20:04:05.012Z" }, + { url = "https://files.pythonhosted.org/packages/94/06/1f9c24db48eef0c2d1207e3b11fffb0478e39dfd8c1e1be7476936885eed/numpy-2.5.4-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:98b053943e5a0474ec0da309d2cb9d3f18ea57f8a2067c2ab7b5f763d1068380", size = 5574615, upload-time = "2026-10-10T20:04:07.316Z" }, + { url = "https://files.pythonhosted.org/packages/da/0f/593fba2e1560e949123bc7d2fc48b5893d56e58cd4bd5a273d2fbf60b220/numpy-2.5.4-cp314-cp314t-macosx_14_0_x86_64.whl", hash = "sha256:b64a85f40e154983960a4167d4c1d57a50c7f109b3d3264a3a984154e90a8454", size = 6889383, upload-time = "2026-10-10T20:04:09.918Z" }, + { url = "https://files.pythonhosted.org/packages/eb/9f/b799dfdce4e05e80ed4bc815c71ff343a11533b2c0ffc221cae8538cda63/numpy-2.5.4-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a813ed7719bf45463c51779e6a98d0385fe905e48447526938a4b8337333d551", size = 15753763, upload-time = "2026-10-10T20:04:12.278Z" }, + { url = "https://files.pythonhosted.org/packages/34/88/16c5f12f86f5ad2817c4d103205131fc6c8acb3d1878af05a1a4f23ec859/numpy-2.5.4-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c9b80cdf5cedba0e90d93fa5f9a333c4d65bd545cd669b71bb97ce2b703c9d73", size = 16757212, upload-time = "2026-10-10T20:04:14.799Z" }, + { url = "https://files.pythonhosted.org/packages/ff/4f/a1fe40e18a898e6a5089f4f0d891f0a493eb0574d5b34458f0fbe5aa3e5c/numpy-2.5.4-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:2199ed071f460487c8db2c0e5c0b564494190edb4772fe80f9aad88b2604def5", size = 17116471, upload-time = "2026-10-10T20:04:17.58Z" }, + { url = "https://files.pythonhosted.org/packages/aa/46/e923a11c78e65c1722e7aaad817c06bd591324174b9d28ce5d31eee4d432/numpy-2.5.4-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:64f9c9878c1938476365e11ccfb6b770f3b9e5f045ccddc514235041e6959365", size = 18524063, upload-time = "2026-10-10T20:04:20.365Z" }, + { url = "https://files.pythonhosted.org/packages/5a/fa/84ab064514440c1f64a1b21088f2c82756defdd05e07c75ab233899565b2/numpy-2.5.4-cp314-cp314t-win32.whl", hash = "sha256:64d1c8ac28a4077cf987e0a71a7a0ef7e2df70722f07f0baa42dbb7eb6938647", size = 6340926, upload-time = "2026-10-10T20:04:22.865Z" }, + { url = "https://files.pythonhosted.org/packages/7e/7e/6cd886876f435b10685db9b9f7eeb70356f99e052116f4e5f11c5792c714/numpy-2.5.4-cp314-cp314t-win_amd64.whl", hash = "sha256:067374eb538c34c745436365cf7b0112595c1d326f21ce4ff340f61230239fbb", size = 12901584, upload-time = "2026-10-10T20:04:24.99Z" }, + { url = "https://files.pythonhosted.org/packages/38/1b/3c1684f6a06f7307f2335fca6e486cb162847fb97e91d65f8eb5cabad213/numpy-2.5.4-cp314-cp314t-win_arm64.whl", hash = "sha256:e94aef2c639da4a960ad0db8e06471208d8589974953d78b61d345b4eb99e394", size = 10891152, upload-time = "2026-10-10T20:04:27.52Z" }, + { url = "https://files.pythonhosted.org/packages/08/f4/3224deff3af2bef6bc0b175369698d8cb348f3d91d9bb0286cd5c9eae9e0/numpy-2.5.4-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:8dddfbee2e68d26d0d7d7d9cb247b1fd4409241cce32d815a11d97ec2cfde179", size = 17003231, upload-time = "2026-10-10T20:04:30.021Z" }, + { url = "https://files.pythonhosted.org/packages/be/75/fee0b8c6d94b44b2fdfae74f6a4ad5a138739589a8aebaec28ce4e713ed5/numpy-2.5.4-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:81e3420b27048b65eb14c3acf0c174a8cb0e023277716110347d2dcb26026dad", size = 12018300, upload-time = "2026-10-10T20:04:32.519Z" }, + { url = "https://files.pythonhosted.org/packages/47/c0/d0b335a499a04b65f532c3f034346ef390f81299060f928492dabc1e0272/numpy-2.5.4-cp315-cp315-macosx_14_0_arm64.whl", hash = "sha256:0b4724a19de67bea8cfc4970798efa78bcbbe2ac2613cfac16721a42d44de2a5", size = 5454250, upload-time = "2026-10-10T20:04:34.943Z" }, + { url = "https://files.pythonhosted.org/packages/5a/0e/461b3783c03d668052e6a21b01b673db6ffcb7831fd32d9aa5368c1cd426/numpy-2.5.4-cp315-cp315-macosx_14_0_x86_64.whl", hash = "sha256:2132418bf8dd124a427ca9e6a1daf9ee1a87185344c95119ceae868b99466da1", size = 6789644, upload-time = "2026-10-10T20:04:37.258Z" }, + { url = "https://files.pythonhosted.org/packages/b3/02/5dad269b02166965a7b4ca14adaddd75dbee0de42435bfecf561b84ba5a6/numpy-2.5.4-cp315-cp315-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:325518d4245b9e331387702aa58c2ce1dc4cdcbb41dfb4ccd5dcbc7e08db1266", size = 15704353, upload-time = "2026-10-10T20:04:39.616Z" }, + { url = "https://files.pythonhosted.org/packages/93/3a/01360c8036822ed9f7aa32189a77d1476567ec1e8e1383522389e4faac45/numpy-2.5.4-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:56733449d2544178beaa4545cee357370440cf056c197f9c7bfb19dbfdd0e86d", size = 16718648, upload-time = "2026-10-10T20:04:42.383Z" }, + { url = "https://files.pythonhosted.org/packages/7d/5c/b863a2c093c4d6f21a597fcaf24ead0835c09ab16a8312d5a5a8868af683/numpy-2.5.4-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:5ec3753760c1a6d8bb91200666e545c3a9728e6269dfb5d6ce02340996698aa3", size = 17059053, upload-time = "2026-10-10T20:04:44.976Z" }, + { url = "https://files.pythonhosted.org/packages/0a/60/ced4f57f9a1258a0af74f17cb0b0c2700b5c67cd6678823c803b263e4df3/numpy-2.5.4-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:b1185012870173de7ae33d370bd45b1cf5baee747ea4b97036b65f4e93016877", size = 18477406, upload-time = "2026-10-10T20:04:47.863Z" }, + { url = "https://files.pythonhosted.org/packages/f9/bd/0ef22dafaafcc7d4bb3ca26b8d2afbd55dedad8eaba99a8c864e1997456f/numpy-2.5.4-cp315-cp315-win32.whl", hash = "sha256:298eca75243f2cbbfdb460560b9fb2a1792a33cf2ab4286efd43d92e8d3df508", size = 6185133, upload-time = "2026-10-10T20:04:50.467Z" }, + { url = "https://files.pythonhosted.org/packages/50/bc/d2651b155ecc608a77e6f4d15495c11f14f19bb98f8bf0c5b0d38f86dda1/numpy-2.5.4-cp315-cp315-win_amd64.whl", hash = "sha256:332f3378fe077dd850e677ec01bdcc4f22368fb5d50ef10b2c79230b1bf5a592", size = 12703085, upload-time = "2026-10-10T20:04:52.63Z" }, + { url = "https://files.pythonhosted.org/packages/dc/d2/45e404f8abb26fb9eda12b94012936873e827b1be76f2ee7890be128312e/numpy-2.5.4-cp315-cp315-win_arm64.whl", hash = "sha256:d4cccbbc78717966f764cd3af4fb70276fa01fc7a2688af11c78901fa5c04f05", size = 10801451, upload-time = "2026-10-10T20:04:55.677Z" }, + { url = "https://files.pythonhosted.org/packages/c6/c3/2ae14e09cfdb67dc187a342e15308a21c15bf4d2071f8079e6aee5fe56dc/numpy-2.5.4-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:950ea81d57ef070665581b6e1b5f6a029306423cd1739c5b95fe78aa30db6b9d", size = 17097121, upload-time = "2026-10-10T20:04:58.403Z" }, + { url = "https://files.pythonhosted.org/packages/f5/cf/305ae624ef8a039414317224abe9ec9c2fe7ea3c2e1cf204d43ff6b2ffb9/numpy-2.5.4-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:c05ede731b03fb1b7591faca9389ade3267d2bddf1ad8882bb3f2cc5e101694f", size = 12135439, upload-time = "2026-10-10T20:05:01.65Z" }, + { url = "https://files.pythonhosted.org/packages/a9/a8/f75c63813aef95827bb2c0d13b12803016853056e8792c280058cdbfe783/numpy-2.5.4-cp315-cp315t-macosx_14_0_arm64.whl", hash = "sha256:5fbf7141bbfd63aea22f435c9062a032b9ea0082fe9845dad7f021d3f1234e71", size = 5571451, upload-time = "2026-10-10T20:05:04.135Z" }, + { url = "https://files.pythonhosted.org/packages/6f/0f/f17763f983868b5c49b4101ebd7e00760bd1769478a6bb6a8de6e085bbac/numpy-2.5.4-cp315-cp315t-macosx_14_0_x86_64.whl", hash = "sha256:3573cd22564692a5b899ec344e5d5b9cc4576f2985b96f22af3564ed54f2710f", size = 6883356, upload-time = "2026-10-10T20:05:06.249Z" }, + { url = "https://files.pythonhosted.org/packages/67/a7/8af04c5a79e047996cfa38854dcfbececdd0343a7c933a46fdd03ef6f5da/numpy-2.5.4-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6c109eac9cd439193678f69d70733c1108487546ca8eafc107b510ae10c1aecd", size = 15750991, upload-time = "2026-10-10T20:05:08.376Z" }, + { url = "https://files.pythonhosted.org/packages/57/7a/648254290d0c504faa8f2d07aa206660c728802c781a6f3fc68ab7cb5d71/numpy-2.5.4-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:80d6ef6e8620eb2c2b4c4caad50b5935d6db3cde2d51581b55dcc79e14016d1d", size = 16757675, upload-time = "2026-10-10T20:05:11.393Z" }, + { url = "https://files.pythonhosted.org/packages/b8/fe/4a8c3cdb0c70400cfe4c5bec42d3099a5673802a95064614b33e07b82aa1/numpy-2.5.4-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:77045a4b175bbf5316ec08003880804336c78f92281a1b72222b274ea85ec5ac", size = 17113846, upload-time = "2026-10-10T20:05:14.49Z" }, + { url = "https://files.pythonhosted.org/packages/1b/7e/619692bb67778702c0e9eb2d468568a7573f4e269386ea61aed01ee4e557/numpy-2.5.4-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:0f02a46e49cfb6c73bdb7aea1c0d3461dbae9aba613542b65f657cd3d17b9fab", size = 18522915, upload-time = "2026-10-10T20:05:17.33Z" }, + { url = "https://files.pythonhosted.org/packages/b7/b5/4da41c328788f575838f97a098fe8ca691ebc6f6fd73ad4a262ee40b184d/numpy-2.5.4-cp315-cp315t-win32.whl", hash = "sha256:ad62a416ddcf863bf44bba76fbf6b53366ab0692e294f51cae4b5fbe0d246788", size = 6335804, upload-time = "2026-10-10T20:05:19.921Z" }, + { url = "https://files.pythonhosted.org/packages/98/94/6482ddfa3d312490cb9358f375bf2ad56427dbea8769187158e94d653753/numpy-2.5.4-cp315-cp315t-win_amd64.whl", hash = "sha256:38f47be9f74ab870d2633b5456ae519c43758a8d1fd05342f0ce4ecc034396ee", size = 12890095, upload-time = "2026-10-10T20:05:21.875Z" }, + { url = "https://files.pythonhosted.org/packages/48/7f/c2d1b436b6e7cfebac140c2579a298344b85f2991a2ce5c3615cefb29400/numpy-2.5.4-cp315-cp315t-win_arm64.whl", hash = "sha256:7a14a461d9340f1b46b8648578aed9cdb8b3b018a8fac6c1dde2c9192a01a87f", size = 10883718, upload-time = "2026-10-10T20:05:28.547Z" }, +] + +[[package]] +name = "oct2py" +version = "6.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "metakernel" }, + { name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, + { name = "numpy", version = "2.5.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, + { name = "octave-kernel" }, + { name = "pydantic-settings" }, + { name = "scipy", version = "1.17.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, + { name = "scipy", version = "1.18.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, + { name = "tornado" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/90/83/792fce2ea65ea7d2c480620bb461cf59230244ded4d2853ac3d5b87257a0/oct2py-6.1.1.tar.gz", hash = "sha256:a7badb0294be3ab1cf3caf646049e70ae2fbff0805b5cd2b06d7b09cf5378695", size = 77607, upload-time = "2026-08-23T10:13:46.967Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a3/a4/e2b2b181b4d19d345cc4aa7f753248d7308432f9e00289eb9d794702af2d/oct2py-6.1.1-py3-none-any.whl", hash = "sha256:58751fc071f67ec5f5836922bfd88dc062bd5ee3e120f2730f09575bf95b1449", size = 43244, upload-time = "2026-08-23T10:13:45.864Z" }, +] + +[[package]] +name = "octave-kernel" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ipykernel" }, + { name = "jupyter-client" }, + { name = "metakernel" }, + { name = "rpds-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/63/74/29b867c63644c776aa291fb571949375d2c17d77d598b35b3712ae4d4298/octave_kernel-1.1.1.tar.gz", hash = "sha256:8c9821bf32dde6b3aae9b09c5663e035f0987530245257c7d31e3fcf0086195f", size = 568618, upload-time = "2026-08-17T10:00:51.032Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/15/58/2428f66d6a5b887e0f88e991ccee9e2381e7dc1bdc102ff414ac52b88b5a/octave_kernel-1.1.1-py3-none-any.whl", hash = "sha256:1bf64b278659d1d082744c9c8d9fe8eb010ff798c8378f0924c9f311e4b9571c", size = 40895, upload-time = "2026-08-17T10:00:49.97Z" }, +] + +[[package]] +name = "opentelemetry-api" +version = "1.45.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/19/14/cf3a6b6448849656e1e5f4e2101f3988dc6789724050096aba1bc5ccf592/opentelemetry_api-1.45.2.tar.gz", hash = "sha256:d7b0008e21e5fd61cbe7a7f34ca3b6905a78ab677d9bc395e299359c75cda6b4", size = 73277, upload-time = "2026-10-29T17:29:37.888Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a9/2d/610db864d7513158cebb8f36cc88e67e73bd6c7aa1905ef18d89e1281c81/opentelemetry_api-1.45.2-py3-none-any.whl", hash = "sha256:2cbd737377e710ee740d261c94e93fa0f08e6d037c18f17513cc0a2d94479a34", size = 60335, upload-time = "2026-10-29T17:29:06.955Z" }, +] + +[[package]] +name = "packaging" +version = "26.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79", size = 313412, upload-time = "2026-08-04T18:15:28.737Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" }, +] + +[[package]] +name = "parso" +version = "0.8.7" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/30/4b/90c937815137d43ce71ba043cd3566221e9df6b9c805f24b5d138c9d40a7/parso-0.8.7.tar.gz", hash = "sha256:eaaac4c9fdd5e9e8852dc778d2d7405897ec510f2a298071453e5e3a07914bb1", size = 401824, upload-time = "2026-05-01T23:13:02.138Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/99/5d/8268b644392ee874ee82a635cd0df1773de230bde356c38de28e298392cc/parso-0.8.7-py2.py3-none-any.whl", hash = "sha256:a8926eb2a1b915486941fdbd31e86a4baf88fe8c210f25f2f35ecec5b574ca1c", size = 107025, upload-time = "2026-05-01T23:12:58.867Z" }, +] + +[[package]] +name = "pathspec" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5a/82/42f767fc1c1143d6fd36efb827202a2d997a375e160a71eb2888a925aac1/pathspec-1.1.1.tar.gz", hash = "sha256:17db5ecd524104a120e173814c90367a96a98d07c45b2e10c2f3919fff91bf5a", size = 135180, upload-time = "2026-04-27T01:46:08.907Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f1/d9/7fb5aa316bc299258e68c73ba3bddbc499654a07f151cba08f6153988714/pathspec-1.1.1-py3-none-any.whl", hash = "sha256:a00ce642f577bf7f473932318056212bc4f8bfdf53128c78bbd5af0b9b20b189", size = 57328, upload-time = "2026-04-27T01:46:07.06Z" }, +] + +[[package]] +name = "pexpect" +version = "4.9.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ptyprocess" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/42/92/cc564bf6381ff43ce1f4d06852fc19a2f11d180f23dc32d9588bee2f149d/pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f", size = 166450, upload-time = "2023-11-25T09:07:26.339Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9e/c3/059298687310d527a58bb01f3b1965787ee3b40dce76752eda8b44e9a2c5/pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523", size = 63772, upload-time = "2023-11-25T06:56:14.81Z" }, +] + +[[package]] +name = "platformdirs" +version = "4.14.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d7/9a/8475be631fb33ca1466915e70fd594c42a4e84b512db650eaa14f90fe75d/platformdirs-4.14.5.tar.gz", hash = "sha256:32e9921db7385aa8169bee4fe9501923e5715ba9fb7ea3b9c69b0d8e0639f7a1", size = 71464, upload-time = "2026-11-04T16:54:50.358Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7c/ae/ecbbbfd0e4343a6a521d49b3c8656fb4643dee2a4f6eaf941cf3280391a8/platformdirs-4.14.5-py3-none-any.whl", hash = "sha256:8e778c6fa421516f4d3369449f8df3b0e1b72c0e0005fe88e3ec772d0a14e750", size = 35402, upload-time = "2026-11-04T16:54:48.875Z" }, +] + +[[package]] +name = "pluggy" +version = "1.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/db/7fc19e6f2dc92a966727031389fc2e08b558f0f25eb7403c1119ad4713cd/pluggy-1.7.0.tar.gz", hash = "sha256:d1eaa46ebb595891b860ab086b4d09c8588af65ebd4361b8e8f4bb8920b90ba8", size = 123304, upload-time = "2026-10-15T09:50:58.343Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/40/9e/2b38731e0fc536806f16490e1a12d7f0dc2a1235aa8cc07bcc75416a7daa/pluggy-1.7.0-py3-none-any.whl", hash = "sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec", size = 27082, upload-time = "2026-10-15T09:50:56.808Z" }, +] + +[[package]] +name = "prompt-toolkit" +version = "3.0.53" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "wcwidth" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7d/ea/39b988c938f75cb75d7045b5c69f8bfed47ee2152c8837fb403de29d6fb8/prompt_toolkit-3.0.53.tar.gz", hash = "sha256:9ec8a0ad96d5c56148b3f914aa79c1564c3fde5d2e6b876e7bc327e353cf8fa6", size = 435492, upload-time = "2026-07-26T20:56:14.758Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/6f/84908cad2d6aa5144abcf7b42709fe4fdb459bc640ec7ac5786e7693dabc/prompt_toolkit-3.0.53-py3-none-any.whl", hash = "sha256:01c0891d7f9237d5e339f7d3e42cdae80b7534abb1c7c0e3352efba6231492f2", size = 392288, upload-time = "2026-07-26T20:56:12.512Z" }, +] + +[[package]] +name = "psutil" +version = "7.2.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/aa/c6/d1ddf4abb55e93cebc4f2ed8b5d6dbad109ecb8d63748dd2b20ab5e57ebe/psutil-7.2.2.tar.gz", hash = "sha256:0746f5f8d406af344fd547f1c8daa5f5c33dbc293bb8d6a16d80b4bb88f59372", size = 493740, upload-time = "2026-01-28T18:14:54.428Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/08/510cbdb69c25a96f4ae523f733cdc963ae654904e8db864c07585ef99875/psutil-7.2.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:2edccc433cbfa046b980b0df0171cd25bcaeb3a68fe9022db0979e7aa74a826b", size = 130595, upload-time = "2026-01-28T18:14:57.293Z" }, + { url = "https://files.pythonhosted.org/packages/d6/f5/97baea3fe7a5a9af7436301f85490905379b1c6f2dd51fe3ecf24b4c5fbf/psutil-7.2.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:e78c8603dcd9a04c7364f1a3e670cea95d51ee865e4efb3556a3a63adef958ea", size = 131082, upload-time = "2026-01-28T18:14:59.732Z" }, + { url = "https://files.pythonhosted.org/packages/37/d6/246513fbf9fa174af531f28412297dd05241d97a75911ac8febefa1a53c6/psutil-7.2.2-cp313-cp313t-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1a571f2330c966c62aeda00dd24620425d4b0cc86881c89861fbc04549e5dc63", size = 181476, upload-time = "2026-01-28T18:15:01.884Z" }, + { url = "https://files.pythonhosted.org/packages/b8/b5/9182c9af3836cca61696dabe4fd1304e17bc56cb62f17439e1154f225dd3/psutil-7.2.2-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:917e891983ca3c1887b4ef36447b1e0873e70c933afc831c6b6da078ba474312", size = 184062, upload-time = "2026-01-28T18:15:04.436Z" }, + { url = "https://files.pythonhosted.org/packages/16/ba/0756dca669f5a9300d0cbcbfae9a4c30e446dfc7440ffe43ded5724bfd93/psutil-7.2.2-cp313-cp313t-win_amd64.whl", hash = "sha256:ab486563df44c17f5173621c7b198955bd6b613fb87c71c161f827d3fb149a9b", size = 139893, upload-time = "2026-01-28T18:15:06.378Z" }, + { url = "https://files.pythonhosted.org/packages/1c/61/8fa0e26f33623b49949346de05ec1ddaad02ed8ba64af45f40a147dbfa97/psutil-7.2.2-cp313-cp313t-win_arm64.whl", hash = "sha256:ae0aefdd8796a7737eccea863f80f81e468a1e4cf14d926bd9b6f5f2d5f90ca9", size = 135589, upload-time = "2026-01-28T18:15:08.03Z" }, + { url = "https://files.pythonhosted.org/packages/81/69/ef179ab5ca24f32acc1dac0c247fd6a13b501fd5534dbae0e05a1c48b66d/psutil-7.2.2-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:eed63d3b4d62449571547b60578c5b2c4bcccc5387148db46e0c2313dad0ee00", size = 130664, upload-time = "2026-01-28T18:15:09.469Z" }, + { url = "https://files.pythonhosted.org/packages/7b/64/665248b557a236d3fa9efc378d60d95ef56dd0a490c2cd37dafc7660d4a9/psutil-7.2.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:7b6d09433a10592ce39b13d7be5a54fbac1d1228ed29abc880fb23df7cb694c9", size = 131087, upload-time = "2026-01-28T18:15:11.724Z" }, + { url = "https://files.pythonhosted.org/packages/d5/2e/e6782744700d6759ebce3043dcfa661fb61e2fb752b91cdeae9af12c2178/psutil-7.2.2-cp314-cp314t-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fa4ecf83bcdf6e6c8f4449aff98eefb5d0604bf88cb883d7da3d8d2d909546a", size = 182383, upload-time = "2026-01-28T18:15:13.445Z" }, + { url = "https://files.pythonhosted.org/packages/57/49/0a41cefd10cb7505cdc04dab3eacf24c0c2cb158a998b8c7b1d27ee2c1f5/psutil-7.2.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e452c464a02e7dc7822a05d25db4cde564444a67e58539a00f929c51eddda0cf", size = 185210, upload-time = "2026-01-28T18:15:16.002Z" }, + { url = "https://files.pythonhosted.org/packages/dd/2c/ff9bfb544f283ba5f83ba725a3c5fec6d6b10b8f27ac1dc641c473dc390d/psutil-7.2.2-cp314-cp314t-win_amd64.whl", hash = "sha256:c7663d4e37f13e884d13994247449e9f8f574bc4655d509c3b95e9ec9e2b9dc1", size = 141228, upload-time = "2026-01-28T18:15:18.385Z" }, + { url = "https://files.pythonhosted.org/packages/f2/fc/f8d9c31db14fcec13748d373e668bc3bed94d9077dbc17fb0eebc073233c/psutil-7.2.2-cp314-cp314t-win_arm64.whl", hash = "sha256:11fe5a4f613759764e79c65cf11ebdf26e33d6dd34336f8a337aa2996d71c841", size = 136284, upload-time = "2026-01-28T18:15:19.912Z" }, + { url = "https://files.pythonhosted.org/packages/e7/36/5ee6e05c9bd427237b11b3937ad82bb8ad2752d72c6969314590dd0c2f6e/psutil-7.2.2-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:ed0cace939114f62738d808fdcecd4c869222507e266e574799e9c0faa17d486", size = 129090, upload-time = "2026-01-28T18:15:22.168Z" }, + { url = "https://files.pythonhosted.org/packages/80/c4/f5af4c1ca8c1eeb2e92ccca14ce8effdeec651d5ab6053c589b074eda6e1/psutil-7.2.2-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:1a7b04c10f32cc88ab39cbf606e117fd74721c831c98a27dc04578deb0c16979", size = 129859, upload-time = "2026-01-28T18:15:23.795Z" }, + { url = "https://files.pythonhosted.org/packages/b5/70/5d8df3b09e25bce090399cf48e452d25c935ab72dad19406c77f4e828045/psutil-7.2.2-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:076a2d2f923fd4821644f5ba89f059523da90dc9014e85f8e45a5774ca5bc6f9", size = 155560, upload-time = "2026-01-28T18:15:25.976Z" }, + { url = "https://files.pythonhosted.org/packages/63/65/37648c0c158dc222aba51c089eb3bdfa238e621674dc42d48706e639204f/psutil-7.2.2-cp36-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b0726cecd84f9474419d67252add4ac0cd9811b04d61123054b9fb6f57df6e9e", size = 156997, upload-time = "2026-01-28T18:15:27.794Z" }, + { url = "https://files.pythonhosted.org/packages/8e/13/125093eadae863ce03c6ffdbae9929430d116a246ef69866dad94da3bfbc/psutil-7.2.2-cp36-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:fd04ef36b4a6d599bbdb225dd1d3f51e00105f6d48a28f006da7f9822f2606d8", size = 148972, upload-time = "2026-01-28T18:15:29.342Z" }, + { url = "https://files.pythonhosted.org/packages/04/78/0acd37ca84ce3ddffaa92ef0f571e073faa6d8ff1f0559ab1272188ea2be/psutil-7.2.2-cp36-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:b58fabe35e80b264a4e3bb23e6b96f9e45a3df7fb7eed419ac0e5947c61e47cc", size = 148266, upload-time = "2026-01-28T18:15:31.597Z" }, + { url = "https://files.pythonhosted.org/packages/b4/90/e2159492b5426be0c1fef7acba807a03511f97c5f86b3caeda6ad92351a7/psutil-7.2.2-cp37-abi3-win_amd64.whl", hash = "sha256:eb7e81434c8d223ec4a219b5fc1c47d0417b12be7ea866e24fb5ad6e84b3d988", size = 137737, upload-time = "2026-01-28T18:15:33.849Z" }, + { url = "https://files.pythonhosted.org/packages/8c/c7/7bb2e321574b10df20cbde462a94e2b71d05f9bbda251ef27d104668306a/psutil-7.2.2-cp37-abi3-win_arm64.whl", hash = "sha256:8c233660f575a5a89e6d4cb65d9f938126312bca76d8fe087b947b3a1aaac9ee", size = 134617, upload-time = "2026-01-28T18:15:36.514Z" }, +] + +[[package]] +name = "ptyprocess" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/20/e5/16ff212c1e452235a90aeb09066144d0c5a6a8c0834397e03f5224495c4e/ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220", size = 70762, upload-time = "2020-12-28T15:15:30.155Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/22/a6/858897256d0deac81a172289110f31629fc4cee19b6f01283303e18c8db3/ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35", size = 13993, upload-time = "2020-12-28T15:15:28.35Z" }, +] + +[[package]] +name = "pure-eval" +version = "0.2.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/da/9f/abfd2959e9261dd5217ca8551d4de211ca6ab26fe9b72cf44731ff6c4442/pure_eval-0.2.4.tar.gz", hash = "sha256:260c2774686e651b79f8b8e7fc9d80b3599ea6a66334b47d5f4abb69fc2c0ea1", size = 20563, upload-time = "2026-09-10T21:41:22.836Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6d/18/83376915176eb058cb86470eb7396388a13350b09a8f233a79303bbcbc5b/pure_eval-0.2.4-py3-none-any.whl", hash = "sha256:96cae060a313cfaad51bb761278bfb0e62dc0248d9315a81173752dc546cd37a", size = 11893, upload-time = "2026-09-10T21:41:21.532Z" }, +] + +[[package]] +name = "pycparser" +version = "3.12" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cb/27/eeb9f307bf07060f3d9f9aa0fb8c15b01bdfded0a941e4b2719c7f94cacd/pycparser-3.12.tar.gz", hash = "sha256:f03387877eab82ce01bbdfd0ba7252ee55a90b1c708d5129e2ce915475cf1db6", size = 158785, upload-time = "2026-10-22T13:40:03.56Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b6/ae/315bbeee126a769cbde43cf4908acb4b40408d8bf8bbf334dd7368d8dadf/pycparser-3.12-py3-none-any.whl", hash = "sha256:a076f3f489b39b43ed13563a1dafe42447445bec2e294154ec5c57fcdda4c85e", size = 62600, upload-time = "2026-10-22T13:40:02.021Z" }, +] + +[[package]] +name = "pydantic" +version = "2.14.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-types" }, + { name = "pydantic-core" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b4/fc/1203d011145c98ddce3cd2f505bb54375ef8d43223053df6bfcf3c746f46/pydantic-2.14.3.tar.gz", hash = "sha256:1054f237f4d4733e5a30e1e2333bd33a2004ab9ab1510bd053a9a31bb48e232d", size = 925636, upload-time = "2026-11-05T09:17:04.686Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/72/b8/b864503789ef5c58597d2a7b4adbee62c26440ab1e682581fc6838df8947/pydantic-2.14.3-py3-none-any.whl", hash = "sha256:3f7b347782ab7e4cf4c798496ae3a82787d9f21ec12676a9c564355eeef8daa8", size = 494071, upload-time = "2026-11-05T09:17:02.426Z" }, +] + +[[package]] +name = "pydantic-core" +version = "2.50.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9c/0f/34f9ce4ba701dd0b815033ef94d99b56f66200e578ee6052aa3ac26f064e/pydantic_core-2.50.4.tar.gz", hash = "sha256:aead3b74b68396bf0feab5d57e050b730ded7df55853c1e048a87e00aaf033c6", size = 522249, upload-time = "2026-11-05T09:15:26.774Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/df/00/85e80811834d7cbd9bc228f9b5cdf8ec0edd69b55351ad720aac8c412d8c/pydantic_core-2.50.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:3e547ceec1da7382f01f9e13963023e53367a71802c88778b21b9645a077cbdf", size = 2170584, upload-time = "2026-11-05T09:11:41.139Z" }, + { url = "https://files.pythonhosted.org/packages/a3/f1/438de1fb99d717dcc6521922478dc16ef7b757302d4fc1f7faba3aaeac09/pydantic_core-2.50.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c813ada7a651193acda85b6bc1cf12abd4b37cd25c7c6a75d7183512cc374969", size = 2128471, upload-time = "2026-11-05T09:11:42.65Z" }, + { url = "https://files.pythonhosted.org/packages/b7/74/f21ab568c6d3f315988b40e53f809c95b63fafc5403332963aa6dfc2c054/pydantic_core-2.50.4-cp311-cp311-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:57fa0a9490785139f1a4e4f43891830d55dfe4408845c0c9cb5eff4aeaf75f69", size = 2281509, upload-time = "2026-11-05T09:11:44.359Z" }, + { url = "https://files.pythonhosted.org/packages/a1/42/24ed3ea8e2fb6463c9ba5b8b1f089e69040905c7fd81dcfa6f52fcc692d5/pydantic_core-2.50.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:30d4dc35bc0eea52202a90b3820445ee0072c820241bfa710a623a078c9b267b", size = 2128064, upload-time = "2026-11-05T09:11:46.01Z" }, + { url = "https://files.pythonhosted.org/packages/d6/d1/44f541b2c18a46df6f18281a557acefeb5bbf0733a0b80b0a5e835e10ee4/pydantic_core-2.50.4-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:789f88dea57841cdebef392b5d6e90444d767117e9ff2e0d9172df5c9de6690c", size = 2214472, upload-time = "2026-11-05T09:11:47.503Z" }, + { url = "https://files.pythonhosted.org/packages/bd/1b/e9a9ad8733e8051abca9e4acce37ba3ddd13930fd3b8730f4c7816fa979a/pydantic_core-2.50.4-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:d690121e80ab16e623415351ab24713534d4e500b3cadff216409cb6826063d4", size = 2401153, upload-time = "2026-11-05T09:11:49.403Z" }, + { url = "https://files.pythonhosted.org/packages/79/84/d88e8e6aa42d4d677666d6625db9177ad6851be9e7564a25aeb0b0cbcaf2/pydantic_core-2.50.4-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b42f64825f5d750228f08318a9bf4d723b7ecb4c472aedcb3013c3ec2dc1f949", size = 2453307, upload-time = "2026-11-05T09:11:51.118Z" }, + { url = "https://files.pythonhosted.org/packages/56/51/cbb7a1bc0196ff94d3478d265eed7449f811759988eb760d41f4edd0893b/pydantic_core-2.50.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:0574866e05f6adeecc520d87e87dd06210c0a51706341f6ef8421572f5a64444", size = 2253434, upload-time = "2026-11-05T09:11:52.997Z" }, + { url = "https://files.pythonhosted.org/packages/9e/04/206b4881d631033ae88f005da6e11bd610c850e1850217342c03053d253b/pydantic_core-2.50.4-cp311-cp311-manylinux_2_31_riscv64.whl", hash = "sha256:dcf2c7eaaa4cafe8e49b017e5bb49e76e084ab6f0cd712ee4019c812b5cf68b8", size = 2279365, upload-time = "2026-11-05T09:11:54.822Z" }, + { url = "https://files.pythonhosted.org/packages/a1/7c/d815b5a3f83069b283d3b6a2e61de6e14baac3b20c6cd3418e9e629551cf/pydantic_core-2.50.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:3b8ee2589a082739c522c1fe4be227412fcf108b903abb6672ae2f5570558882", size = 2319407, upload-time = "2026-11-05T09:11:56.46Z" }, + { url = "https://files.pythonhosted.org/packages/ee/00/c9a483276d1052d5142e1e01eccac97d939f83a3a3fd94c4766495a9b807/pydantic_core-2.50.4-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:aec3c2d741a8e3ee993de7f95f37afb51e31b169c95dbd29da4cf6688f340914", size = 2489900, upload-time = "2026-11-05T09:11:58.102Z" }, + { url = "https://files.pythonhosted.org/packages/2d/b5/8cd8ee29a1d63ad47f95593384df92476cef6896c644f280db0748b8e76b/pydantic_core-2.50.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8923fcd49f875e8a0448d7223d1fdf1a9973ae2d1f20d4158753ceb8909facd2", size = 2497732, upload-time = "2026-11-05T09:11:59.928Z" }, + { url = "https://files.pythonhosted.org/packages/60/31/050a48c0c373df16442ac07f3fa167414bb0e22f54a3e886f6d6cb7ad1d4/pydantic_core-2.50.4-cp311-cp311-win32.whl", hash = "sha256:fc04affef30be98c1f36f0c422a4061ef618fdc1dde79f5ad5458dd496fecffa", size = 2132347, upload-time = "2026-11-05T09:12:01.928Z" }, + { url = "https://files.pythonhosted.org/packages/c6/06/cebeeb7a8e87b42a3d8bc189d0d400e47df5d1736cb326764bae8a74c433/pydantic_core-2.50.4-cp311-cp311-win_amd64.whl", hash = "sha256:15bece43a02ad543c621c8305e67dedb5f27d378c5ba741e5a2c36523f8ef37f", size = 2255970, upload-time = "2026-11-05T09:12:03.888Z" }, + { url = "https://files.pythonhosted.org/packages/46/db/5b4bf14347da658c994483043fbabffedcab98929c41c261ec168c3c1f87/pydantic_core-2.50.4-cp311-cp311-win_arm64.whl", hash = "sha256:e498900bfbf7ddddd862f810440c09e9b81674739e8a11d619b40906dccd4a9a", size = 2196799, upload-time = "2026-11-05T09:12:05.389Z" }, + { url = "https://files.pythonhosted.org/packages/10/bf/d1f6b81709538f831ebe1c42f50fb89db3dfda06f9e9b1ea24e90fc69209/pydantic_core-2.50.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:32a991aebd165f227b7c7c60bb9d66c2c7de9c24308552da264c9938fde0f8d6", size = 2231444, upload-time = "2026-11-05T09:12:06.969Z" }, + { url = "https://files.pythonhosted.org/packages/c1/39/6618e541658d5a687a8d4962fc304350073a8f322bc4c62e8ed4c2d514d6/pydantic_core-2.50.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1e20cbde2b6deb33a51d08cd168454dd9044ec7d4474056f4d98d63f51578783", size = 2108048, upload-time = "2026-11-05T09:12:08.85Z" }, + { url = "https://files.pythonhosted.org/packages/d9/54/1c941fffa4e14bfc9ab0cd4977075f0e03201447856130d08a33cd45e47b/pydantic_core-2.50.4-cp312-cp312-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:8cceae48ae7f94990c2f4e36291e9ec9868735e8b0f19e4489a17b0422338466", size = 2256866, upload-time = "2026-11-05T09:12:10.495Z" }, + { url = "https://files.pythonhosted.org/packages/61/a0/8028ef3e014be522ce43060aeac82a5be2288215e660866f5e6260acc123/pydantic_core-2.50.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:16902a147b3da4840612164a5e67947104d63e978f7a57c395877a5e26690b9c", size = 2125682, upload-time = "2026-11-05T09:12:12.278Z" }, + { url = "https://files.pythonhosted.org/packages/c3/f2/b98bb73b1734ec4e42e786a766abc24f3c89620a0ddbaf8aa14e4b4c628c/pydantic_core-2.50.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:d6e3485a5e5c01fb5339c1ee3d4b9e21e2135a2a9d44caafb71acd994487ee7c", size = 2197108, upload-time = "2026-11-05T09:12:13.873Z" }, + { url = "https://files.pythonhosted.org/packages/f1/d1/7a7142786781400143e8806633fe5b65e2d407c311041fc9494490f05b18/pydantic_core-2.50.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:629eae995185540406e3635df5d5cf1d44f19ea240840b835d3f44541ff694d8", size = 2380521, upload-time = "2026-11-05T09:12:15.539Z" }, + { url = "https://files.pythonhosted.org/packages/b5/34/cf710ca48d4498b04a3ea605d45892675dc2b14a94a25121a8d03f56d3e9/pydantic_core-2.50.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:41b2cd8b29dbb5a4c9828a70f50d1abfc92011115c813213d3a91205c6f731b3", size = 2457436, upload-time = "2026-11-05T09:12:17.447Z" }, + { url = "https://files.pythonhosted.org/packages/91/23/e0c6e3cd09a0ac809953fea698c816b9f03bf0b35b6820c9553e4f5d85a8/pydantic_core-2.50.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c81d98e27d9d9261909dcccab1ba5d6ea1c98b0bb9470e368604614fd1d36ddd", size = 2261727, upload-time = "2026-11-05T09:12:19.097Z" }, + { url = "https://files.pythonhosted.org/packages/f9/00/292a0ed96d5d2d6edb49468ef481336e5b7e54f13435d73b7c912c891c23/pydantic_core-2.50.4-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:ca83a32b2b41653d89f09a3d22b770bca96da72273bef8f7a68136bdd1e8b823", size = 2262071, upload-time = "2026-11-05T09:12:20.78Z" }, + { url = "https://files.pythonhosted.org/packages/f8/36/d4690faf8c082eacf7754e52ab6bebe1bc73b167272e28699c00480ee908/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:817953730e4a73a09008b010c4a42396cefe799616a22df2ac21d3927b3080cf", size = 2298931, upload-time = "2026-11-05T09:12:22.614Z" }, + { url = "https://files.pythonhosted.org/packages/21/17/b180af6d17cf6c8e0d3d2661fc501a4a40959744ca4947d6ad0db81b1416/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:664e74848c2f5fc27db8505fe24e1ecd3ac669412913bf73d176916f86cc08e2", size = 2474285, upload-time = "2026-11-05T09:12:24.842Z" }, + { url = "https://files.pythonhosted.org/packages/6e/bb/7e44d4ac6e1292f1859384c688713045bdf5448e0635c49c003d2be3bb6c/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:219114f8dcdcbe4720d82ef016b1287ce5a0a67d7c69ca61524eb72e82aac344", size = 2498172, upload-time = "2026-11-05T09:12:26.434Z" }, + { url = "https://files.pythonhosted.org/packages/d8/84/5101f35294579c4bef7dc32fd4f097d91eedac2e195894266bdabc1e6dfd/pydantic_core-2.50.4-cp312-cp312-win32.whl", hash = "sha256:67f7cc397e1d5556a801d1cba74de0d27d827eb242e6c036c0ca273c745414f1", size = 2119592, upload-time = "2026-11-05T09:12:27.971Z" }, + { url = "https://files.pythonhosted.org/packages/82/88/d438a8fcf3738e9ff2670f724047ca3893ec899bcd5cdfc077a2aab133c6/pydantic_core-2.50.4-cp312-cp312-win_amd64.whl", hash = "sha256:ea2f61b0bc12f3592288503961b764579dea0658852d96a0b3d823614d808821", size = 2264064, upload-time = "2026-11-05T09:12:29.538Z" }, + { url = "https://files.pythonhosted.org/packages/77/d4/4a0c73dc3ef9e50b122b8c3527afcded15a44838f1c9668d2d4b72cc09f0/pydantic_core-2.50.4-cp312-cp312-win_arm64.whl", hash = "sha256:32d6dda86383645ec428ea64dfc277036f5cbc60a72238eab28b91a3fdb9a113", size = 2167792, upload-time = "2026-11-05T09:12:31.103Z" }, + { url = "https://files.pythonhosted.org/packages/1b/21/39f8d97e7ea8e3083606ee9bb1d7f3ec70ded780bb6a872aad76c7eb08b2/pydantic_core-2.50.4-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:0f87ae9db5ba8d8de40dcb93982cf8dd544e6552a80d3345af51941cc2146b80", size = 2232841, upload-time = "2026-11-05T09:12:32.617Z" }, + { url = "https://files.pythonhosted.org/packages/90/a9/fc89a632331882c4cb91b949003418e6f5085ddcf2c9b875d499682bca91/pydantic_core-2.50.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1239daaf063e62213ca1f34d96663900bd7510c42a786e843fd328af70e46445", size = 2108326, upload-time = "2026-11-05T09:12:34.419Z" }, + { url = "https://files.pythonhosted.org/packages/5d/6d/4f6d00e9e4ba2a7bfb206ae49cb32a3ea90c4d658e62f8775277d75e8291/pydantic_core-2.50.4-cp313-cp313-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:1afefe44ec042fbabfb4483ea258c04cf75ff4ff328d754f09b321fdaa232aca", size = 2256276, upload-time = "2026-11-05T09:12:36.212Z" }, + { url = "https://files.pythonhosted.org/packages/b3/b8/936cb0d85a4082e902c7397db0f05c4372eac08372c8bd2d0b43088fcf17/pydantic_core-2.50.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:a9ee990bf2cfbd81574c5d4f9f6c9d480a14b5b43d2c4f2ca13f4c6f48089394", size = 2125469, upload-time = "2026-11-05T09:12:37.913Z" }, + { url = "https://files.pythonhosted.org/packages/66/a1/f3b551ce233dcac73286b8b2ae45c23232a9f41c68663e2dcce4bb2dbcfa/pydantic_core-2.50.4-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:ab2822bcdcefb54d1e8ca29f5e3ec3afe160fb794bb3a3a73b09d11ed2671104", size = 2196397, upload-time = "2026-11-05T09:12:39.725Z" }, + { url = "https://files.pythonhosted.org/packages/3d/93/a8a6e7e20826567a73e6f52416667698aa3de704804d7a49d25272246af4/pydantic_core-2.50.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:0001d6920e3a5d92758cda460d6dc9f918a78ad6d5d092f1c8b5395e6b775356", size = 2380442, upload-time = "2026-11-05T09:12:41.196Z" }, + { url = "https://files.pythonhosted.org/packages/aa/ba/921d90c9d8ddfa653a35a92f2bbdcd650a9493f5c43f39cdfe4c56659cfa/pydantic_core-2.50.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:ad92d255a165cde5f9882ff69699eaf5495e0a1f32e97566bbbb80f11e46781f", size = 2457747, upload-time = "2026-11-05T09:12:42.723Z" }, + { url = "https://files.pythonhosted.org/packages/2b/c0/1c8f2c8f1b03d3fe2fdd7962df8f5a744fe48c90b4c49615e4eb77d04141/pydantic_core-2.50.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:fb2bb5b557080da398b866408117d98fe9731a12334afd0cdff221b458cdc5dc", size = 2260946, upload-time = "2026-11-05T09:12:44.185Z" }, + { url = "https://files.pythonhosted.org/packages/07/ab/5b78a78f0c0f11c8b54fac214ed49cbb4795c34881aa5e5a15715917936f/pydantic_core-2.50.4-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:92f8f63df729061bb14558ed740e7a222f6e2aa6c2e6a5bcfb4e706676562049", size = 2261921, upload-time = "2026-11-05T09:12:45.706Z" }, + { url = "https://files.pythonhosted.org/packages/b3/e8/dd5d154cf3401f836d8754fdc1b82ecadd37944e4355d855e5b54c7d8ae5/pydantic_core-2.50.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:2a60ec2a57ac3ef3767e526e9bf706ec75aa3d79c4ea134d9d4fcf7c62a297a7", size = 2298475, upload-time = "2026-11-05T09:12:47.183Z" }, + { url = "https://files.pythonhosted.org/packages/b7/49/af059d9c4483cba168b17e5f84f1090a3e4547a02fc7698ebc231d48298a/pydantic_core-2.50.4-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:a2f8716344bbbd10443391be0b1f2003b34949e3c4e6883005c2bc498ab6b64b", size = 2473226, upload-time = "2026-11-05T09:12:48.785Z" }, + { url = "https://files.pythonhosted.org/packages/71/ba/4e8cc3064e8bc2ea272cf80dfc57fa4e455f6835c1def21609a9b4f94135/pydantic_core-2.50.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:b300a30304c4c6aeab03ed06809819d9eceacdd58441d3c7dffe41edfd006091", size = 2498764, upload-time = "2026-11-05T09:12:50.316Z" }, + { url = "https://files.pythonhosted.org/packages/bf/96/0878499cfa88eb0b07762b488d3cc1b64cb156a4905db99a0d12096b2e17/pydantic_core-2.50.4-cp313-cp313-win32.whl", hash = "sha256:ef8a9ddb2e2a4eae4abb72dc0710eca6c2726779b0664bd10c3ce9fcfaed8c4e", size = 2119158, upload-time = "2026-11-05T09:12:51.834Z" }, + { url = "https://files.pythonhosted.org/packages/e7/e0/95b651213e79ffe0cbee855590bf5cfdf8e3a0d90a7fc73a080e63f7cc38/pydantic_core-2.50.4-cp313-cp313-win_amd64.whl", hash = "sha256:4c29b8f2d6417069bb1f257e6b9113f5d64dc2f554cc200ea90b4fe2c5cdb733", size = 2262887, upload-time = "2026-11-05T09:12:53.282Z" }, + { url = "https://files.pythonhosted.org/packages/08/d3/c3801dc75844a0b13d000bd575bf1b3b3a8aca9f63d19e1809f69c9c5121/pydantic_core-2.50.4-cp313-cp313-win_arm64.whl", hash = "sha256:a0c5210d038418a115e7cf8706bfa611bd14add2f5787274dba45aadca3155e0", size = 2167878, upload-time = "2026-11-05T09:12:54.677Z" }, + { url = "https://files.pythonhosted.org/packages/ee/ed/c9a4982ac3bbc78f27498d9efb85b3dabd739a1724db53c35cc4c018e1de/pydantic_core-2.50.4-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:5c074454dc6d4f6f4ba6561a56bf33a14db7651d882a5a5321ba3ae8868e082d", size = 2236841, upload-time = "2026-11-05T09:12:56.111Z" }, + { url = "https://files.pythonhosted.org/packages/56/32/92c174c17bfc5fc52d0c064e6a7969a727731e25829ede752fba8bacce0f/pydantic_core-2.50.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:a4bb174bd65f795c39ad6642d9d5bdc43351b306b7d0a654ab0d0abb38be245f", size = 2108348, upload-time = "2026-11-05T09:12:57.638Z" }, + { url = "https://files.pythonhosted.org/packages/cb/cb/9f637d424a04d3edce7dd527da941950cce05a74b025eef3d54427b86c8e/pydantic_core-2.50.4-cp314-cp314-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:0ec20aca2b067369913716847f7dfe5f4dddf16a46965b7a70bbad5defaaba86", size = 2261331, upload-time = "2026-11-05T09:12:59.154Z" }, + { url = "https://files.pythonhosted.org/packages/91/ff/1117a3cccabb67305bd98d992a84eaf275939a9a043b4f14126ed7252e4f/pydantic_core-2.50.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:70dbc9f83c41f37a4faa62dae5203853847223a891da446f48ef2efcfd5df806", size = 2128667, upload-time = "2026-11-05T09:13:00.614Z" }, + { url = "https://files.pythonhosted.org/packages/93/45/6de1b4a6e8c415cd547f90d1408a711e7975116423e3eb3046061c62d7c7/pydantic_core-2.50.4-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:3de6c2a4df2af0ac9ab4dc1488746fe8b1a90e27955d870d9edda3187d20092b", size = 2198183, upload-time = "2026-11-05T09:13:02.259Z" }, + { url = "https://files.pythonhosted.org/packages/d0/bd/c6e64c315d35cc0783a0ea033a3dca062bc368905d0217eab6f6f63007de/pydantic_core-2.50.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:3a48a5254d15a0ad050318bfc7a9566d4ec740118187e8f303e47a6840287eb7", size = 2386279, upload-time = "2026-11-05T09:13:03.988Z" }, + { url = "https://files.pythonhosted.org/packages/33/ab/0d56280c89d3841381e9c699c3fa80e3dd3288edf5e7fe4d149136835dca/pydantic_core-2.50.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:0af56dbf8822ba9f4efcbbfdc15478f8b6fb08f1609860cb50aa2cc8476b3c34", size = 2464343, upload-time = "2026-11-05T09:13:05.98Z" }, + { url = "https://files.pythonhosted.org/packages/56/9c/621ad8f88590a92a086b1168dce09369d9c5e079e2e635e6646d248af55b/pydantic_core-2.50.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f1d62fb172db35c6478c9323da34ff37d1f3d37d7d44337a9d94ba8c583e5730", size = 2265388, upload-time = "2026-11-05T09:13:07.808Z" }, + { url = "https://files.pythonhosted.org/packages/f3/7b/cef68a667bf29b86e293a80a601d488a84c8f45508915ad6201fcfe1a798/pydantic_core-2.50.4-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:5c1013647be741647895c102831dcf79c34209662dbb683df9efb864417ed7d5", size = 2267012, upload-time = "2026-11-05T09:13:09.273Z" }, + { url = "https://files.pythonhosted.org/packages/4b/9f/3ae4d163d8feda2b52de88b5cd96b1c40f79d11503003b061136d2ece6ab/pydantic_core-2.50.4-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:aeb2e123cbf978a905e9f55155c1b8316fbbfa7cf64d04521fe174bab302d100", size = 2300478, upload-time = "2026-11-05T09:13:10.758Z" }, + { url = "https://files.pythonhosted.org/packages/e8/72/41881d31f6452430ed6792679c5391795910f0a27a6aebd424683e504ed6/pydantic_core-2.50.4-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:523466eba8ee10f7480f3c2057563145978011c583130d2cc01fb1e7af808e25", size = 2474874, upload-time = "2026-11-05T09:13:12.188Z" }, + { url = "https://files.pythonhosted.org/packages/05/ef/099874dd6d5ca1e49987dea87eecc05610183249450b1fff883d87f1e8eb/pydantic_core-2.50.4-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:c9e70012926e97069cdd09221861aff412aa94e4cac2e019055cdb79485b150c", size = 2502771, upload-time = "2026-11-05T09:13:13.981Z" }, + { url = "https://files.pythonhosted.org/packages/c6/07/a7d8615b8677bf69e24666bbce431299850c95a7b084649342582a1c3210/pydantic_core-2.50.4-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:e6da138a1ecc1341c8b788a5ee822670b03788e1f5decf7af9d461de6e508b8e", size = 1496509, upload-time = "2026-11-05T09:13:15.704Z" }, + { url = "https://files.pythonhosted.org/packages/ab/71/fdf2c25c3a4f89968263c1d896c933809ca8d2fb13443626648a17b2e296/pydantic_core-2.50.4-cp314-cp314-win32.whl", hash = "sha256:13b6dd62b5279f5b9d72f3bf918a35443ee8bd549241d9dc52d79a2c3b6d7016", size = 2122015, upload-time = "2026-11-05T09:13:17.09Z" }, + { url = "https://files.pythonhosted.org/packages/3a/9f/3554f0148b01ddaa5e678bf5fbce4679873534e5c0985cdf6c59c41dc9a9/pydantic_core-2.50.4-cp314-cp314-win_amd64.whl", hash = "sha256:b0cdb655fbd1562c2dfc9986f9103a106f7058cd0915afc6e656d4b1d73f3387", size = 2265109, upload-time = "2026-11-05T09:13:18.702Z" }, + { url = "https://files.pythonhosted.org/packages/ed/3c/196ef237d9ec5cca5ea9b773911dee1a387b9b1d4bfea05625b3e191a338/pydantic_core-2.50.4-cp314-cp314-win_arm64.whl", hash = "sha256:df1c174796cd63eb6b139f7daf783affe1f3ed659605850e843b24764c21bfc5", size = 2165745, upload-time = "2026-11-05T09:13:20.245Z" }, + { url = "https://files.pythonhosted.org/packages/36/12/0ee82a41a3995f0b531cf14e0b823dc2365ba4a22330670fccaa72753f12/pydantic_core-2.50.4-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:edbca8789fd10f0de534b660a6b4c71f1fd18039679c918dad392ab044bb37e4", size = 2223917, upload-time = "2026-11-05T09:13:21.623Z" }, + { url = "https://files.pythonhosted.org/packages/90/2c/592f8404abbcc65a70e6a802d1dc8f11412af44913e5146cf5c345370074/pydantic_core-2.50.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:33b21f69540a12c2053cd1d95766d8bd9667a3897f7c712a642de8aa37eb0865", size = 2087372, upload-time = "2026-11-05T09:13:23.16Z" }, + { url = "https://files.pythonhosted.org/packages/ea/1d/c7111757c84b5b8c19b1e39ceb5e131e6e48e14169ec6004e0f8f28f43f3/pydantic_core-2.50.4-cp314-cp314t-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:ffb616d8d55965839670301dc3bae3abacff560a7e137a89056058a8a9da4d96", size = 2275190, upload-time = "2026-11-05T09:13:24.634Z" }, + { url = "https://files.pythonhosted.org/packages/3d/ae/6c49cc9b8e66e61adee782d1763894bf64a357cddae82f725059b85bdc98/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6c5687b59b6ba0f663c4f2f15470f68507d6b45ccd3a19ee6d224f95cbee70d8", size = 2110343, upload-time = "2026-11-05T09:13:26.168Z" }, + { url = "https://files.pythonhosted.org/packages/ed/39/0ee5261d1daa9ad526371181c13696add0565251b2823f6e00a9a9af397d/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:c733087ecf7dde06b1d071679bfd5f3ba03266ba77814c1c7253bc48c9adedd9", size = 2207887, upload-time = "2026-11-05T09:13:27.681Z" }, + { url = "https://files.pythonhosted.org/packages/ac/b5/a0652c0e99590107e111088b6d059044380a787da9ffdd0b458ab4cd9453/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:94733cb447c37b0ce6f71b39ca1288d5f966a084023a5617b4cc35a852586859", size = 2404171, upload-time = "2026-11-05T09:13:29.864Z" }, + { url = "https://files.pythonhosted.org/packages/a3/85/d49f0b8e09a0ffc40dcefb604f9e6020e0d61b51a5f64a504f382fa84c39/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b26f39a5be3cd91a2035818be3d0ffdf5282c3e1f5f53d3b80b7024021acee52", size = 2466049, upload-time = "2026-11-05T09:13:31.658Z" }, + { url = "https://files.pythonhosted.org/packages/e6/76/f2b04d7c53edfd8136053c812ea49914fbf4091196cb7baf9ea326fa2ff8/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c856e439a9d54d514e81a7131229ba151cdf81df7c408e0f6c89340e5003dfe2", size = 2262062, upload-time = "2026-11-05T09:13:33.806Z" }, + { url = "https://files.pythonhosted.org/packages/24/60/016f14cea883adc33df90b8df220df934de49ded9640f45c8e92bb298494/pydantic_core-2.50.4-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:cbf0777d54672990b10cb8ca9b0523499e182d7e2ea39f86b138519a902aa601", size = 2263713, upload-time = "2026-11-05T09:13:35.337Z" }, + { url = "https://files.pythonhosted.org/packages/f1/3f/b05828e978512973e7e215bab69e65e70d223d6309a17bf48084a50692f4/pydantic_core-2.50.4-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:edc17549ab592e33cfcaf285f047bb75fcd98f608aa9309af1187fd736ce9641", size = 2305044, upload-time = "2026-11-05T09:13:37.043Z" }, + { url = "https://files.pythonhosted.org/packages/91/c1/fca6c5f623ac45ba284713c614b30173aa0794899a0a457f866fa6f5e886/pydantic_core-2.50.4-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:23a9ba564b2db709ff16eca990992ba95a19069972b34bff87c81d4b473cd755", size = 2483506, upload-time = "2026-11-05T09:13:40.524Z" }, + { url = "https://files.pythonhosted.org/packages/94/c2/ec41f68d1208e53e1a73ead940c050c4316bbb555ba42676a5e949fd529e/pydantic_core-2.50.4-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:41f4f8ae714e4fea1d635880f8a1af715ecf080eed4d13c5b04a0f3210f9c61a", size = 2512832, upload-time = "2026-11-05T09:13:43.361Z" }, + { url = "https://files.pythonhosted.org/packages/43/22/58583b86309f70cce854e0e77c412839a56ac6c682d6060f5794afeff315/pydantic_core-2.50.4-cp314-cp314t-win32.whl", hash = "sha256:601fce6cea9ddeaa85329e12e7f351def38d233075f42a3012b9c48071b02941", size = 2101977, upload-time = "2026-11-05T09:13:45.735Z" }, + { url = "https://files.pythonhosted.org/packages/6b/28/193bc0994f7fe15f2874c1dfe2f3bc7872aed8283ffda2cf05fb9a5a06b4/pydantic_core-2.50.4-cp314-cp314t-win_amd64.whl", hash = "sha256:22e874666bdbd96d6bf629d32cd8ab376fedf1fd62585b52a42b9fa9fa6c20b6", size = 2240461, upload-time = "2026-11-05T09:13:48.38Z" }, + { url = "https://files.pythonhosted.org/packages/00/ed/5615cfdd5620a4926440eb1a2b73db0dc895824ba565ccaa8d9eb3a8e974/pydantic_core-2.50.4-cp314-cp314t-win_arm64.whl", hash = "sha256:71395a43da5584bb70556f380387e15f845c0dcf76373c1afbfa0025737576ac", size = 2168505, upload-time = "2026-11-05T09:13:50.762Z" }, + { url = "https://files.pythonhosted.org/packages/6d/9f/e6673535165d965a11c1d5339f53995f90234019827eaecb41a57e6e463d/pydantic_core-2.50.4-cp315-cp315-macosx_10_12_x86_64.whl", hash = "sha256:7ac2769a7ddd661e07e26c12220adc31b17014c48234b2a5a88993b8d4109e09", size = 2241950, upload-time = "2026-11-05T09:13:53.055Z" }, + { url = "https://files.pythonhosted.org/packages/6f/02/65951efadbf7826e6a270843f97e3da2ef726de2b6d9cd7c5dfa4c48807e/pydantic_core-2.50.4-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:930ad463d3fb7a340d323bcc496ec32dae469ec9974c29ff569f19806b6b03b4", size = 2112412, upload-time = "2026-11-05T09:13:55.309Z" }, + { url = "https://files.pythonhosted.org/packages/c9/d3/4fb6e2e4a9e4951f1e05b198366ed5330e0874e83d52077e8b985350fe0e/pydantic_core-2.50.4-cp315-cp315-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:b867f9fd183d76977f810c626d539265183c25b2284762893a31e8d6cacc81c0", size = 2263220, upload-time = "2026-11-05T09:13:57.555Z" }, + { url = "https://files.pythonhosted.org/packages/63/83/42e70436c523357b49393b73f161f2741acf36003c8efd2f941d2be56bae/pydantic_core-2.50.4-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:49eb1241a969a5994db6880c18c012b6cbe2340343d8f529721571806583e500", size = 2134716, upload-time = "2026-11-05T09:13:59.413Z" }, + { url = "https://files.pythonhosted.org/packages/36/66/ed9b87f4751fd07e472c62cfe151f575abdf4c452fab943d35ba8efdc6c4/pydantic_core-2.50.4-cp315-cp315-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:477af785d1846e4e96bf56983b92ea7553aaeccdeb8acdaa55c7cee9eda0ae32", size = 2201901, upload-time = "2026-11-05T09:14:01.472Z" }, + { url = "https://files.pythonhosted.org/packages/2b/21/ff2e6ac7202b6d326e9f007c6082f6e6f3aaa063790ea2a355bdc985addc/pydantic_core-2.50.4-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:29358a8ca74e7d81158d14e2b10c904bd18773293ae3788716c0626fe0342347", size = 2389670, upload-time = "2026-11-05T09:14:03.431Z" }, + { url = "https://files.pythonhosted.org/packages/b9/34/e9348bc13d549641791a51843ed140fbb311d9066628e27477343412d5ad/pydantic_core-2.50.4-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:300753f71c73302e218124baf995f00058e085cd01869bd9610bcbd0bd4500c1", size = 2468951, upload-time = "2026-11-05T09:14:05.028Z" }, + { url = "https://files.pythonhosted.org/packages/ac/5e/145a02bf2b9f66981108caf6cc9e78917e31e4caca14d1e3ccd3ff2c7293/pydantic_core-2.50.4-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:26cb012c4b8ca9f847bd0ac15978bd3d0f55b050bfbe6c47355edfc7e945029b", size = 2272957, upload-time = "2026-11-05T09:14:06.587Z" }, + { url = "https://files.pythonhosted.org/packages/fd/38/b71c5b245e923f6cf144e948ed2a9d6b7fb97d8905784db8d860f5176b8b/pydantic_core-2.50.4-cp315-cp315-manylinux_2_31_riscv64.whl", hash = "sha256:9be1cfe715ecaa060ffd5d599ef410b94ef2697a0eed4cee562f788a2aa2175b", size = 2275028, upload-time = "2026-11-05T09:14:08.219Z" }, + { url = "https://files.pythonhosted.org/packages/ba/71/2504dacdc5cd3ea3ec5e68c9b6e097c979500bcff220b97046cc8ea3c1ad/pydantic_core-2.50.4-cp315-cp315-musllinux_1_1_aarch64.whl", hash = "sha256:c81e35862aced259177a537ce1a6264c3a97bae1ced184ca9dc10ea754563688", size = 2305447, upload-time = "2026-11-05T09:14:09.795Z" }, + { url = "https://files.pythonhosted.org/packages/2c/90/904233a6c148bcac9f30bb96a2761e5fb52682d0d6de31a40c74a3714ceb/pydantic_core-2.50.4-cp315-cp315-musllinux_1_1_armv7l.whl", hash = "sha256:b2f2d13239487cecaae98c9f4d5904ad0737643cdf8873c88ec6a78b12214f20", size = 2477852, upload-time = "2026-11-05T09:14:11.443Z" }, + { url = "https://files.pythonhosted.org/packages/72/33/1cbdcbf343ca23b507e967b21dddc4c8bf17a74c8b5cad59228c85ba4efc/pydantic_core-2.50.4-cp315-cp315-musllinux_1_1_x86_64.whl", hash = "sha256:e6b4b08d09054310a4dc389fa61ee22a7a5a292cb23ab8a985136ca8828bf924", size = 2506352, upload-time = "2026-11-05T09:14:13.165Z" }, + { url = "https://files.pythonhosted.org/packages/91/24/3ad9ea0876e6624c90967e5f1446e751b275cfdfaaf798a0d8e0b30025bc/pydantic_core-2.50.4-cp315-cp315-win32.whl", hash = "sha256:6619d49a89a15cd04334f76fec530c155923bfc60da74ff5d815a52629e1aa6c", size = 2127780, upload-time = "2026-11-05T09:14:17.52Z" }, + { url = "https://files.pythonhosted.org/packages/c0/3c/0582532b90a12492471977bdbca1317eca5144f6342ea581d2cee73ccd35/pydantic_core-2.50.4-cp315-cp315-win_amd64.whl", hash = "sha256:e5bd109d095aaae989a0463d5ef0fcc43e9ddd5de125e656d3c119a79e466380", size = 2270596, upload-time = "2026-11-05T09:14:20.955Z" }, + { url = "https://files.pythonhosted.org/packages/6c/50/967cfe4f7043a993c0c80cd3563c598b5281d2276aa775d0f6ff7f714271/pydantic_core-2.50.4-cp315-cp315-win_arm64.whl", hash = "sha256:6118e5a5550e36582e19bac1a403711a748f9f18251b054c326d3db02aaa7a18", size = 2170880, upload-time = "2026-11-05T09:14:24.822Z" }, + { url = "https://files.pythonhosted.org/packages/9e/71/3ec5bd8a82f792482f16d79fdbe8ce85aa71bf7147e556c5fc5f8546818d/pydantic_core-2.50.4-cp315-cp315t-macosx_10_12_x86_64.whl", hash = "sha256:d8201c9f9035520cdcc7dcad383b039ec8123969b87e01cf27c3dd883c02313b", size = 2233053, upload-time = "2026-11-05T09:14:27.942Z" }, + { url = "https://files.pythonhosted.org/packages/6e/2e/614dc37aedf8e9f811c1f2eedaf8eb09a7c196e2d137fe82bcc9d5662ca2/pydantic_core-2.50.4-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:1de7be9a66fc8536770481ab64a05aae5067c725f2b29a09543af00e6a417b97", size = 2090776, upload-time = "2026-11-05T09:14:30.281Z" }, + { url = "https://files.pythonhosted.org/packages/f9/14/aefc14e3e05013070ee959fc0b8703f6860a2776ed6e75b9c748f61aced0/pydantic_core-2.50.4-cp315-cp315t-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:789a6453e5ffd18a7ab6b8c3a0dd8403053829197ec258ecb90c604c21ffcc99", size = 2272481, upload-time = "2026-11-05T09:14:32.578Z" }, + { url = "https://files.pythonhosted.org/packages/13/c9/d56999aa7236dc9303091db2b1ef7303f0b022baf25ebf33cd200c0cb933/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6348ad12fa741bcc9c2f173e99fbf27cbc038826d8c31a4a7d836eca27878ba2", size = 2113069, upload-time = "2026-11-05T09:14:34.69Z" }, + { url = "https://files.pythonhosted.org/packages/b7/d5/a62da9e72f272f198f6118c5457332bbd4b9fdc4b77858448120569756de/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:d49127f137f871cde3c5650af33bbbdcee02679dae76e020902fa106f522b8ae", size = 2202754, upload-time = "2026-11-05T09:14:36.49Z" }, + { url = "https://files.pythonhosted.org/packages/37/4a/e7f21577f96e42ac3082cd014df398c1c913d482afac1c8ef17b9e039198/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:2f5cc5bcb94063fbbdfd285a2b302da34af07491337c10bb35de1d5220fa1583", size = 2411472, upload-time = "2026-11-05T09:14:38.63Z" }, + { url = "https://files.pythonhosted.org/packages/38/ad/c57c5e13bbfd3404ec1af519764aadbc52ee01e39f9f9ae9d28317f982f2/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b99bed995ed7c41515c11fe2beb86f8a6cc298e5537cae2f736de2f982f74ef0", size = 2475330, upload-time = "2026-11-05T09:14:40.519Z" }, + { url = "https://files.pythonhosted.org/packages/6e/63/65cf0e1f1fd8cfaafee3c005712b8020e063b0f3e3571493ea68db5ec44f/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:faa4e96385c820ce9d7f7a623486e23d4134ae3c9ba2071e44e0ab5a5a5002c4", size = 2265718, upload-time = "2026-11-05T09:14:42.379Z" }, + { url = "https://files.pythonhosted.org/packages/72/5d/fd9fdec9b25e2ef1f788970a84f749f0e28f166573c87654fd5387d8e5ce/pydantic_core-2.50.4-cp315-cp315t-manylinux_2_31_riscv64.whl", hash = "sha256:d6a166978f22f10cb91413f70519861605219346decf65bc79008f9257c94afe", size = 2273454, upload-time = "2026-11-05T09:14:44.286Z" }, + { url = "https://files.pythonhosted.org/packages/34/8c/19705c6d5eb72ff8c25006df8a375da7466176a5968781789e5415384f65/pydantic_core-2.50.4-cp315-cp315t-musllinux_1_1_aarch64.whl", hash = "sha256:a70d5effebd81ebd8e15a8aabdc7980832367b2b00c36543bac378977004cc80", size = 2314862, upload-time = "2026-11-05T09:14:45.97Z" }, + { url = "https://files.pythonhosted.org/packages/b8/fb/acefa27031aba2646b0d3026c4a1602e526489d39395ab17bc47f03234e3/pydantic_core-2.50.4-cp315-cp315t-musllinux_1_1_armv7l.whl", hash = "sha256:f8fd23653a252cefabea11cd041efd7b80bdf403e43a36dea53f9cb0aaa21f0f", size = 2479073, upload-time = "2026-11-05T09:14:47.526Z" }, + { url = "https://files.pythonhosted.org/packages/ef/e1/db08fa1e5edf1779fa0612f8d09f9030bdc513f593687c883cb781b86caa/pydantic_core-2.50.4-cp315-cp315t-musllinux_1_1_x86_64.whl", hash = "sha256:7646353a5a7c553c04167aca628e2550b538f492765b03ccf34321a560acc43c", size = 2521328, upload-time = "2026-11-05T09:14:49.042Z" }, + { url = "https://files.pythonhosted.org/packages/0d/51/bf1ec5b96c076d8d514b08f3bcffb3397df7a0fcc729eb960838a8bbe27f/pydantic_core-2.50.4-cp315-cp315t-win32.whl", hash = "sha256:65376dbe1ab4dbc768ca2b72b7c13993562c035f5925fd3bc7ff9c8c585c515d", size = 2107629, upload-time = "2026-11-05T09:14:50.891Z" }, + { url = "https://files.pythonhosted.org/packages/18/32/43d5db1824ec2314f737ff8d9962ff59954a74616d8656a8cc78790e45f1/pydantic_core-2.50.4-cp315-cp315t-win_amd64.whl", hash = "sha256:f08ee8248aad2d054e5bc4c73554d4505464698f6d754f16198dbc5764e9821d", size = 2244906, upload-time = "2026-11-05T09:14:53.056Z" }, + { url = "https://files.pythonhosted.org/packages/3a/c0/38c505004969c4641c3a077a8e72e354f02d5c06d8f51d7a103699704772/pydantic_core-2.50.4-cp315-cp315t-win_arm64.whl", hash = "sha256:da779ae50b46f3f7d1e1b5f362fdc0ad376a49fd55f6f3122dc2b6149936cdf7", size = 2179018, upload-time = "2026-11-05T09:14:54.448Z" }, + { url = "https://files.pythonhosted.org/packages/9a/18/2f6a25e9104d5af713d16671711927601da1f0db74e785be67bd590385c9/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:c04e9d920e2674f54651fd260a15c5d2843526c73d5242ee4311325ddc9573b3", size = 2212591, upload-time = "2026-11-05T09:14:56.262Z" }, + { url = "https://files.pythonhosted.org/packages/4c/1b/ba8b721af10a7659e7fbbef320ff8eb55462557a72607858af5a9bd22cb1/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:5bc1811ef2b4d4ba63e8e452f6e332b6374bd1d2cbbfdf66826c8cb1f71dd10d", size = 2048167, upload-time = "2026-11-05T09:14:57.681Z" }, + { url = "https://files.pythonhosted.org/packages/48/42/3f8638e7d90bdd9a7c7f3e5084723af59e7f43f15a292e242d35624073ce/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0b059a7968b1911be5a2d9a8234827ab0bef9d1e465d4b42da525894143550e8", size = 2119548, upload-time = "2026-11-05T09:14:59.317Z" }, + { url = "https://files.pythonhosted.org/packages/e0/8d/4bfbacaf191f7939893d165e18eb301731fa3366c59a6e57336c4f168fbd/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:bee28aab5a580eec673f7b68dfa8dece3dd37bd207ef8d22fafe23a8e9837296", size = 2279952, upload-time = "2026-11-05T09:15:00.907Z" }, + { url = "https://files.pythonhosted.org/packages/9e/3a/d405a50e02ea81cd95e93fc97f43d351eeaa1707c28aa6fb58a9f1c1efa9/pydantic_core-2.50.4-graalpy313-graalpy253_313_native-macosx_11_0_arm64.whl", hash = "sha256:71e03d2ea1a221d020cfc5b6cc8bbbedef23a06704c70fcf4d0afb42965b22d1", size = 2049324, upload-time = "2026-11-05T09:15:02.379Z" }, + { url = "https://files.pythonhosted.org/packages/8f/3b/03e7992115e17cae4131ecd71aadb8fd5e4a04cc2aead72c3c27e9b453d1/pydantic_core-2.50.4-graalpy313-graalpy253_313_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:09450778e3ab58d3f565899fcfbf6c82926e31af29e28e799d1d50941316e0cb", size = 2119802, upload-time = "2026-11-05T09:15:03.901Z" }, + { url = "https://files.pythonhosted.org/packages/e3/d5/b76fc647e473377ca6e693c21549ee3a4a7677e4962c28ae4659337c5114/pydantic_core-2.50.4-graalpy313-graalpy253_313_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4eb15be588407148ef5937dc8d9256a71f6b115e6cddadb7aa20b6ee384680dc", size = 2280639, upload-time = "2026-11-05T09:15:05.374Z" }, + { url = "https://files.pythonhosted.org/packages/d8/18/3ca5b3b8ce7a540305e6856d013e9c6b9c0fef93258fef6038db0beb233a/pydantic_core-2.50.4-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:39f489ce31272073e6e146f6781690f9c1ee8c126836e6403361ef91154d89fe", size = 2166960, upload-time = "2026-11-05T09:15:06.902Z" }, + { url = "https://files.pythonhosted.org/packages/a3/60/65d725001bffcde0170f6d37ae8bccce715e5311122eb6127f698115957e/pydantic_core-2.50.4-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:5b26e5f1793b96cdc60242bf38da86ff24a27a708aa396214cac9b534bf571c7", size = 2085636, upload-time = "2026-11-05T09:15:08.395Z" }, + { url = "https://files.pythonhosted.org/packages/ac/12/934cf1d44a3fee3c47231d4690dddee19264150c3aa59a3ddf66fa43454d/pydantic_core-2.50.4-pp311-pypy311_pp73-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:7210398a1607ad607dc73196e575b3148b00a333cbb602ddbe1b60ba54554f43", size = 2284621, upload-time = "2026-11-05T09:15:09.82Z" }, + { url = "https://files.pythonhosted.org/packages/c4/91/52248eee98d76f8d9239166d24928f805292df16729109f4f189cdb59be4/pydantic_core-2.50.4-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:2f42584e5785385f681163a42506cab0d51295e17599a648396c52a7046c1372", size = 2277673, upload-time = "2026-11-05T09:15:11.236Z" }, + { url = "https://files.pythonhosted.org/packages/9f/89/900a7970ef19843aa79522a95b461e9c365b7fedd7ee80ef28a84dae9a41/pydantic_core-2.50.4-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:2039e323acee9abfec1fb5f661776e8965fe5928f3b7f8431900a774cba5c317", size = 2297354, upload-time = "2026-11-05T09:15:12.798Z" }, + { url = "https://files.pythonhosted.org/packages/de/ec/053d829437f70070cdd7116a0257cc0da651103328ff1e9e82954c45efd6/pydantic_core-2.50.4-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:71ade6d2e445839350d589ff99bbddfde16f3f32db28da5c894a09f99c8b2a03", size = 2469913, upload-time = "2026-11-05T09:15:14.319Z" }, + { url = "https://files.pythonhosted.org/packages/80/af/207c821cb0813e16d630660e0073491e3ab07370efaa6fa0b8b10fffb7b6/pydantic_core-2.50.4-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:d7d406709ae924cf0b08b8282ca2f0e1c90526911d93bc040557cbc83b74c55f", size = 2503746, upload-time = "2026-11-05T09:15:15.736Z" }, + { url = "https://files.pythonhosted.org/packages/e7/ca/8a053f24e22d8150349cabaecb2f35c89dcf07fbaadb5e48295184dd0e5b/pydantic_core-2.50.4-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:7472c39480ccc11dda69a196d1b7c7a6b48eb6594b77f05d945599d3e47f731c", size = 2333540, upload-time = "2026-11-05T09:15:17.883Z" }, + { url = "https://files.pythonhosted.org/packages/ac/9d/41b374c62cdb87f84081e2ef2963a115eacc6284a26dbc96bb83568e83ec/pydantic_core-2.50.4-pp311-pypy311_pp80-macosx_10_12_x86_64.whl", hash = "sha256:b67d38e8bb0ade7e6e84575e4bb153fab35b122458077273aeb08fdf12be9d2c", size = 2166962, upload-time = "2026-11-05T09:15:20.276Z" }, + { url = "https://files.pythonhosted.org/packages/9a/4f/51ef440ee346d4388a2c4a3ac4b271fcc7b1d3ff68be8da2ed2be4d488b0/pydantic_core-2.50.4-pp311-pypy311_pp80-macosx_11_0_arm64.whl", hash = "sha256:4eda7e3fdef382b7d4492745988a5baaf6953923a337f8b9dde5f76fa8afde20", size = 2085634, upload-time = "2026-11-05T09:15:21.953Z" }, + { url = "https://files.pythonhosted.org/packages/4b/5f/c9ed62b96beb9050db221d29e81856b6e28f277db601f8b0c3a08f8cf913/pydantic_core-2.50.4-pp311-pypy311_pp80-manylinux_2_28_x86_64.whl", hash = "sha256:474f7e598c7902165662a5d5160d3fce31037890a2975a9871ebf7c05862300b", size = 2277804, upload-time = "2026-11-05T09:15:23.836Z" }, + { url = "https://files.pythonhosted.org/packages/63/bd/b912a5e251ef10ed7be5e543a2bfbeebb0c79bf6302bee786f8dc3bf4341/pydantic_core-2.50.4-pp311-pypy311_pp80-win_amd64.whl", hash = "sha256:3e0b395648c6cb871bceb2906907f255dc876ec425f2d5b024e129985cea8519", size = 2333539, upload-time = "2026-11-05T09:15:25.354Z" }, +] + +[[package]] +name = "pydantic-settings" +version = "2.16.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pydantic" }, + { name = "python-dotenv" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d0/31/21d21e0e38a8f5f7a7f0cde22820117b6d17d6bc36f348129527f915d7f4/pydantic_settings-2.16.2.tar.gz", hash = "sha256:3dc08ffabed2bbd5dc2dd55ead7b78b4e4c5cd776aecd04310db5f1224caaf46", size = 309225, upload-time = "2026-10-28T11:14:28.066Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/39/88/4131c51ff87b7cd7f82a1194d0c0a2b7ca68c72d9da04c3b7e69ab91a79f/pydantic_settings-2.16.2-py3-none-any.whl", hash = "sha256:8d523e5c129b097686bde019bd6109bff53f4c8c3f63f1ddf9933ffa42e5ab4f", size = 81994, upload-time = "2026-10-28T11:14:26.716Z" }, +] + +[[package]] +name = "pygments" +version = "2.21.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/49/2e/ced460408999b33da6b31b0021b0f37d329e202d4169aeb164493778f25b/pygments-2.21.0.tar.gz", hash = "sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c", size = 5005329, upload-time = "2026-08-17T08:02:48.824Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9", size = 1250147, upload-time = "2026-08-17T08:02:44.912Z" }, +] + +[[package]] +name = "pyjwt" +version = "2.15.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/43/ea/5194e52748b0da83d71e082d75496eaec6e58f419f5e184786ded517e6a9/pyjwt-2.15.1.tar.gz", hash = "sha256:4f259e80cdfb6b3fc18a7de51fd1ef9ec79652f25019bae68975ca2468a34df8", size = 121252, upload-time = "2026-09-28T18:40:42.598Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/50/ca/44de4e75f8aadc457f0634be3b542815078ded46dca30efb960edeecad6e/pyjwt-2.15.1-py3-none-any.whl", hash = "sha256:42d59d631f7768a1028a64c7ff581a9bf7519804daf91fc5b6c56e30eec5e193", size = 33860, upload-time = "2026-09-28T18:40:41.429Z" }, +] + +[package.optional-dependencies] +crypto = [ + { name = "cryptography" }, +] + +[[package]] +name = "pytest" +version = "9.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/79/42/bb4641652e58dedeac2ec51abc1f8cae4fee4ec63899a0999016229a0f2a/pytest-9.2.0.tar.gz", hash = "sha256:97c4f3b1f3c7414aa36465e09b8220f1d03627993bd51b1282e193753c80557b", size = 1797555, upload-time = "2026-10-27T21:30:20.728Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/39/1f5d8c8877a0fa327db959c19341d4be61660de1ab6b7391f9eb805bcd67/pytest-9.2.0-py3-none-any.whl", hash = "sha256:07acdcf88ec174f907dc01af70bf52d49b014bbab03faeeade31c96b18c2e588", size = 411776, upload-time = "2026-10-27T21:30:19.131Z" }, +] + +[[package]] +name = "python-dateutil" +version = "4.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "tzdata" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/18/39/b3927f3616f6223832f9b760e4208e8a7c7e1dea2b4d9ad7d32a5d214c3a/python_dateutil-4.0.0.tar.gz", hash = "sha256:d7295ff14fdc0f92f662100bfb6c551d160ca090f2939f1ec5b9794265c03f06", size = 250419, upload-time = "2026-11-01T07:02:42.426Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2f/a9/52b89563d154433d79b51ed1eb4842bf7334cb2696891a7fe135618853d7/python_dateutil-4.0.0-py3-none-any.whl", hash = "sha256:a5e246f79eb80475e691bf93862cead98decd8a498cf53ba0516fcdc0f50dc1c", size = 92853, upload-time = "2026-11-01T07:02:40.797Z" }, +] + +[[package]] +name = "python-dotenv" +version = "1.2.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/74/26/2fbeedb218a787a5eea551c7532cac4e009f83d689dd2faa0d0353473f86/python_dotenv-1.2.4.tar.gz", hash = "sha256:f0d53e69935a851c0dcc78f3ab7aaccd8cabef0b92382b576b824212902873c0", size = 60824, upload-time = "2026-10-01T05:36:10Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/60/d1/38f3a3405989a89ac18390803e70c6ad7c7760da4f9b83cbeca0c44a0c72/python_dotenv-1.2.4-py3-none-any.whl", hash = "sha256:42269a8a5b3fd54ffa6f3d84b18abed50064717576b4ecf03dc4a55d8aa04fdc", size = 23266, upload-time = "2026-10-01T05:36:08.633Z" }, +] + +[[package]] +name = "python-multipart" +version = "0.0.33" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9f/b7/15b905f6142a9a8a68f66900788da1a32e4d4254452783b37ad1eccb0506/python_multipart-0.0.33.tar.gz", hash = "sha256:b8112424a6abd162ec08d390565dd113ad699f2fe6fef3c987b8bbcbfe9e390d", size = 50499, upload-time = "2026-10-31T14:23:47.461Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/dd/1b/6b1b4164ec734cac911460ab599bfbe46afedd42c5c9627fe4235942c314/python_multipart-0.0.33-py3-none-any.whl", hash = "sha256:8f16c07b36add9da6b2ee87d3efcaf0a45a6de9c3d0a5dd94e9ccf7675a7bc45", size = 32253, upload-time = "2026-10-31T14:23:46.33Z" }, +] + +[[package]] +name = "pywin32" +version = "312" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1f/f5/10a6e845a00fc5e7afd0a988b744f403d4d57162a28d160a093c4d9322f0/pywin32-312-cp311-cp311-win32.whl", hash = "sha256:17948aeadbdb091f0ced6ef0841620794e68327b94ee415571c1203594b7215c", size = 6362659, upload-time = "2026-06-04T07:49:21.349Z" }, + { url = "https://files.pythonhosted.org/packages/35/c4/dcd2d62b5944b6d5db53413a5899016ccd57ffcb7278f3f81655d25d2027/pywin32-312-cp311-cp311-win_amd64.whl", hash = "sha256:d11417d84412f859b722fad0841b3614459ed0047f7542d8362e77884f6b6e8a", size = 6928825, upload-time = "2026-06-04T07:49:23.934Z" }, + { url = "https://files.pythonhosted.org/packages/b7/56/3cbb433fe4501cdba2eb9040f56a4e1a8243faa4186b25295564d1a7a79d/pywin32-312-cp311-cp311-win_arm64.whl", hash = "sha256:b2200a054ca6d6625c4842fc56a4976a4b47f96b73dbe5538c3f813a80359f47", size = 6721875, upload-time = "2026-06-04T07:49:26.416Z" }, + { url = "https://files.pythonhosted.org/packages/83/ff/32aa7d2ed0ab12b323aaa64f9b75e6ad4f8fd09f9ccfc28c79414d46838d/pywin32-312-cp312-cp312-win32.whl", hash = "sha256:dab4f65ac9c4e48400a2a0530c46c3c579cd5905ecd11b80692373915269208b", size = 6371877, upload-time = "2026-06-04T07:49:28.836Z" }, + { url = "https://files.pythonhosted.org/packages/03/d9/77040d3b43df3f3be32ea289433d660d2727f5ba327bc73be835127d9d60/pywin32-312-cp312-cp312-win_amd64.whl", hash = "sha256:b457f6d628a47e8a7346ce22acb7e1a46a4a78b52e1d17e1af56871bd19a93bc", size = 6914841, upload-time = "2026-06-04T07:49:31.85Z" }, + { url = "https://files.pythonhosted.org/packages/e3/cc/7b1ec671775756020a0ee7f4feeaf3c568f0ab86bd3900088cf986937a92/pywin32-312-cp312-cp312-win_arm64.whl", hash = "sha256:6017c58e12f6809fbb0555b75df144c2922a9ffd18e4b9b5afa863b6c1a9d950", size = 6727901, upload-time = "2026-06-04T07:49:34.244Z" }, + { url = "https://files.pythonhosted.org/packages/2d/41/12fbfd7f36ed2146d8bc9de96c2741296bf0d490b98508496cff322e274c/pywin32-312-cp313-cp313-win32.whl", hash = "sha256:7a27df850933d16a8eabfbaeb73d52b273e2da667f80d70b01a89d1f6828d02c", size = 6370184, upload-time = "2026-06-04T07:49:36.253Z" }, + { url = "https://files.pythonhosted.org/packages/ba/db/36a78e3403099d31d9746d13fdcde5accc43c1155f375a34d15983a479a7/pywin32-312-cp313-cp313-win_amd64.whl", hash = "sha256:c53e878d15a1c44788082bfe712a905433473aa38f86375b7cf8b45e3acbaaf9", size = 6914298, upload-time = "2026-06-04T07:49:38.876Z" }, + { url = "https://files.pythonhosted.org/packages/84/37/c1697194092b76de9ed47ca124323f02c57ffc8a45c06f88a3d5acaf01eb/pywin32-312-cp313-cp313-win_arm64.whl", hash = "sha256:59aba5d5940842075343a5ddc6b11f1cdf0d1567fe745290359dfbcc7c2eb831", size = 6727640, upload-time = "2026-06-04T07:49:41.083Z" }, + { url = "https://files.pythonhosted.org/packages/fc/2b/1f3cded5822fd49c02f40544cbb5f58c7cfd6b1694869fd476cb6170ee97/pywin32-312-cp314-cp314-win32.whl", hash = "sha256:a77a90fbb6881238d2ca9c6fd797b25817f3768fe78d214a90137ff055a75f5b", size = 6468928, upload-time = "2026-06-04T07:49:43.188Z" }, + { url = "https://files.pythonhosted.org/packages/21/82/3bf86d2e2808902013132e1ce905a7da0da53790f3836c64bf44d55e24f3/pywin32-312-cp314-cp314-win_amd64.whl", hash = "sha256:a4dd3a848290ef724347b19f301045831d8e802fa4464f491b98b1e0a081432e", size = 7024157, upload-time = "2026-06-04T07:49:45.34Z" }, + { url = "https://files.pythonhosted.org/packages/a4/0e/73f6d6800b4f27655abd9e9f6aaeaefcddb2b946e4674efa2bab184a7f7b/pywin32-312-cp314-cp314-win_arm64.whl", hash = "sha256:9fce94568364e0155e6dfb781ac5d95903be8baf28670632beab1b523f300daa", size = 6839598, upload-time = "2026-06-04T07:49:47.613Z" }, + { url = "https://files.pythonhosted.org/packages/eb/61/caa39686032d2ebdd04ff0ab5cbe163126c0066d98e00c9018646e42393b/pywin32-312-cp315-cp315-win32.whl", hash = "sha256:5c1fbe4a937a73ae9297384a3da38518cbc694c68ad8a809b2e19acd350f03ed", size = 6471159, upload-time = "2026-06-04T07:49:50.035Z" }, + { url = "https://files.pythonhosted.org/packages/0f/cd/7e1de64a4a6f69c04214169657ccab0d93a670ea50e35eb8f489d7378249/pywin32-312-cp315-cp315-win_amd64.whl", hash = "sha256:c2f03a0f73f804a13c2735b99392b0cd426bb4f2c4d0178e5ac966a0f21618d5", size = 7025293, upload-time = "2026-06-04T07:49:54.857Z" }, + { url = "https://files.pythonhosted.org/packages/23/ed/4532e9388e65fa16b46776ef47ad631a64eda1631884488af707666350ed/pywin32-312-cp315-cp315-win_arm64.whl", hash = "sha256:a8597d28f267b39074aef51fa593530082b39cbe5a074226096857b1fed2dfb9", size = 6840337, upload-time = "2026-06-04T07:49:57.531Z" }, +] + +[[package]] +name = "pyyaml" +version = "6.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6d/16/a95b6757765b7b031c9374925bb718d55e0a9ba8a1b6a12d25962ea44347/pyyaml-6.0.3-cp311-cp311-macosx_10_13_x86_64.whl", hash = "sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e", size = 185826, upload-time = "2025-09-25T21:31:58.655Z" }, + { url = "https://files.pythonhosted.org/packages/16/19/13de8e4377ed53079ee996e1ab0a9c33ec2faf808a4647b7b4c0d46dd239/pyyaml-6.0.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824", size = 175577, upload-time = "2025-09-25T21:32:00.088Z" }, + { url = "https://files.pythonhosted.org/packages/0c/62/d2eb46264d4b157dae1275b573017abec435397aa59cbcdab6fc978a8af4/pyyaml-6.0.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c", size = 775556, upload-time = "2025-09-25T21:32:01.31Z" }, + { url = "https://files.pythonhosted.org/packages/10/cb/16c3f2cf3266edd25aaa00d6c4350381c8b012ed6f5276675b9eba8d9ff4/pyyaml-6.0.3-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00", size = 882114, upload-time = "2025-09-25T21:32:03.376Z" }, + { url = "https://files.pythonhosted.org/packages/71/60/917329f640924b18ff085ab889a11c763e0b573da888e8404ff486657602/pyyaml-6.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d", size = 806638, upload-time = "2025-09-25T21:32:04.553Z" }, + { url = "https://files.pythonhosted.org/packages/dd/6f/529b0f316a9fd167281a6c3826b5583e6192dba792dd55e3203d3f8e655a/pyyaml-6.0.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a", size = 767463, upload-time = "2025-09-25T21:32:06.152Z" }, + { url = "https://files.pythonhosted.org/packages/f2/6a/b627b4e0c1dd03718543519ffb2f1deea4a1e6d42fbab8021936a4d22589/pyyaml-6.0.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4", size = 794986, upload-time = "2025-09-25T21:32:07.367Z" }, + { url = "https://files.pythonhosted.org/packages/45/91/47a6e1c42d9ee337c4839208f30d9f09caa9f720ec7582917b264defc875/pyyaml-6.0.3-cp311-cp311-win32.whl", hash = "sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b", size = 142543, upload-time = "2025-09-25T21:32:08.95Z" }, + { url = "https://files.pythonhosted.org/packages/da/e3/ea007450a105ae919a72393cb06f122f288ef60bba2dc64b26e2646fa315/pyyaml-6.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf", size = 158763, upload-time = "2025-09-25T21:32:09.96Z" }, + { url = "https://files.pythonhosted.org/packages/d1/33/422b98d2195232ca1826284a76852ad5a86fe23e31b009c9886b2d0fb8b2/pyyaml-6.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196", size = 182063, upload-time = "2025-09-25T21:32:11.445Z" }, + { url = "https://files.pythonhosted.org/packages/89/a0/6cf41a19a1f2f3feab0e9c0b74134aa2ce6849093d5517a0c550fe37a648/pyyaml-6.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0", size = 173973, upload-time = "2025-09-25T21:32:12.492Z" }, + { url = "https://files.pythonhosted.org/packages/ed/23/7a778b6bd0b9a8039df8b1b1d80e2e2ad78aa04171592c8a5c43a56a6af4/pyyaml-6.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28", size = 775116, upload-time = "2025-09-25T21:32:13.652Z" }, + { url = "https://files.pythonhosted.org/packages/65/30/d7353c338e12baef4ecc1b09e877c1970bd3382789c159b4f89d6a70dc09/pyyaml-6.0.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c", size = 844011, upload-time = "2025-09-25T21:32:15.21Z" }, + { url = "https://files.pythonhosted.org/packages/8b/9d/b3589d3877982d4f2329302ef98a8026e7f4443c765c46cfecc8858c6b4b/pyyaml-6.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc", size = 807870, upload-time = "2025-09-25T21:32:16.431Z" }, + { url = "https://files.pythonhosted.org/packages/05/c0/b3be26a015601b822b97d9149ff8cb5ead58c66f981e04fedf4e762f4bd4/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e", size = 761089, upload-time = "2025-09-25T21:32:17.56Z" }, + { url = "https://files.pythonhosted.org/packages/be/8e/98435a21d1d4b46590d5459a22d88128103f8da4c2d4cb8f14f2a96504e1/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea", size = 790181, upload-time = "2025-09-25T21:32:18.834Z" }, + { url = "https://files.pythonhosted.org/packages/74/93/7baea19427dcfbe1e5a372d81473250b379f04b1bd3c4c5ff825e2327202/pyyaml-6.0.3-cp312-cp312-win32.whl", hash = "sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5", size = 137658, upload-time = "2025-09-25T21:32:20.209Z" }, + { url = "https://files.pythonhosted.org/packages/86/bf/899e81e4cce32febab4fb42bb97dcdf66bc135272882d1987881a4b519e9/pyyaml-6.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b", size = 154003, upload-time = "2025-09-25T21:32:21.167Z" }, + { url = "https://files.pythonhosted.org/packages/1a/08/67bd04656199bbb51dbed1439b7f27601dfb576fb864099c7ef0c3e55531/pyyaml-6.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd", size = 140344, upload-time = "2025-09-25T21:32:22.617Z" }, + { url = "https://files.pythonhosted.org/packages/d1/11/0fd08f8192109f7169db964b5707a2f1e8b745d4e239b784a5a1dd80d1db/pyyaml-6.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8", size = 181669, upload-time = "2025-09-25T21:32:23.673Z" }, + { url = "https://files.pythonhosted.org/packages/b1/16/95309993f1d3748cd644e02e38b75d50cbc0d9561d21f390a76242ce073f/pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1", size = 173252, upload-time = "2025-09-25T21:32:25.149Z" }, + { url = "https://files.pythonhosted.org/packages/50/31/b20f376d3f810b9b2371e72ef5adb33879b25edb7a6d072cb7ca0c486398/pyyaml-6.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c", size = 767081, upload-time = "2025-09-25T21:32:26.575Z" }, + { url = "https://files.pythonhosted.org/packages/49/1e/a55ca81e949270d5d4432fbbd19dfea5321eda7c41a849d443dc92fd1ff7/pyyaml-6.0.3-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5", size = 841159, upload-time = "2025-09-25T21:32:27.727Z" }, + { url = "https://files.pythonhosted.org/packages/74/27/e5b8f34d02d9995b80abcef563ea1f8b56d20134d8f4e5e81733b1feceb2/pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6", size = 801626, upload-time = "2025-09-25T21:32:28.878Z" }, + { url = "https://files.pythonhosted.org/packages/f9/11/ba845c23988798f40e52ba45f34849aa8a1f2d4af4b798588010792ebad6/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6", size = 753613, upload-time = "2025-09-25T21:32:30.178Z" }, + { url = "https://files.pythonhosted.org/packages/3d/e0/7966e1a7bfc0a45bf0a7fb6b98ea03fc9b8d84fa7f2229e9659680b69ee3/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be", size = 794115, upload-time = "2025-09-25T21:32:31.353Z" }, + { url = "https://files.pythonhosted.org/packages/de/94/980b50a6531b3019e45ddeada0626d45fa85cbe22300844a7983285bed3b/pyyaml-6.0.3-cp313-cp313-win32.whl", hash = "sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26", size = 137427, upload-time = "2025-09-25T21:32:32.58Z" }, + { url = "https://files.pythonhosted.org/packages/97/c9/39d5b874e8b28845e4ec2202b5da735d0199dbe5b8fb85f91398814a9a46/pyyaml-6.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c", size = 154090, upload-time = "2025-09-25T21:32:33.659Z" }, + { url = "https://files.pythonhosted.org/packages/73/e8/2bdf3ca2090f68bb3d75b44da7bbc71843b19c9f2b9cb9b0f4ab7a5a4329/pyyaml-6.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb", size = 140246, upload-time = "2025-09-25T21:32:34.663Z" }, + { url = "https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac", size = 181814, upload-time = "2025-09-25T21:32:35.712Z" }, + { url = "https://files.pythonhosted.org/packages/bd/9c/4d95bb87eb2063d20db7b60faa3840c1b18025517ae857371c4dd55a6b3a/pyyaml-6.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310", size = 173809, upload-time = "2025-09-25T21:32:36.789Z" }, + { url = "https://files.pythonhosted.org/packages/92/b5/47e807c2623074914e29dabd16cbbdd4bf5e9b2db9f8090fa64411fc5382/pyyaml-6.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7", size = 766454, upload-time = "2025-09-25T21:32:37.966Z" }, + { url = "https://files.pythonhosted.org/packages/02/9e/e5e9b168be58564121efb3de6859c452fccde0ab093d8438905899a3a483/pyyaml-6.0.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788", size = 836355, upload-time = "2025-09-25T21:32:39.178Z" }, + { url = "https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5", size = 794175, upload-time = "2025-09-25T21:32:40.865Z" }, + { url = "https://files.pythonhosted.org/packages/dd/3f/5989debef34dc6397317802b527dbbafb2b4760878a53d4166579111411e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764", size = 755228, upload-time = "2025-09-25T21:32:42.084Z" }, + { url = "https://files.pythonhosted.org/packages/d7/ce/af88a49043cd2e265be63d083fc75b27b6ed062f5f9fd6cdc223ad62f03e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35", size = 789194, upload-time = "2025-09-25T21:32:43.362Z" }, + { url = "https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac", size = 156429, upload-time = "2025-09-25T21:32:57.844Z" }, + { url = "https://files.pythonhosted.org/packages/f4/f4/a4541072bb9422c8a883ab55255f918fa378ecf083f5b85e87fc2b4eda1b/pyyaml-6.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3", size = 143912, upload-time = "2025-09-25T21:32:59.247Z" }, + { url = "https://files.pythonhosted.org/packages/7c/f9/07dd09ae774e4616edf6cda684ee78f97777bdd15847253637a6f052a62f/pyyaml-6.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3", size = 189108, upload-time = "2025-09-25T21:32:44.377Z" }, + { url = "https://files.pythonhosted.org/packages/4e/78/8d08c9fb7ce09ad8c38ad533c1191cf27f7ae1effe5bb9400a46d9437fcf/pyyaml-6.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba", size = 183641, upload-time = "2025-09-25T21:32:45.407Z" }, + { url = "https://files.pythonhosted.org/packages/7b/5b/3babb19104a46945cf816d047db2788bcaf8c94527a805610b0289a01c6b/pyyaml-6.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c", size = 831901, upload-time = "2025-09-25T21:32:48.83Z" }, + { url = "https://files.pythonhosted.org/packages/8b/cc/dff0684d8dc44da4d22a13f35f073d558c268780ce3c6ba1b87055bb0b87/pyyaml-6.0.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702", size = 861132, upload-time = "2025-09-25T21:32:50.149Z" }, + { url = "https://files.pythonhosted.org/packages/b1/5e/f77dc6b9036943e285ba76b49e118d9ea929885becb0a29ba8a7c75e29fe/pyyaml-6.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c", size = 839261, upload-time = "2025-09-25T21:32:51.808Z" }, + { url = "https://files.pythonhosted.org/packages/ce/88/a9db1376aa2a228197c58b37302f284b5617f56a5d959fd1763fb1675ce6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065", size = 805272, upload-time = "2025-09-25T21:32:52.941Z" }, + { url = "https://files.pythonhosted.org/packages/da/92/1446574745d74df0c92e6aa4a7b0b3130706a4142b2d1a5869f2eaa423c6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65", size = 829923, upload-time = "2025-09-25T21:32:54.537Z" }, + { url = "https://files.pythonhosted.org/packages/f0/7a/1c7270340330e575b92f397352af856a8c06f230aa3e76f86b39d01b416a/pyyaml-6.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9", size = 174062, upload-time = "2025-09-25T21:32:55.767Z" }, + { url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" }, +] + +[[package]] +name = "pyzmq" +version = "27.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi", marker = "implementation_name == 'pypy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e2/e1/ea46ab0d707219c098065a37d2add5b53d3b124241aa19429bcd0863e5b4/pyzmq-27.3.0.tar.gz", hash = "sha256:bbedb3d1d99babc625f1dd9d7438acefd442b36b75073fd6bc1ef7c0a4b96d56", size = 293249, upload-time = "2026-11-04T00:31:33.068Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ba/ea/4b0f153994ff26f654ca4f941b3e38216ae368cf578e10a1a6d1d8847f01/pyzmq-27.3.0-cp311-cp311-macosx_10_15_universal2.whl", hash = "sha256:86fb4408797aabb54a31e147176ae0f2474d99f1715a36a4564089eca9ef9ce8", size = 1262961, upload-time = "2026-11-04T00:28:46.452Z" }, + { url = "https://files.pythonhosted.org/packages/ca/b4/85be2f47469f13bf31a778c88475bd33824299243af36b18728f96631658/pyzmq-27.3.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f3d14fc8a7b85156c67e3f6ebbe8f2af2f89da2a407997a66e2a578e1bdabf6a", size = 788453, upload-time = "2026-11-04T00:28:48.34Z" }, + { url = "https://files.pythonhosted.org/packages/8e/09/9f33bee7acbb95b0b8b4847a20f0ca15650bbfbed53795c2ca88f3390391/pyzmq-27.3.0-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:477b8ad30d66fc905c5388351e83b9ac25824b00e82c0d052b72ea6392636dfd", size = 875050, upload-time = "2026-11-04T00:28:50.344Z" }, + { url = "https://files.pythonhosted.org/packages/5c/90/397107ce4ac5e69c38cf58c190338a3885432263120298738881cdb8b9b2/pyzmq-27.3.0-cp311-cp311-manylinux_2_28_i686.whl", hash = "sha256:6e5a566ba2f0bdbe3eb0046a3c958b9a5d54cd866bf2ef9e5678a5dfed48613a", size = 938860, upload-time = "2026-11-04T00:28:52.638Z" }, + { url = "https://files.pythonhosted.org/packages/40/03/039a3741e4d4a9996ca976ccd5fb46f0b4ac2fe11e9f7f9718bed8952977/pyzmq-27.3.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:aaab8cf85cf6f063f291ccbee20ced0de69b8e945589471e8e7dc355218a0a13", size = 1779740, upload-time = "2026-11-04T00:28:54.563Z" }, + { url = "https://files.pythonhosted.org/packages/a5/c9/4eabf560d2ca533b5e4074911f9eb6ca5a3697497cfd9f6dff98d98196c8/pyzmq-27.3.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:30c57cdda34d208541944f0b2a6bdece682364bfd6579633dde8f732e32f6376", size = 2086501, upload-time = "2026-11-04T00:28:56.811Z" }, + { url = "https://files.pythonhosted.org/packages/bb/e4/6e5969282f4e26fac4035e4fd1f1b5051fc230148cdcc3ea3587e229274b/pyzmq-27.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b1d5c7d0903f5485e0689a115ca528748a9f287fa04ed6c46580772a2e725c46", size = 1913616, upload-time = "2026-11-04T00:29:03.6Z" }, + { url = "https://files.pythonhosted.org/packages/97/fd/6dd284b6c193cec6672d34a97b56d6160fd32c0e2991ce9bdebad5b423f7/pyzmq-27.3.0-cp311-cp311-win32.whl", hash = "sha256:c2ad234ad2566426c8d568df650675f4996de35bd9376d603b33e32a967f5411", size = 575220, upload-time = "2026-11-04T00:29:05.095Z" }, + { url = "https://files.pythonhosted.org/packages/9e/3b/d3f6c6a3d46781f723ceb90fdfafe403fbcc5494b440e70c37c60e3acfdc/pyzmq-27.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:df98c790f86b6aa2378b4bb94dec7b85b0adb195b880b41e429a4990aed2a8c9", size = 658252, upload-time = "2026-11-04T00:29:06.584Z" }, + { url = "https://files.pythonhosted.org/packages/2c/a7/6229f4b219056a21df780c1d340d6d5c86c5a48d2328f2940010ac932157/pyzmq-27.3.0-cp311-cp311-win_arm64.whl", hash = "sha256:652d68fb398e714540d8a577cef81c548c61394c721bc1b996b5a4028e89f73d", size = 580574, upload-time = "2026-11-04T00:29:08.162Z" }, + { url = "https://files.pythonhosted.org/packages/b5/9e/6663ccc8c1af4e7db85de65921560a8058ad4ad4c40ebc49af4b1164f01a/pyzmq-27.3.0-cp312-abi3-macosx_10_15_universal2.whl", hash = "sha256:15155fd8f308d3bd47f67a8f6cc809f9db90abbf63c514c384a17622e2cf080f", size = 1232964, upload-time = "2026-11-04T00:29:09.922Z" }, + { url = "https://files.pythonhosted.org/packages/b4/90/4fc65d7a48077f535705ac957c29a3c07fa54a1f8d2595ca2f5f1489b21c/pyzmq-27.3.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ad8b828407caee77ff3ab0bdb2984ee8d48922328b226e8fda7c84a71a55dbb4", size = 770405, upload-time = "2026-11-04T00:29:11.487Z" }, + { url = "https://files.pythonhosted.org/packages/2c/62/e4721d8b8b9de685323717489a408521067a786cabc2b73ccd91aa9b9077/pyzmq-27.3.0-cp312-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:858fe25231e0fd8612da142efde019faa5ef63fa150a821a27870e791b38c798", size = 855178, upload-time = "2026-11-04T00:29:13.042Z" }, + { url = "https://files.pythonhosted.org/packages/39/5f/8190ff273beb195d9c9b62a36d0d87bad79019e76ff4407cabe463bc650d/pyzmq-27.3.0-cp312-abi3-manylinux_2_28_i686.whl", hash = "sha256:8b174298b57d5c2397c74fbefd656101d477357035916881970ed5f53b7b904c", size = 919158, upload-time = "2026-11-04T00:29:14.854Z" }, + { url = "https://files.pythonhosted.org/packages/8f/66/ab116baad852235c82be3d8d83af7098a7165c48995a03f2b6e8d50297dc/pyzmq-27.3.0-cp312-abi3-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:cffd75359342ef88c86c287c99b16b2b100795dab467fd5398bcedd87d49bce7", size = 813613, upload-time = "2026-11-04T00:29:17.239Z" }, + { url = "https://files.pythonhosted.org/packages/b3/55/5075ef84055eca159435e65f8d67591bfe06c562cf310792cd50a6aeb0c9/pyzmq-27.3.0-cp312-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:220095b4c11b0542ae5c0d67411331d3819753ee9ec0468e63a4ca6fd4ccf50f", size = 1762126, upload-time = "2026-11-04T00:29:18.994Z" }, + { url = "https://files.pythonhosted.org/packages/28/6f/e75d5e5aeda920dbcaaedcc413605379287b817578d00e47bfa89a8ea671/pyzmq-27.3.0-cp312-abi3-musllinux_1_2_i686.whl", hash = "sha256:e9e12fe784529e12177937aee8c714b7aed8913a2429ee2567400c904d4d55b5", size = 2067522, upload-time = "2026-11-04T00:29:20.762Z" }, + { url = "https://files.pythonhosted.org/packages/9c/b4/0d91b1e5ea8d659c1014ef39acfda279f4768fc4043120e98b764a59f1c9/pyzmq-27.3.0-cp312-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:d317685b83663fbd03ca8b5c34add7463e9bed094e3e1a69d2a895130b64ffaf", size = 1893864, upload-time = "2026-11-04T00:29:22.451Z" }, + { url = "https://files.pythonhosted.org/packages/2a/23/ed213d9dc6e48913a1f77090d1aed85bc4b1e5567ef74a86fd8fd473f423/pyzmq-27.3.0-cp312-abi3-win32.whl", hash = "sha256:07dd778d7cf242a1e131bfad6244f64df59441dda7ea639d037d0fdb22112b6c", size = 567172, upload-time = "2026-11-04T00:29:24.09Z" }, + { url = "https://files.pythonhosted.org/packages/fa/6d/23a02024011a494fb52bcfb179f10a3b230cff7b6fe0d5b8a3c775ce3b82/pyzmq-27.3.0-cp312-abi3-win_amd64.whl", hash = "sha256:3ea8e8fa5c097e68fef91d70b150fda96f307758103868018fc4deeb9c214122", size = 642389, upload-time = "2026-11-04T00:29:25.739Z" }, + { url = "https://files.pythonhosted.org/packages/e2/1b/410fc7ec4fc114b46da17ed0df3b88606f0624fbe172e184658d361b1dc1/pyzmq-27.3.0-cp312-abi3-win_arm64.whl", hash = "sha256:2187a5ca80691a5edb30690f02d9fb714e2c32d3dfdeb652e159ff5da2dd4283", size = 570810, upload-time = "2026-11-04T00:29:27.709Z" }, + { url = "https://files.pythonhosted.org/packages/d1/0f/81652a1066e994000cfec501f16137fa231e921675b63ee54c8cf4e30362/pyzmq-27.3.0-cp313-cp313-android_24_arm64_v8a.whl", hash = "sha256:a418d35be0a0a2693bf1990d831a744ee2f012b8268b3e0c6cb28b06c2769d76", size = 1136520, upload-time = "2026-11-04T00:29:29.58Z" }, + { url = "https://files.pythonhosted.org/packages/ce/0e/a2e5cb7db327ce85f3c2d11f25be55aba1639f55dad8ea77e03458ec5dbf/pyzmq-27.3.0-cp313-cp313-android_24_x86_64.whl", hash = "sha256:e9012762d869d620dad3c83fb5ff8f4900490decddd98caf6ff80847176c4be0", size = 1181427, upload-time = "2026-11-04T00:29:31.178Z" }, + { url = "https://files.pythonhosted.org/packages/88/b8/8a80749971b1a42fc415c720a52deedd33d0ae72792544331fc76f306ded/pyzmq-27.3.0-cp314-cp314-android_24_arm64_v8a.whl", hash = "sha256:fca5c2352c499e8355b581ddecfe52538984131b7efc052a30e2d32426baf637", size = 1143753, upload-time = "2026-11-04T00:29:32.923Z" }, + { url = "https://files.pythonhosted.org/packages/59/2d/196f50920da3137fd54b1636c36aba97b95d18d467bf097edca5f6ef5be8/pyzmq-27.3.0-cp314-cp314-android_24_x86_64.whl", hash = "sha256:91ac316f440aca4e6eaf3786f54b80f4ab433e5cc4e5e9b82eb44a27c5c987cd", size = 1182341, upload-time = "2026-11-04T00:29:35.073Z" }, + { url = "https://files.pythonhosted.org/packages/c7/3f/bf2a67da7cfac3c1f85c0130b8bd1fc48e96c1e66e8a50c71faea83979b3/pyzmq-27.3.0-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:d292cedc7250db240e9f41994cf3eefe2c7606c702ef5c56aab8d4f03870108c", size = 1271939, upload-time = "2026-11-04T00:29:36.803Z" }, + { url = "https://files.pythonhosted.org/packages/f6/43/2bfa60b57b3febd892d5760c811012b6850306962e3dd6a2f91b96cd5398/pyzmq-27.3.0-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:924f870055c05926887157485efe903c8f9668d0f3f19d56df7612bcb3d662cb", size = 779903, upload-time = "2026-11-04T00:29:38.52Z" }, + { url = "https://files.pythonhosted.org/packages/e3/72/4f88cd0d1da0e5db9a26a899e37f8b46d925f328f9bae590f86fc995074b/pyzmq-27.3.0-cp314-cp314t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6dac496cd8aacf185a634e5cc8930331db1627dd214a58ee4c27948ce4ae79af", size = 864708, upload-time = "2026-11-04T00:29:50.209Z" }, + { url = "https://files.pythonhosted.org/packages/79/5e/fce842845aad4135a2e1936f3cd1a418b4f49e2d45cd7b5576d6f836d95b/pyzmq-27.3.0-cp314-cp314t-manylinux_2_28_i686.whl", hash = "sha256:665b1a3d35a4ffe6cfa626191a5439108159d51d17bd9d44f1beb1690114adfc", size = 927234, upload-time = "2026-11-04T00:29:52.003Z" }, + { url = "https://files.pythonhosted.org/packages/e1/28/945736083a00750e101c4259312b5303aead36ef08539a0f0ad93a1cb899/pyzmq-27.3.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:0fedab58520a5091ffa62547eb507bea44882ce72d49929fa9626061ae1b9a2c", size = 1771921, upload-time = "2026-11-04T00:29:53.677Z" }, + { url = "https://files.pythonhosted.org/packages/3d/30/2a584e845a51c0e5d6e13889fe659aa90912004fbb5bc4750491f558528c/pyzmq-27.3.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:1b9b9d11e2e775a81d0e8b5c6cb76a395ddaa7c6b6373f3b0d2c8f8146d95f4a", size = 2075396, upload-time = "2026-11-04T00:29:55.772Z" }, + { url = "https://files.pythonhosted.org/packages/4e/6b/93066f121c31b825c56c74dca01ea5c00847f8b44645ad990f92bd04d29c/pyzmq-27.3.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:169a522c4d166c3bc7b67ed827d3beda549a8e65c4015c9410687757fb39852f", size = 1903986, upload-time = "2026-11-04T00:29:57.741Z" }, + { url = "https://files.pythonhosted.org/packages/85/ae/ecc7c77cd6ea18ff7b2b07a2fd0db5c31c2204ecf9a774e80bd1250dc9d9/pyzmq-27.3.0-cp314-cp314t-win32.whl", hash = "sha256:0228fe121f05a8b638ef218dde7508477a8c46200a588f71ce7143d85987cdd7", size = 597206, upload-time = "2026-11-04T00:29:59.35Z" }, + { url = "https://files.pythonhosted.org/packages/7a/1d/0bee73e1e8ab1c26eecba13a4725dfbe0405b53f451a91671dd515effe00/pyzmq-27.3.0-cp314-cp314t-win_amd64.whl", hash = "sha256:8a3d02fc710302a23c9a67b287bc13f2992067d398c3192b50eb0e30d44ed885", size = 685132, upload-time = "2026-11-04T00:30:01.144Z" }, + { url = "https://files.pythonhosted.org/packages/cd/23/13a768f9a8e66a999250abd216e50e1961a1cd4a8708749f656f5c0c2aea/pyzmq-27.3.0-cp314-cp314t-win_arm64.whl", hash = "sha256:2b9f08778b608fe4f6250e2d132f41b4f99fa8d03051cf2809b1c0420def81b4", size = 595549, upload-time = "2026-11-04T00:30:02.693Z" }, + { url = "https://files.pythonhosted.org/packages/91/ac/674d5c512c196c3ff2c37b27ce87764e9e69c7591902ef48330ff0ebfc07/pyzmq-27.3.0-cp315-cp315-android_24_arm64_v8a.whl", hash = "sha256:81fcd4e798f384a158b1790171a63541e66ccdee5a139a4dd0848a6e88dc7b9e", size = 1143291, upload-time = "2026-11-04T00:30:04.411Z" }, + { url = "https://files.pythonhosted.org/packages/c1/eb/6bf15cb88fb5d9f8fe6ee6b57185c110f862b6bc1ad02772767571bd3c5c/pyzmq-27.3.0-cp315-cp315-android_24_x86_64.whl", hash = "sha256:e9b87a6f40b62c7cd47691fc2ba4fdc28bef58f5fccf48eaf39940d183d2a16c", size = 1181899, upload-time = "2026-11-04T00:30:05.993Z" }, + { url = "https://files.pythonhosted.org/packages/2c/bc/e00cf032d751a709e12d71c3e2e265957bfb0097d8d071fae4f6a45e2d4c/pyzmq-27.3.0-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:23ddfe5d4d0c6ea529614c8999065d609a113f343c7e60dda9746d7dcb00d766", size = 1270101, upload-time = "2026-11-04T00:30:07.977Z" }, + { url = "https://files.pythonhosted.org/packages/20/aa/87ebb4664bb27fa53382d45f21f9f49d6194c0eb6737d7c2c5d5e921f1ee/pyzmq-27.3.0-cp315-cp315t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b437cf437fe737e17082625f470258f12e4bf5d56edfb88cb21d3aa4089fcef9", size = 779378, upload-time = "2026-11-04T00:30:10.504Z" }, + { url = "https://files.pythonhosted.org/packages/c1/85/e998ff27a29aca9b0f8529e32b0913420e75f8f990a54ad9434faa3d4c5e/pyzmq-27.3.0-cp315-cp315t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bc2cc98f37a14a3c9baccc18173a9fca9c6d18ffb233bca7079e58b2e47ee7f8", size = 864317, upload-time = "2026-11-04T00:30:12.259Z" }, + { url = "https://files.pythonhosted.org/packages/d6/7a/6535a0b2fbde9554291caeb3c41b6452207ed7afeb910af830f48e6731f5/pyzmq-27.3.0-cp315-cp315t-manylinux_2_28_i686.whl", hash = "sha256:1a1e092726596141e8ad2cc7f542fd366ddd692b8a9e254d2972ac47b399b982", size = 926240, upload-time = "2026-11-04T00:30:13.862Z" }, + { url = "https://files.pythonhosted.org/packages/51/6f/0c3b1b621f17ebd3eaa2c974b11507dc88cef529ebdc72b42935d00e4a90/pyzmq-27.3.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:0c9c332883373eb85b72f4d912a9a4402ba7702709fa783d3c76ff2bd703a491", size = 1771499, upload-time = "2026-11-04T00:30:15.471Z" }, + { url = "https://files.pythonhosted.org/packages/e1/a5/b753eb9acc131fbb4da67c4c68037965f12f8782d1fd5e461e803e0a1dc1/pyzmq-27.3.0-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:1f724caa222b1ae3c48f7d25147c816c8bde56fb109c164a650f0502b9005ab6", size = 2074632, upload-time = "2026-11-04T00:30:17.149Z" }, + { url = "https://files.pythonhosted.org/packages/d1/ad/8bce8d0ff0f0cc0958bdfeebbde9ee319cbd025c949607ab2864df657ce6/pyzmq-27.3.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:129ca693e543940527e105144dcacdf9e0ec01d41421098e08893de8227aca58", size = 1903559, upload-time = "2026-11-04T00:30:19.142Z" }, + { url = "https://files.pythonhosted.org/packages/fd/25/e5b3e6a066b59840cdc0ea6de8244b1a50b5f237edc7b7adc0e085973708/pyzmq-27.3.0-cp315-cp315t-win32.whl", hash = "sha256:39b9ff1fbab854ccbc53da0e79cb6b78b61b470fb7c191b89aa034825ea9a883", size = 596443, upload-time = "2026-11-04T00:30:20.811Z" }, + { url = "https://files.pythonhosted.org/packages/3f/c8/20ecc504500aeaab0440a4c8487a3c1cd32f4ac38f3e92482f1671fcaeca/pyzmq-27.3.0-cp315-cp315t-win_amd64.whl", hash = "sha256:3b850eaa955ae7edb926fe266600e57da818255d1f6ee9c3d8049967aa4a22cc", size = 684767, upload-time = "2026-11-04T00:30:22.784Z" }, + { url = "https://files.pythonhosted.org/packages/e8/5d/33c528d9b7ee074d0807e3af1a23a3e50bfdbe28cbc178e99f0466c13648/pyzmq-27.3.0-cp315-cp315t-win_arm64.whl", hash = "sha256:f0b9d192b285a9d38e390e762011f2672432742a301859b6c8cb4fab5f10f687", size = 594143, upload-time = "2026-11-04T00:30:24.33Z" }, + { url = "https://files.pythonhosted.org/packages/67/36/04666a943685abde486ca045701ee9443b1a698e31c0e5d29be965087164/pyzmq-27.3.0-pp311-pypy311_pp80-macosx_10_15_x86_64.whl", hash = "sha256:78157e57c734e8fc6dbf28c76aafc2cd7e871780fc661825c75e0afdc3424a82", size = 689539, upload-time = "2026-11-04T00:30:57.5Z" }, + { url = "https://files.pythonhosted.org/packages/e3/22/ad080fd18de3e6b1618029c8166895991a765f39bd489c32c1ff46f15778/pyzmq-27.3.0-pp311-pypy311_pp80-macosx_11_0_arm64.whl", hash = "sha256:8f15e7f2b5cc6459c45619e06e61f02fd1d9138b677b56e7a677232251a873b7", size = 632029, upload-time = "2026-11-04T00:30:59.361Z" }, + { url = "https://files.pythonhosted.org/packages/1c/45/08e946778c08c1989abade2ed86687114bb6fb22218521f68c7e9fb3eb4c/pyzmq-27.3.0-pp311-pypy311_pp80-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ae989940ebc279e81821bad87864119b9ab179e5abd50fe642dfb425f0eb2f92", size = 684299, upload-time = "2026-11-04T00:31:05.898Z" }, + { url = "https://files.pythonhosted.org/packages/08/6d/00f9a4e5c17135cca4126fdc60df9a397066fcd8ba390dc11cc07ad5a5ed/pyzmq-27.3.0-pp311-pypy311_pp80-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2ad3ec36c9d107ef33063d167ce07d9066ff92eba23385e320f1c2472437bb8a", size = 761485, upload-time = "2026-11-04T00:31:07.551Z" }, + { url = "https://files.pythonhosted.org/packages/27/18/c66e01646180e453216df42ef6274bddba3f4be412997b82de790bedf6d2/pyzmq-27.3.0-pp311-pypy311_pp80-manylinux_2_28_i686.whl", hash = "sha256:487dc31c44c16cfb5e78ae65a187d25fa82e59d1efad0595b6e79eadc4750c68", size = 821380, upload-time = "2026-11-04T00:31:09.209Z" }, + { url = "https://files.pythonhosted.org/packages/c8/be/aeaef2cfdded411909ce556631e029761dccce49cb2a078162a4d04416be/pyzmq-27.3.0-pp311-pypy311_pp80-win_amd64.whl", hash = "sha256:c72f9b1f6dbaf760daea97082506f4d6fd682a8512dbd320986b5268b189e727", size = 564188, upload-time = "2026-11-04T00:31:10.758Z" }, + { url = "https://files.pythonhosted.org/packages/53/53/6ea90b8bb4c77bcc4babd15ef6a63ed243cfd47920cb270da5f29438d11f/pyzmq-27.3.0-pp312-pypy312_pp80-macosx_10_15_x86_64.whl", hash = "sha256:cff2031014f79b213818b6773253cbf330119c93de33ee1a635596f407da5c35", size = 689536, upload-time = "2026-11-04T00:31:12.423Z" }, + { url = "https://files.pythonhosted.org/packages/a1/9e/699898cdd86e4cd4bc20547b9f1bce24c58900f51e6a9d5fad03c2890407/pyzmq-27.3.0-pp312-pypy312_pp80-macosx_11_0_arm64.whl", hash = "sha256:18da98ce26045ef503b42a3f98fc2a2af0cdb2af87dc0594852fa5cea3795427", size = 632027, upload-time = "2026-11-04T00:31:14.338Z" }, + { url = "https://files.pythonhosted.org/packages/a6/59/5d6ccce5456cafbdf84c98141d3ddf6c073716eb7b958254349e047fad84/pyzmq-27.3.0-pp312-pypy312_pp80-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:13c7336a4112d3e09c5d78d17e17af1cd01da858ec1c5e3755b2d06339aa7d4f", size = 684300, upload-time = "2026-11-04T00:31:15.891Z" }, + { url = "https://files.pythonhosted.org/packages/b4/37/c4cf124d820495c5549b3f606b1292949c9e2053467309a7e1baaf0c3784/pyzmq-27.3.0-pp312-pypy312_pp80-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:51e1358fabf41920d69cab170495b6e263680797ac5b80ace1b5cf1eb2d89642", size = 761485, upload-time = "2026-11-04T00:31:17.817Z" }, + { url = "https://files.pythonhosted.org/packages/a7/cf/caa0bd5f7a1b139b9240faf3b34586867656f682774364101572e8e84f80/pyzmq-27.3.0-pp312-pypy312_pp80-manylinux_2_28_i686.whl", hash = "sha256:cdb5efd4c23465573e928fb8429e40996ac0e1a4809365efe19e2753112b6ee1", size = 821382, upload-time = "2026-11-04T00:31:19.451Z" }, + { url = "https://files.pythonhosted.org/packages/8e/34/81fa1d9701024eb4f48949ba5f93da3a063ab997e0e0c9787ff37f11ecda/pyzmq-27.3.0-pp312-pypy312_pp80-win_amd64.whl", hash = "sha256:1b7ab96158dd50d7e6e430e6e4f744aaccee1df2e9d167ace9e7d2f3e3051712", size = 564187, upload-time = "2026-11-04T00:31:21.486Z" }, +] + +[[package]] +name = "referencing" +version = "0.37.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "rpds-py" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/22/f5/df4e9027acead3ecc63e50fe1e36aca1523e1719559c499951bb4b53188f/referencing-0.37.0.tar.gz", hash = "sha256:44aefc3142c5b842538163acb373e24cce6632bd54bdb01b21ad5863489f50d8", size = 78036, upload-time = "2025-10-13T15:30:48.871Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2c/58/ca301544e1fa93ed4f80d724bf5b194f6e4b945841c5bfd555878eea9fcb/referencing-0.37.0-py3-none-any.whl", hash = "sha256:381329a9f99628c9069361716891d34ad94af76e461dcb0335825aecc7692231", size = 26766, upload-time = "2025-10-13T15:30:47.625Z" }, +] + +[[package]] +name = "rpds-py" +version = "2026.9.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/42/68/3bd46b8a5e01d3c2ebdf9c5e9497912e3fe0cde02bac21a7130ca866e403/rpds_py-2026.9.1.tar.gz", hash = "sha256:4793ef7f78268b124b73fa933440f01d258bbae01de9fa53e9080c9ab0425a12", size = 63948, upload-time = "2026-10-04T16:32:36.469Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f5/6d/ddb8dfcf41892ba9c672d27988592c038d30db61708230313831b6780a1b/rpds_py-2026.9.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:2711d29b653b3bce48a63d18b9c6b53274669e6d6c4094dddeb4d9a0e45128b2", size = 344947, upload-time = "2026-10-04T16:28:55.207Z" }, + { url = "https://files.pythonhosted.org/packages/9e/b2/632c3d034961149eff606e3e357547620a9ab37b849ae5815f67838753fd/rpds_py-2026.9.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3231c4c0e521dafa5be0c9f114ee2c2ad46650836f2d72caa86801950c3e7044", size = 346770, upload-time = "2026-10-04T16:28:56.884Z" }, + { url = "https://files.pythonhosted.org/packages/6d/45/4df346410bb873d03ec60c3b891d1fceb8cabde1971d29844bbb625cc296/rpds_py-2026.9.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e01b3c878c8641913e688edd1b3f08658c6783d29cf6b826bd3c0d1ae7a1ffaa", size = 377795, upload-time = "2026-10-04T16:28:58.193Z" }, + { url = "https://files.pythonhosted.org/packages/ba/b8/a70f302207e4f29f873c01a986fcac5def49b9c8224328cef1ad7da6b7a9/rpds_py-2026.9.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3e524c7874ac72884d28e16dd5b8d839fd09e0fe76b020d3fbca23212a7b8c52", size = 383137, upload-time = "2026-10-04T16:28:59.411Z" }, + { url = "https://files.pythonhosted.org/packages/13/e3/3aa28a48a01169d0e20728bf0e5ebbea3ae2774285b40853ae49b3ef332a/rpds_py-2026.9.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:761fdae6728ceb99ab182fad2f0cc1e262f610834dc891aea1d1a2a2e634776f", size = 496789, upload-time = "2026-10-04T16:29:01.011Z" }, + { url = "https://files.pythonhosted.org/packages/3e/a7/414e8d088602d66ad6f47c65bf07fe5090992a8574cdd4571c1a83b647ed/rpds_py-2026.9.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6b723eb406dec5bc9ec516c73ab9c3239a3284e017f7eb89ee2b3258bd504fb7", size = 395929, upload-time = "2026-10-04T16:29:02.465Z" }, + { url = "https://files.pythonhosted.org/packages/2d/5c/aac3b960fd55d37b49f77c0eebbe043eaf36762ebd48e7b46951e59c1c05/rpds_py-2026.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:136a1c3fe4402b7008bc81cb62ee538481795b61a7e83df88dff3b3f02b726ff", size = 375426, upload-time = "2026-10-04T16:29:03.944Z" }, + { url = "https://files.pythonhosted.org/packages/d3/80/77987a41c40be7202a78d9aed4a650bfb05792237cfd3b9e22638d990fe5/rpds_py-2026.9.1-cp311-cp311-manylinux_2_31_riscv64.whl", hash = "sha256:839dde845559254f34885267c6878f60d61d5205180226d976fe488d45fa128e", size = 381497, upload-time = "2026-10-04T16:29:05.308Z" }, + { url = "https://files.pythonhosted.org/packages/b8/d0/640b02eb1ecd71a913c1178b6235287b31006266bca9a26862e80e497b54/rpds_py-2026.9.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:56cd8b3f77d7b6812f533b662186a1f28316931166ddc00fb893b1b0db7e9888", size = 405740, upload-time = "2026-10-04T16:29:06.578Z" }, + { url = "https://files.pythonhosted.org/packages/3e/8c/d034195d45d215625a23f2ae85dbbdb86a49a93a51272061c97c80b9d316/rpds_py-2026.9.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:074a4d198bc34d9a8ea425114fc3ded6d11ec01f6a314a8db67454a5152d8834", size = 555850, upload-time = "2026-10-04T16:29:08.115Z" }, + { url = "https://files.pythonhosted.org/packages/de/f8/532f1addfc86207bc3cf23749638bb0d457bce891595012ed8a08d0543b8/rpds_py-2026.9.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:6beb738155fe8ab8091afdfa5a3226b21c2b1593f1e50ebb90eb25b44dbc0391", size = 618661, upload-time = "2026-10-04T16:29:09.554Z" }, + { url = "https://files.pythonhosted.org/packages/50/5b/b0f2c9833a36a5b1f6ac5cb0e635fabacf713266f46ceefba2102da0bf51/rpds_py-2026.9.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:57492a550a1d88d29d003247e5f78dd8cf04a701fac0e4c8db8745a6d2504e0a", size = 583530, upload-time = "2026-10-04T16:29:11.072Z" }, + { url = "https://files.pythonhosted.org/packages/bf/20/464ed4b98d3c8c6a334f3b5e24d3886de04b05658a95fc40a37e0e6e4775/rpds_py-2026.9.1-cp311-cp311-win32.whl", hash = "sha256:d95a354e02393eada6d7351184671aced9d4cce109dabf927cb7aa99624352a1", size = 208125, upload-time = "2026-10-04T16:29:12.408Z" }, + { url = "https://files.pythonhosted.org/packages/df/c9/384a9b62f8cd89c8e3e609b8c9052c140e8c01d807261e0517c904b8bf29/rpds_py-2026.9.1-cp311-cp311-win_amd64.whl", hash = "sha256:ce4d4f52e2a4324396caddbd45a97d8d7be5f42edd25d2355282a9c34f9b2f7f", size = 226045, upload-time = "2026-10-04T16:29:13.751Z" }, + { url = "https://files.pythonhosted.org/packages/4f/3b/0a691f0dcb2301fa9c736346da2d0d4991778373283301c5c12b8f952f3d/rpds_py-2026.9.1-cp311-cp311-win_arm64.whl", hash = "sha256:fdcd198979b4ecffcc1beba366a7fbcf4eb41243691a82fe52ceb0b902f09c12", size = 222636, upload-time = "2026-10-04T16:29:14.989Z" }, + { url = "https://files.pythonhosted.org/packages/5d/34/a828586ea3329fbb50895b50e9cf98ca3d924a9f41a0b26d443bff1b3794/rpds_py-2026.9.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:50906f5aea24b5a865cbd0a589698288631d9f3a54c3a937c83aefa95a0d14af", size = 346822, upload-time = "2026-10-04T16:29:16.258Z" }, + { url = "https://files.pythonhosted.org/packages/90/81/ac6a0d064982251856ce009c9e1dd51a34110b3c055aa7d1aad18b4899a3/rpds_py-2026.9.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:e21c1429e205828ea886a2293a4a2c8e01f4c25d9893ca330e97a6cf73f52e7b", size = 341380, upload-time = "2026-10-04T16:29:17.706Z" }, + { url = "https://files.pythonhosted.org/packages/42/ff/bf7d54f362748fd6a49277b9d6531c394074110fedf50ad791ec59133fbb/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2693b2728bbcc48d09a981a356954b0c47c53ff25b545856f28a889ea619f69a", size = 373053, upload-time = "2026-10-04T16:29:19.063Z" }, + { url = "https://files.pythonhosted.org/packages/60/de/74b0ccdbbd28687b9b5fdb34c1cabed88352182facaced9d6f5486b8b9ed/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8601470267d938bcb7f3ab1a336100af51a4fd5b6ed030ef52461bb3ef5e7e07", size = 377742, upload-time = "2026-10-04T16:29:20.543Z" }, + { url = "https://files.pythonhosted.org/packages/c2/6d/b979775a3057b2a5c26d75ecbff60a20a24ef081db6dd76836fca3f20247/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3890a6aa36e6baa53d5258a2a25d3ef8b37ad165a6ab27a892d7c3e3a432cd69", size = 487289, upload-time = "2026-10-04T16:29:21.958Z" }, + { url = "https://files.pythonhosted.org/packages/1d/5d/7c34734ce3ece943d9d6ee0122a74a21bbc75b47acb5b7053c83f6efb1ed/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6b5b393eda5ea42cca1c1a6665f2a4882b4fd5d1777e41ce0545a107fb008c9d", size = 390710, upload-time = "2026-10-04T16:29:23.378Z" }, + { url = "https://files.pythonhosted.org/packages/1d/6d/b26eb1e75395925b3a142ed351cbed2ec8212f5c9d937aee3df32c701baa/rpds_py-2026.9.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:addeda51556dac7c1a2f14cda62db8b621cd12afba3091d03a96c72932387eab", size = 371261, upload-time = "2026-10-04T16:29:25.1Z" }, + { url = "https://files.pythonhosted.org/packages/7c/98/b2fdfe10301a9e27af21e634337fbba7baac0bc17fe44619a17c26bba2cb/rpds_py-2026.9.1-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:d9edf30457d74eebfd76b045535e36f1cd89062566a128a0db2145ca042d787e", size = 376075, upload-time = "2026-10-04T16:29:26.748Z" }, + { url = "https://files.pythonhosted.org/packages/c5/b1/c4b8d954e49c3c69cf8063c0c9e0919c99f3d2cecc46311606a1cbe835dc/rpds_py-2026.9.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:815d26356930846a40c7bc1366e7b1b0320ab8a063e66c11298a208bed0fd237", size = 399358, upload-time = "2026-10-04T16:29:28.282Z" }, + { url = "https://files.pythonhosted.org/packages/b3/59/9559a7293c97dff0cbb293efffbd36644103883ecc27741af8ef90c84ca8/rpds_py-2026.9.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3b5a6f40f0a1486b4b36c888123afc67acdbd9f33235927acf5ff295429a0ba3", size = 550267, upload-time = "2026-10-04T16:29:29.851Z" }, + { url = "https://files.pythonhosted.org/packages/6c/9d/6dc60e49511de4c8b00e74f9c1d43aed4d27f712cdb1ade92f2c199cbf64/rpds_py-2026.9.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:b5b8b0753718d258fd454283fbd57e14545d3b40583fa672e27cb4f987626bcc", size = 614018, upload-time = "2026-10-04T16:29:31.54Z" }, + { url = "https://files.pythonhosted.org/packages/fb/bc/92a4ecf27301b886232a413360f6b348a81d55ffef654f2ebda5970ebc3d/rpds_py-2026.9.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:46d80bc76b51a6c24f9944368c28d38b8bcbcea1da4f2f8d3ebc31a67e8c6ec6", size = 578509, upload-time = "2026-10-04T16:29:33.01Z" }, + { url = "https://files.pythonhosted.org/packages/08/53/efb97f2e6589b7ab8394385a73870e0b2ab2a195281c117b21fd6d7d4855/rpds_py-2026.9.1-cp312-cp312-win32.whl", hash = "sha256:befc2d6a953e563f8a7bfd87a42c22ebf8a3e980dcb7b6a4d17b70b0e914e8a3", size = 205401, upload-time = "2026-10-04T16:29:34.451Z" }, + { url = "https://files.pythonhosted.org/packages/1c/84/1700cc748d0eaa747486e4e82882d2575224e6e9a3148df583058850c629/rpds_py-2026.9.1-cp312-cp312-win_amd64.whl", hash = "sha256:5ce8943f79c2210f7abcc28e86367b03b28d95027fd01c46d2472373ae70c86f", size = 222923, upload-time = "2026-10-04T16:29:35.709Z" }, + { url = "https://files.pythonhosted.org/packages/c3/89/0302215373c2f8b4408b0fdfee955368cc378a98ff59508d47a7e0dc2dbf/rpds_py-2026.9.1-cp312-cp312-win_arm64.whl", hash = "sha256:501909f2e4a1e2dee528ef766fe3c469060ebc17e54a8383d404ba07a81a6f02", size = 218415, upload-time = "2026-10-04T16:29:37.263Z" }, + { url = "https://files.pythonhosted.org/packages/83/ea/ee88fd9e756ff93fb6b1182a47ec09504a242620e33ce1d20679efefe841/rpds_py-2026.9.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:a36b70596407634ca82d4b989a3729074a008537a0522e4c8046a67c729103e9", size = 346229, upload-time = "2026-10-04T16:29:38.82Z" }, + { url = "https://files.pythonhosted.org/packages/57/71/a097d6552f837500fc36e6b23d09cfb9890c3cc47531f9ca64e149799615/rpds_py-2026.9.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:eba5d173f7d5708b22a93815017a4611873ed54db9f268077c0dd1ed99cfc858", size = 340514, upload-time = "2026-10-04T16:29:40.405Z" }, + { url = "https://files.pythonhosted.org/packages/bd/b7/497e85768bf4e0d8ddbaa096a4cac31d1509251dee2728a8490aa367e0b5/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:457866b85daf5034296666168b84a69e0b2e89dc4f1af102b46f6448a60b9063", size = 372611, upload-time = "2026-10-04T16:29:41.778Z" }, + { url = "https://files.pythonhosted.org/packages/52/4b/74ab4108916250b6e198e0d3af05bc6835eb046315f22f7a0ceb49667c5a/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a3a52a3ba86436ab3aef510fbe21512abc2ddd1993005dfe50514bd2284ef025", size = 377712, upload-time = "2026-10-04T16:29:43.242Z" }, + { url = "https://files.pythonhosted.org/packages/0c/8e/067e77d9d7b3cc793c9d909b7e97e7aadbbb1fb094093b6876902cc96d38/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d7841166b7fa64c9c56404617ae4341448847482d45933b13135d26c130519e5", size = 488106, upload-time = "2026-10-04T16:29:44.692Z" }, + { url = "https://files.pythonhosted.org/packages/3c/b4/c5aae6c2dde269bf955f6b7d35065c655a57e47750d9668052ad67e74dda/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:926bdd3e3b5998ddf70cc64bc8cf57209571f9044542913afb673799fec77dd0", size = 390795, upload-time = "2026-10-04T16:29:46.129Z" }, + { url = "https://files.pythonhosted.org/packages/a0/36/76fab39973ee11e7f9f357c55138197bb01c86f6502cb76487e3b4f42db0/rpds_py-2026.9.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7868b85224291c6cb6759f9b5adb9745f486d226f62b16a614dd5a2a5ab2b35b", size = 370794, upload-time = "2026-10-04T16:29:47.603Z" }, + { url = "https://files.pythonhosted.org/packages/3d/fe/cd2a80e6d7b871937a60e935c5d507aa390d143f4ff3636f640b9733d5df/rpds_py-2026.9.1-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:3cd182d7291d29b92c521a0069d9c01ba6193628a9a105531d11b40a6d731a33", size = 375673, upload-time = "2026-10-04T16:29:49.223Z" }, + { url = "https://files.pythonhosted.org/packages/6c/18/7464a9953724e55a3b3206062fa0ffdeaa519584c6aabf65d3956d94f131/rpds_py-2026.9.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e6ea1cda8d8c688278430e4268a42f5e5da3bdd74578dfadc0820c3f1766ce83", size = 398758, upload-time = "2026-10-04T16:29:50.601Z" }, + { url = "https://files.pythonhosted.org/packages/c0/86/1534b436700fd49ff411063b7c4d7e938adfabf90895b6cf1622d5a7d1f6/rpds_py-2026.9.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:5943980471829f6de242a20b109de3111ba6b77e3af0ffc587028ac854b05e6c", size = 550370, upload-time = "2026-10-04T16:29:52.002Z" }, + { url = "https://files.pythonhosted.org/packages/57/1c/e1fa82a8a01e3c5820f3ba98a8b2673f642128eb368fa88871b01dd2c909/rpds_py-2026.9.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:76d3af9732d2dab69f28179b40ba2d87e2f1d5824b4a694780aa787d685e8f36", size = 613106, upload-time = "2026-10-04T16:29:53.655Z" }, + { url = "https://files.pythonhosted.org/packages/29/55/b20b8c4c3dde8755bfcd5b08492a02d0cd2e26929aedf6199ca2a377d42a/rpds_py-2026.9.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:78326f4cb4427a56ba4996c0762b63be45f06b85f086526420d2b3a66e40f84d", size = 578235, upload-time = "2026-10-04T16:29:55.157Z" }, + { url = "https://files.pythonhosted.org/packages/55/42/df3f7bbc3f7ab37a8a9db8d6c2ff2c985422899f1f7926afbf7ec3c0b8b4/rpds_py-2026.9.1-cp313-cp313-win32.whl", hash = "sha256:172e47169583f46ce118cbec68e6795d0da0f4606b488b6434f8276bca0a058c", size = 205293, upload-time = "2026-10-04T16:29:56.669Z" }, + { url = "https://files.pythonhosted.org/packages/31/9c/ba5a9569d719bfdd6ce863df4133ac6a1658cf1b07cc3534c31db729fbbc/rpds_py-2026.9.1-cp313-cp313-win_amd64.whl", hash = "sha256:3e93b2cd69a9830be33e03945cd7cda940a0a8bfcfbff41d6144f0cb0d3d8bd9", size = 222409, upload-time = "2026-10-04T16:29:58.049Z" }, + { url = "https://files.pythonhosted.org/packages/35/72/f28ca566f6c23c35bbf7445f65eb0364577b25a026305995e24f78b83d94/rpds_py-2026.9.1-cp313-cp313-win_arm64.whl", hash = "sha256:d151e148117294133bf8af7eeace085e7e87432db15ab6adf640330298a47f6f", size = 217681, upload-time = "2026-10-04T16:29:59.449Z" }, + { url = "https://files.pythonhosted.org/packages/8a/f2/67b94be1532767803415c1c5a1fd88ea487643d74a673cec1ba140af77bb/rpds_py-2026.9.1-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:c9d1aca01f49170fdcf5c92761b1fafe97f554b721ca4570c5949fff778f0d4b", size = 347178, upload-time = "2026-10-04T16:30:00.865Z" }, + { url = "https://files.pythonhosted.org/packages/04/37/b751de2b59b0197a1d92a5dd491de88e8a5e928c2e6562581974f1e85263/rpds_py-2026.9.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:3f0e9ac28fc067d4d34b88ae43c48e9489455c97fee9633d851f7eeed5a05d35", size = 341878, upload-time = "2026-10-04T16:30:02.564Z" }, + { url = "https://files.pythonhosted.org/packages/72/e2/5873bc4643c250db9e05d48dc0c93763d4aa68bc3b81164cb1af3b45b284/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:07deecbfce94c78473018bc7d10b337cc651d12df87a1eb2cb3e4024bc9c33d0", size = 373963, upload-time = "2026-10-04T16:30:04.026Z" }, + { url = "https://files.pythonhosted.org/packages/51/03/5acf7632158247f3f6386ff0af3a1ee48167d575037e8d0920594b76d92b/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:821b2755db9194409254012f429c56643416fb96ef9be090be82ec8826b7f477", size = 377975, upload-time = "2026-10-04T16:30:05.555Z" }, + { url = "https://files.pythonhosted.org/packages/e6/00/63fda451b8bffa5808fc8bb311ee7c073b340974b09f273c7b2a145d3d62/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c91c210ae7645626c608400e3519b4a642f837cce09ca830db3beb2e9f274d4", size = 490347, upload-time = "2026-10-04T16:30:07.156Z" }, + { url = "https://files.pythonhosted.org/packages/a1/ae/c093ffd070ba0fb02f76c565d06fecc65ad6e4afdbae78f7031076d3cdac/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:54ac2158a6f96cfbabff0b2eedaf94b90c5ec7ca8317fcadc61e1c2b2e0ff6ef", size = 392962, upload-time = "2026-10-04T16:30:08.77Z" }, + { url = "https://files.pythonhosted.org/packages/22/9d/d08a1128ab199b2f0cf25bfeb0639bd05119fff4b7c47bec24ef9a8ec23f/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eac2f5dbafd585dfe31f86a23ebf0d3ba480a9d49ebc87947267b5608d4ea0cd", size = 371623, upload-time = "2026-10-04T16:30:10.501Z" }, + { url = "https://files.pythonhosted.org/packages/53/c7/4758ddcbb75609414bbccfcb11d612436f9b3ee821bd2f33f0f1604ee648/rpds_py-2026.9.1-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:8aa5dda18d39b6143eb24809d158f9252c88f402749b6f1b62a506cc7d96cc35", size = 376997, upload-time = "2026-10-04T16:30:12.124Z" }, + { url = "https://files.pythonhosted.org/packages/87/e4/947bd7f608ff60faf46dc9d389c3dffd0e3d767d78a0be19978448ef0ce7/rpds_py-2026.9.1-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:5c90e7fa02e8f5de0d10c17595c568ada48c5302e749462c0ea1a4c362111a86", size = 400169, upload-time = "2026-10-04T16:30:13.804Z" }, + { url = "https://files.pythonhosted.org/packages/4b/35/fe93e020a0543b5670472c18d7e6af3197c08da571240ce1965c84f85c0f/rpds_py-2026.9.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e6d198bad4e49dd6732fbd636e2fc5c082f45c8cad0b4acb756b00c82c76072e", size = 551615, upload-time = "2026-10-04T16:30:15.332Z" }, + { url = "https://files.pythonhosted.org/packages/0d/4f/5d2a0136bb03b2a56a39dc6ff92d58a6e3e53a2e17079238b86228882f16/rpds_py-2026.9.1-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:96beca19ec79de272e8668585380ff9092c47077c1d7a1e098e00bbd921f4785", size = 614655, upload-time = "2026-10-04T16:30:16.92Z" }, + { url = "https://files.pythonhosted.org/packages/09/1c/3f1025aaf70d9bf7272cc41f8b64ee76b48bf01726248138430e16f23b38/rpds_py-2026.9.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:a5cf77eb04f20b720be95265a3e00eb2a14814074255cc27069c551b2db53118", size = 579602, upload-time = "2026-10-04T16:30:18.555Z" }, + { url = "https://files.pythonhosted.org/packages/53/0d/5c72e6204f76610608706da32b6b7e11ef7e10317558a7bb15a122e008dc/rpds_py-2026.9.1-cp314-cp314-win32.whl", hash = "sha256:a03d57b86d2a51d0a66c92177e2be154ad015f357791d306e714569999cdb4cc", size = 206315, upload-time = "2026-10-04T16:30:20.05Z" }, + { url = "https://files.pythonhosted.org/packages/a4/0b/489d48abbcc7d70cf3fbf662d9d22abf1f4650761c0a9ae05260800800d3/rpds_py-2026.9.1-cp314-cp314-win_amd64.whl", hash = "sha256:837c6b305e26fe0f75b15c92cf3b2ba29e0ae19dc40b1c557b026cb426347d0c", size = 222852, upload-time = "2026-10-04T16:30:21.604Z" }, + { url = "https://files.pythonhosted.org/packages/91/16/bbb05a7e6a10cf79ba639be7f799d770ee15f64175cc61d081b218dd402a/rpds_py-2026.9.1-cp314-cp314-win_arm64.whl", hash = "sha256:fce4b85234a0cbad67bf8e6e1201ee815d172c9aebad75f25645bc4d834f8e31", size = 218709, upload-time = "2026-10-04T16:30:23.036Z" }, + { url = "https://files.pythonhosted.org/packages/22/ac/ac507a0a4ec478ca470440a09583db4be5259ba7670aeba0620822f1e57a/rpds_py-2026.9.1-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:3a72c11530d71abfb66c8d7696a2f86c43e63fca8b948f1a784ac490f4ec688e", size = 349596, upload-time = "2026-10-04T16:30:24.558Z" }, + { url = "https://files.pythonhosted.org/packages/e9/f2/817a46b658d5070f477f722c298ee9a24525b0e4017347964146ef5fdd0e/rpds_py-2026.9.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:068c37bba854ec2fe42f7365c640af11dd9895890ccbf2df5070d0c059bd7f96", size = 343114, upload-time = "2026-10-04T16:30:26.048Z" }, + { url = "https://files.pythonhosted.org/packages/6c/42/6ade976b13ac1b4cb3bf2eb603f1be2fe74df19a29988d4c2b386be59d6f/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7fca4eb6df565e2a928f1c7dad92d27db8f9df0f449e76423ed5d7e713ed445", size = 374197, upload-time = "2026-10-04T16:30:27.699Z" }, + { url = "https://files.pythonhosted.org/packages/d9/70/77cdf1d3f1a07faabe936016ae623aec7981f73108a8fe7a203ed2e21998/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c933c6678c6f116ff8af47a4c6db0868b8ace74af0343016c0ef00f00272ea69", size = 378025, upload-time = "2026-10-04T16:30:29.451Z" }, + { url = "https://files.pythonhosted.org/packages/3f/6b/18a44a3beaa9b7931acb04af7bd9539836477c630a794452d4826d6185d4/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:028ad274ea951dac64491b5d1e65712a4aeabfdbdb9fccf797b57bd899b0c495", size = 491969, upload-time = "2026-10-04T16:30:30.995Z" }, + { url = "https://files.pythonhosted.org/packages/73/27/fb39cfd6bddaf741b024f813890374578ff8ac1f1adc473659c048b03b05/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:740d0a99cf9de0b17a3943388e9294a59becf75e7c43421f387bd3c7a9901f7c", size = 393905, upload-time = "2026-10-04T16:30:32.628Z" }, + { url = "https://files.pythonhosted.org/packages/ed/71/0fa7bb77b57af0d710273964180d11b503f62b8a5c358eb2d8c3f62feff6/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0da298fb372dc192610a4b9ecbc68a0cd8b675bbbd1fc519d01b41cfd658333e", size = 374569, upload-time = "2026-10-04T16:30:34.257Z" }, + { url = "https://files.pythonhosted.org/packages/54/22/f41cfac269af3b449513ef1bc3d7f32fde52abbbd2d01c7e76b47743acd9/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:eb61be926bb81567c1f48bdc8aa22b9855048dc2efd53871f9f7e6e9a5632346", size = 377482, upload-time = "2026-10-04T16:30:35.997Z" }, + { url = "https://files.pythonhosted.org/packages/b4/fc/312b49006e7f8f9ca5f96647577b8aa6f3df30519c46bd448f5c425af0b2/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:42e75466f83cd43f6026c81eab74246efb2bdadafb307b85700632d06c68f299", size = 400040, upload-time = "2026-10-04T16:30:37.76Z" }, + { url = "https://files.pythonhosted.org/packages/cf/a6/18cca7a878dc7fa95165a83343fd4d7b65643fd22e54e47340a451121d5c/rpds_py-2026.9.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:617f59cde379b4f648a09797b7f683d04b90a46344cddab85639da5aff0f5531", size = 551849, upload-time = "2026-10-04T16:30:39.443Z" }, + { url = "https://files.pythonhosted.org/packages/e4/6d/1f5685e20f39604691bdc3c05aaa6b8bd2f954e9e996477adf2376768e33/rpds_py-2026.9.1-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:3edae8c5ddfdb6985d49ae9d150516e5076888879022f91a26c2de9276ce0bdb", size = 614842, upload-time = "2026-10-04T16:30:41.231Z" }, + { url = "https://files.pythonhosted.org/packages/c6/25/98652109fd9f7e10268dd4571aa52b81987001b806f37ef1a18260de714a/rpds_py-2026.9.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:0f045bb053c9057720d72c56dffe30dffdc05997b2897a827b9325f0ab6623fa", size = 582606, upload-time = "2026-10-04T16:30:43.345Z" }, + { url = "https://files.pythonhosted.org/packages/19/03/11ca09099bab5f53373a80a334c424ec917c13d050760a59499d2af5171e/rpds_py-2026.9.1-cp314-cp314t-win32.whl", hash = "sha256:bf35d0568abda97233239ce32896d3ad53fccc537832c104e30c94aa5fb93569", size = 203341, upload-time = "2026-10-04T16:30:44.954Z" }, + { url = "https://files.pythonhosted.org/packages/6f/8a/88909e3ffd9f47f5b58211473875d8c3c09079f0058c46fb72c55a702a26/rpds_py-2026.9.1-cp314-cp314t-win_amd64.whl", hash = "sha256:1e8d4d79d828299bf44a55db22a9388ab967b49d17132c88eab0f4360b48da8e", size = 222843, upload-time = "2026-10-04T16:30:46.486Z" }, + { url = "https://files.pythonhosted.org/packages/f6/b7/a662f367d4896dd0a10cef2fc91f10b7f08af1c10858e287e019563f338d/rpds_py-2026.9.1-cp315-cp315-macosx_10_12_x86_64.whl", hash = "sha256:1d77b649e6f7cdf12ca5c2a98dad0ad37f9ea9b6f960408a92f0cb12bb3d04d9", size = 347463, upload-time = "2026-10-04T16:30:48.203Z" }, + { url = "https://files.pythonhosted.org/packages/ae/3f/ad45d03df4f84ebae5439577ee81f3999d182711e82235c8037b6528890e/rpds_py-2026.9.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:00ba2d8c7dd4ee537978ddf4b3fbd712bef2d8751603f7f3146b3f4287768e25", size = 342051, upload-time = "2026-10-04T16:30:49.872Z" }, + { url = "https://files.pythonhosted.org/packages/7e/31/3dcd68c13d4bcc59c1f7eb33ac8e80698f06f3eb0d8a1e06419836071c20/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ec450527cbf485e13c8d3602a54f428ab0432fdade0ede75efd74b735421c871", size = 374143, upload-time = "2026-10-04T16:30:51.508Z" }, + { url = "https://files.pythonhosted.org/packages/cf/0d/68c1f058a250fbd1380ebda9fc227cbf50117adf8ffe8161ef383ea79f68/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:306ee1850d8105b5baf977e78d45fcadd12c1a54678d614c9baf217708446e91", size = 378604, upload-time = "2026-10-04T16:30:53.206Z" }, + { url = "https://files.pythonhosted.org/packages/d7/d6/2d4c59b85397cb4800594fadf692688ccf5ce556adc930e7a5bf21061a5e/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ef6b65b03247c54692ad4fd9ee97cb772781927db72e3cb05e70b3db6d1ff14f", size = 490790, upload-time = "2026-10-04T16:30:54.925Z" }, + { url = "https://files.pythonhosted.org/packages/da/04/7e05dc3aebaf52f4e026766bd668fdd09a9d0e23f64a14686b36b3501892/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a575404ebc9cf2e91edd32eaf570ec1430eb900d4f56724ba7dd4bc1fc9c176d", size = 393146, upload-time = "2026-10-04T16:30:56.625Z" }, + { url = "https://files.pythonhosted.org/packages/57/ca/e2e9a0a46a74ed51a0498ba1fe10f4ea6b2d9a155f372a2f91e51f18cf10/rpds_py-2026.9.1-cp315-cp315-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2c16ab111bc27c646ba8aa005d0527754edc538ebb636f0b1bf8e244b48d1945", size = 372022, upload-time = "2026-10-04T16:30:58.295Z" }, + { url = "https://files.pythonhosted.org/packages/ba/cb/8f8774df5134e23424372838bcc5c7ed4127d723e1ff52f7bebd4dcb2563/rpds_py-2026.9.1-cp315-cp315-manylinux_2_31_riscv64.whl", hash = "sha256:7664419f27db41d4f1c43a78dccda7dd6e8ef2428df3ee01d0c2a07a6b071297", size = 377092, upload-time = "2026-10-04T16:30:59.984Z" }, + { url = "https://files.pythonhosted.org/packages/90/02/8d7095d73bf9114219be40230baa5df00611e0a82ed9517779ff9c19f82b/rpds_py-2026.9.1-cp315-cp315-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4b26b03d9d2658ee2fa234f8f4f19f38a09773fe5261028025032e26d4d35af0", size = 400830, upload-time = "2026-10-04T16:31:01.721Z" }, + { url = "https://files.pythonhosted.org/packages/ec/02/8206856f8f363cd042a8315dc86b3912f5dcb6d3c66bbb24b69c2bfb0775/rpds_py-2026.9.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:be3e47e2d91aa3942ff9bf4077a505226005abfc39b6f7554a91c1b9393986b9", size = 551478, upload-time = "2026-10-04T16:31:03.472Z" }, + { url = "https://files.pythonhosted.org/packages/41/6b/36211f1bb1f0b0313f496d92f5905b74ea107f27cb16fa3355a82f04575e/rpds_py-2026.9.1-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:6307a0da524939decb8ca4a3933b8ab62525794411d6984fca6726e732804af6", size = 615173, upload-time = "2026-10-04T16:31:05.281Z" }, + { url = "https://files.pythonhosted.org/packages/35/77/cda0c4a6f055446b692f0ed5692f73707cafd3dff82672ede31b1a9b59de/rpds_py-2026.9.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:159a7aab5c5e8b112c8830f54717ce56da1252ebdbb526f5be2df2309280b9e7", size = 579653, upload-time = "2026-10-04T16:31:07.065Z" }, + { url = "https://files.pythonhosted.org/packages/74/ec/d8385f446240aed643b9e92a5055cff3015cc04a13c61f73b2883c478ed5/rpds_py-2026.9.1-cp315-cp315-win32.whl", hash = "sha256:dbc2673f9223d420c91145599b3ba45a8a50c207d1976908e5fb5ddb0c9b9429", size = 206498, upload-time = "2026-10-04T16:31:08.989Z" }, + { url = "https://files.pythonhosted.org/packages/6d/a5/71b5cd00e0521e3b6b81828baea368c62b6b700ebdd9554cd7d41ddf12fa/rpds_py-2026.9.1-cp315-cp315-win_amd64.whl", hash = "sha256:75c38c50ab9aca840225d9a9a3810bf11d04bd5c1f186cabbb8aee56db3e9b15", size = 223121, upload-time = "2026-10-04T16:31:10.84Z" }, + { url = "https://files.pythonhosted.org/packages/33/58/dba857c3bc8221b31b62eb170a3080f4f191de79f047200389b7ed1b06a7/rpds_py-2026.9.1-cp315-cp315-win_arm64.whl", hash = "sha256:a431156bb41865fc14cd5d79bb9d7bbed83110b0159e34e62ae30951f96c0009", size = 218741, upload-time = "2026-10-04T16:31:12.592Z" }, + { url = "https://files.pythonhosted.org/packages/5b/d0/320ab28ccc1415eeb509d68682b0014fb74690cd49f1c2d29a232475af50/rpds_py-2026.9.1-cp315-cp315t-macosx_10_12_x86_64.whl", hash = "sha256:ef0d8c843e2827d6c120ab4687e9423fb1d893db1df27b7c1506615bcb9734a0", size = 349719, upload-time = "2026-10-04T16:31:14.48Z" }, + { url = "https://files.pythonhosted.org/packages/56/88/f5b12f1358f443c08b7ce3cc8391d82d335f4872580e2e097847fd36087a/rpds_py-2026.9.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:45bc6bccf78b20fd834237d18db64965d7ee68ba7f60440a26c7ab71e7b8d51a", size = 343267, upload-time = "2026-10-04T16:31:16.827Z" }, + { url = "https://files.pythonhosted.org/packages/f7/0c/c765b0059d532acb3b9c45d781ccc22f15a96dbe443d00903f643ba9df10/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1d55198263bb51f557550c6ed2e6d1cb6a6fed6eb5c9120b741c5926bef8a45d", size = 374555, upload-time = "2026-10-04T16:31:18.931Z" }, + { url = "https://files.pythonhosted.org/packages/6b/8a/cafddfda77564a10cd21184640c3bffda6a2b8d20972fb5dedd5e0166328/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a8763f20692da7df39b0afdd1ba3042b004c50a45994f76c2d9a25641f7673db", size = 378346, upload-time = "2026-10-04T16:31:20.75Z" }, + { url = "https://files.pythonhosted.org/packages/b9/01/5e626016eff72c183bf6c96539240cace15d402468647a453ec08415b2fc/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e43d4a1f673e8a1cbd8533e809e02b4bf9d4f2280269bb640436556312121250", size = 492373, upload-time = "2026-10-04T16:31:22.614Z" }, + { url = "https://files.pythonhosted.org/packages/3b/9c/15a2469e9389242f46896b3f0a01d68caea8a5a35c011fcb05ef333aae73/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ea394a937f17a54c51239348bdbe2e3518124c8d4a8951ba04a311d3095bd18f", size = 394371, upload-time = "2026-10-04T16:31:24.768Z" }, + { url = "https://files.pythonhosted.org/packages/63/f5/c100ff77e1e6366e947c75969c258fdfc4b7bc5bbfe7351e62ffbf2a1228/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cdeaa99ce822dca76cfb1b993e9120c5ea212f2eb66d48950ad63c349668a018", size = 375132, upload-time = "2026-10-04T16:31:26.588Z" }, + { url = "https://files.pythonhosted.org/packages/dd/f4/fe0269c9de253e99c81cabc12b8971a5feaa083debdaff1221e06264d9e3/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_31_riscv64.whl", hash = "sha256:b4f062343e7ad3fa94f2c66e5ae667dee47ee74dd41a9057c4fbe163236a123d", size = 377642, upload-time = "2026-10-04T16:31:28.677Z" }, + { url = "https://files.pythonhosted.org/packages/05/65/b34a7b257baccff8f4a24a722933166d4941d5ebdc9c3f4bc4ffcd5ce4f4/rpds_py-2026.9.1-cp315-cp315t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:22ffd29a63d71fb1b81552c21f2c2b734949b7ac751a9be70675a939a900839b", size = 400855, upload-time = "2026-10-04T16:31:30.802Z" }, + { url = "https://files.pythonhosted.org/packages/98/32/844e54176b6071b90b38a564e6940bc6eb8f97b2890dc709c19db9dec0f4/rpds_py-2026.9.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:08dae4a4095150a7c4545a1fb40b98e1ab1744fbc2770d92c977b9dadaa49ab6", size = 552573, upload-time = "2026-10-04T16:31:32.709Z" }, + { url = "https://files.pythonhosted.org/packages/17/73/6041d20729dffbfdf155c02d65be58bc225a1c1fb548fd87c23ef306138f/rpds_py-2026.9.1-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:9a0460d43603d1fd9ef59c30278531e15d78581721ddb538fa560aa7817ea4ad", size = 615840, upload-time = "2026-10-04T16:31:34.565Z" }, + { url = "https://files.pythonhosted.org/packages/af/9e/418094adaee6b056ce199051b255448ed872829051e341b2294c80da0977/rpds_py-2026.9.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:1c2d1f6da5128eabf34e963d7163a818846075a52568250d006c4c953b40f903", size = 582764, upload-time = "2026-10-04T16:31:36.665Z" }, + { url = "https://files.pythonhosted.org/packages/3d/9b/1698ebf6b840ddfe8b472198abbed6ace35c6e398faeecd6c47dae742a4e/rpds_py-2026.9.1-cp315-cp315t-win32.whl", hash = "sha256:5c6ee90dee3e85e055ddfd502d611643d9b0fd94c818220bda84ec3dacd9b27b", size = 203795, upload-time = "2026-10-04T16:31:38.53Z" }, + { url = "https://files.pythonhosted.org/packages/8a/e2/91f70d804c61f8eac39a417e82aa1024f655ab9e8bdd7393b196242bc41b/rpds_py-2026.9.1-cp315-cp315t-win_amd64.whl", hash = "sha256:fe5ad0664ec772b02c45859041aa17655709cced7a31005817fbbbd988c25567", size = 223037, upload-time = "2026-10-04T16:31:40.468Z" }, + { url = "https://files.pythonhosted.org/packages/f3/ad/f0eba548e297987964ef8088403db875b333963bf8189f3f563b6936b20e/rpds_py-2026.9.1-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4c0d2cb595a420b34d5086db0add011e26e2c09d6a024afbac4228bf8f863a30", size = 384112, upload-time = "2026-10-04T16:31:42.643Z" }, + { url = "https://files.pythonhosted.org/packages/33/89/891fa4d81f1eae7fe262ecd0aba2c51de94a116c7f3ccfb034fa75f4c537/rpds_py-2026.9.1-pp311-pypy311_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f3d6ed6a98cfd19155996605474982cc470d7601746a6439078f1a5a3fa8b050", size = 389662, upload-time = "2026-10-04T16:31:44.642Z" }, + { url = "https://files.pythonhosted.org/packages/4f/46/912cf623b2263f9c9c2d04e8508fc38dbe89983faeba5fb36ca4558ae550/rpds_py-2026.9.1-pp311-pypy311_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8171b44a054e5c67fd748ada04187f1250bf35b95f85e52ab64bcf3331a923bb", size = 504637, upload-time = "2026-10-04T16:31:46.667Z" }, + { url = "https://files.pythonhosted.org/packages/9b/5c/7f3cfa7c5f01765c9f47c8398210ed0c1eb686c0e99c223cb1c6776d3fb9/rpds_py-2026.9.1-pp311-pypy311_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fda1d96e542c37b6c804547dbf489c129fe7c97183a76a5ec275909ba1a063df", size = 402607, upload-time = "2026-10-04T16:31:49.068Z" }, + { url = "https://files.pythonhosted.org/packages/f0/76/2e915d4115ee453c33e6af17bc1df7e22ddc52974e178eeeb92a78c09983/rpds_py-2026.9.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:270bdcdaac5d5b6f73c5e22e7e135c7f2a50e789f71d9e241d5be8d90026e19a", size = 382762, upload-time = "2026-10-04T16:31:51.24Z" }, + { url = "https://files.pythonhosted.org/packages/0d/e5/844382925d7b84a4074ad79fc2b9d05eb6231ea243b34f247e68e519b606/rpds_py-2026.9.1-pp311-pypy311_pp73-manylinux_2_31_riscv64.whl", hash = "sha256:84a6ecc0c940169190d2c23bd969debd48c94dbc855acd60188a68d71d421608", size = 389563, upload-time = "2026-10-04T16:31:53.549Z" }, + { url = "https://files.pythonhosted.org/packages/81/82/d6e3951602dc2e24790ef9d299aa24bf5e2493df5043f2c6da00480cc447/rpds_py-2026.9.1-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ab4b2fda7c2b542f7f9d886cc6a838c5079d2b76f72e6081411faba11adde2c9", size = 416842, upload-time = "2026-10-04T16:31:55.76Z" }, + { url = "https://files.pythonhosted.org/packages/ea/1c/8d248e4ea671d525ab7daa0703ad81cc2175076fa0ccd7ef088facbd2b01/rpds_py-2026.9.1-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:44b32a7c4f0da3d28af31c259e38ddcff096f855e205ed0671d02fcf44f1ea1c", size = 562434, upload-time = "2026-10-04T16:31:57.874Z" }, + { url = "https://files.pythonhosted.org/packages/ad/38/e7ac0db898120d15dea25e3661b1242a40cb3b23d1f4db86c15a01fe0ba1/rpds_py-2026.9.1-pp311-pypy311_pp73-musllinux_1_2_i686.whl", hash = "sha256:a3dbc5ed9514908d5046107d7b1346bde71eea61de6e0e4919c19354f97e769f", size = 627909, upload-time = "2026-10-04T16:31:59.977Z" }, + { url = "https://files.pythonhosted.org/packages/03/c8/37e555514932cb1ee36c75349187aa882a98dee5d5654c761699ed8a0d27/rpds_py-2026.9.1-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:6eae33003518fd4cb4f83a218d5371469dd3001aa3b87128c005b07762f7fe5e", size = 593658, upload-time = "2026-10-04T16:32:02.14Z" }, + { url = "https://files.pythonhosted.org/packages/12/5c/5f69a91add94a8a33acea68a2b034a464946a654ff7296af9d957ef0d6a5/rpds_py-2026.9.1-pp311-pypy311_pp80-macosx_10_12_x86_64.whl", hash = "sha256:0483515261947e4e8b8e1375bf7463e7eb6ccfb3d86e7b554d90cd5285f20f32", size = 351769, upload-time = "2026-10-04T16:32:04.675Z" }, + { url = "https://files.pythonhosted.org/packages/41/22/35ea8bf3b2682b90ab687c74e4828418ff12298a5b0b0a0c033f61c86a30/rpds_py-2026.9.1-pp311-pypy311_pp80-macosx_11_0_arm64.whl", hash = "sha256:4cfaf02209061880210819934de2f4f6aa83dc04dafe6770276acc240a56da31", size = 351719, upload-time = "2026-10-04T16:32:06.834Z" }, + { url = "https://files.pythonhosted.org/packages/a3/90/a9ba81408369d34c1aca73319c15adc91ed45c1d21e9e8ee4832ffb7fe0b/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6cdc537c8633d7fd92a82e2e0d2ab74320a3f63d5e59fb9cf08711e08fe151c4", size = 381109, upload-time = "2026-10-04T16:32:08.994Z" }, + { url = "https://files.pythonhosted.org/packages/b3/44/5192a0bed94cec86bd2a5e1cc5a1bb8f7eec3aec907eacd2deb13e87e326/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:10e208f2425d973938afcd56e28a7c4be32e27b6a60b5d381f49fb9d8acf9759", size = 388222, upload-time = "2026-10-04T16:32:11.321Z" }, + { url = "https://files.pythonhosted.org/packages/92/cd/5356549711448f18b52f7a11ffbe90f1228774996fbf3c6cd1b18d22abaf/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6c0dbbcc19735fe5f8b0a54c07659d154a9e69f47e15d0a6ab7299215daf62cb", size = 500384, upload-time = "2026-10-04T16:32:13.478Z" }, + { url = "https://files.pythonhosted.org/packages/7a/88/ddda9d28adfe33119c75b2e733d4ba7e326f41d7e1b1093951771768ca48/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:684fd492fff4fead00587544e059be2bbcb6f93454f21fa2a91b66fc7508be82", size = 401661, upload-time = "2026-10-04T16:32:15.653Z" }, + { url = "https://files.pythonhosted.org/packages/32/c3/bb59ba16a6b4a57995d15b8c04c00f28df3b938c4dcdde48fbe0f73edb0c/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d1028417bb44037eb3069c1009bd7b7277212876cda22fbe565b0bca9fab6d2c", size = 380748, upload-time = "2026-10-04T16:32:17.727Z" }, + { url = "https://files.pythonhosted.org/packages/f5/b8/0580faa1c5a32ddc160130dd7ae54d2d007272a89a40a6b5db3e50f9f585/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_31_riscv64.whl", hash = "sha256:492e5e428cbe126221611f47e068f01660352feec4ad18bc0f5ea9b2ae88fb14", size = 385731, upload-time = "2026-10-04T16:32:19.855Z" }, + { url = "https://files.pythonhosted.org/packages/bf/70/f73564642bbe3322c7eeef2c2f258cf040b71c41a430b532e59d04a1b838/rpds_py-2026.9.1-pp312-pypy312_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:88b5268892fde430d5531f95bc560b6efbbd67c929662c586afd729a96e7461c", size = 412131, upload-time = "2026-10-04T16:32:22.285Z" }, + { url = "https://files.pythonhosted.org/packages/8c/5d/17fff2e1f8f68721a2afb5cb48f7e442c751bb6b4883157c5abaf618cd08/rpds_py-2026.9.1-pp312-pypy312_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:01445c8d194aa032a08e944f16567672da1c62dbdbefd8b6d0693032e290cf68", size = 558193, upload-time = "2026-10-04T16:32:24.4Z" }, + { url = "https://files.pythonhosted.org/packages/2a/d0/869ab6fb08531f97aae4a780b4d61b4190d8aef48fe054ee28bcf7114466/rpds_py-2026.9.1-pp312-pypy312_pp73-musllinux_1_2_i686.whl", hash = "sha256:eef6a03b0b6d08d0835ccfa8ec8d1bc70525e3801387567137b50c557695e6da", size = 622448, upload-time = "2026-10-04T16:32:26.844Z" }, + { url = "https://files.pythonhosted.org/packages/ba/a5/9672e532fe02cd3b92c78cfd8743abca939d96853006c63835009a1ecb6f/rpds_py-2026.9.1-pp312-pypy312_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:6b9bf3135b4ad5981df9a73d71a35272d650a2985ae9c2746357b24d59de2448", size = 591126, upload-time = "2026-10-04T16:32:29.274Z" }, + { url = "https://files.pythonhosted.org/packages/80/ef/3a9f8e4279c7920af561deed4cb7ebebed2794a8f608cf404d5eef14a105/rpds_py-2026.9.1-pp312-pypy312_pp80-macosx_10_12_x86_64.whl", hash = "sha256:56c6952a9b15047466d0c2347c446a761d4527f89976156341e68f0ce5cc08b0", size = 357108, upload-time = "2026-10-04T16:32:31.641Z" }, + { url = "https://files.pythonhosted.org/packages/b7/55/4b2fa381a583760aea5c92841e4e928a358e1c6511b129219e9c2826a226/rpds_py-2026.9.1-pp312-pypy312_pp80-macosx_11_0_arm64.whl", hash = "sha256:b242c27c8f836305a4a72df9cdd564386ac57b807bd252a063223331c9316b37", size = 346877, upload-time = "2026-10-04T16:32:34.061Z" }, +] + +[[package]] +name = "ruff" +version = "0.17.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/86/cc/7b71512eb8b49926efb887cc66c74dd993642943c29eba51a877f6b85692/ruff-0.17.5.tar.gz", hash = "sha256:625e57d80cd43352d12ea81690f3eac46cddc8c0f35026d137fb0f157f94592e", size = 5368382, upload-time = "2026-11-12T17:54:55.04Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d4/f2/61df414cb4338617290a9023ad09486e207fb9a6d09357a7be34f2e369a4/ruff-0.17.5-py3-none-linux_armv6l.whl", hash = "sha256:d511dd302982e46a285528942fa6557d57730edc4bdb9def95e86a2603d77396", size = 10231309, upload-time = "2026-11-12T17:54:09.314Z" }, + { url = "https://files.pythonhosted.org/packages/d1/72/8ed970f3361f7c8d3f8e1b3b1af27cf086bc4b3a6b62ec20e21a1aaaaff5/ruff-0.17.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b72fbc232e328bdbb9cdddf4f1aedcd61bd1aa64d75fc012114b4add0bd7f26b", size = 10250018, upload-time = "2026-11-12T17:54:11.983Z" }, + { url = "https://files.pythonhosted.org/packages/dc/4b/8b10f6c9d0a18413301ae8dd2af9d180a81bb738b1b731d944a37404c523/ruff-0.17.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6f0db748508f04a04e3fbebcc636a5c8b3bd76274f8ed28f497c44d75c2ea2d7", size = 9504737, upload-time = "2026-11-12T17:54:14.567Z" }, + { url = "https://files.pythonhosted.org/packages/b7/ea/1b3afa3943239dede7a0755ea139bdb51879f0f3f96f92894081d5c7d2e5/ruff-0.17.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f6a7b138edf9cc402ca736a59d9525e6d766e5395760b72e7e146e6251ac963", size = 10168006, upload-time = "2026-11-12T17:54:17.195Z" }, + { url = "https://files.pythonhosted.org/packages/31/08/ee641daa45f83792f91274b65796cb011f1065f588911bfa3909ad9e31e7/ruff-0.17.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e52622ecf3a0df9d03e796fe3eed4aa085adda65520db7e0619cbd2192a97342", size = 10043751, upload-time = "2026-11-12T17:54:19.815Z" }, + { url = "https://files.pythonhosted.org/packages/f8/cf/1c59fdb42d0b5671ad5b160636fab4005ee28db72cb06aef6e3f3c04f377/ruff-0.17.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54c0f67d1be11b55d12c184a819fc229f5eee3ef45c16c4fcad41258e83b4882", size = 10690562, upload-time = "2026-11-12T17:54:22.789Z" }, + { url = "https://files.pythonhosted.org/packages/49/c5/578074716173fb0c1591e9648a9f85c469888d9530cb35b89b757dc1208b/ruff-0.17.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dd0dfe7c6fe5a447fce467c58e69893be1d9a7e4378f5b9906432da33d94a97f", size = 11338465, upload-time = "2026-11-12T17:54:25.523Z" }, + { url = "https://files.pythonhosted.org/packages/aa/b9/d6428bcf5ed88f4dc1d6e3417ee350236ed36e7a35f9477b727c00e437bf/ruff-0.17.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ec4ecf40fb4d6e1265b009dbe551727920926fc0f769070c452d6d84b422a74d", size = 10895501, upload-time = "2026-11-12T17:54:28.441Z" }, + { url = "https://files.pythonhosted.org/packages/f2/8a/1e29c0c3785ae7e5cd0d54ee8717a08867ef71545796340be4c653c57e24/ruff-0.17.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40ca8afaac309b41a5b2e09e4e7beb1f824826b93c25697c4d74f573324fba4e", size = 10613231, upload-time = "2026-11-12T17:54:30.862Z" }, + { url = "https://files.pythonhosted.org/packages/32/b6/88944350c14bb90651014d678ad554e233ae2a79c14ad52101845f93d15b/ruff-0.17.5-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:8e85601bd6d9b6c3e3b95c0e0dccdbac1d23c6bcef006d187fbcddaf8225a5df", size = 10562789, upload-time = "2026-11-12T17:54:33.869Z" }, + { url = "https://files.pythonhosted.org/packages/6f/fd/2792e955b0bf54295cdcdddc4bb3f380c0790d7e60e789f528a9e6e48a31/ruff-0.17.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f93d2b7d449ed9545304f6923699ca20d13c675b69f258481709a08ae61076db", size = 10069824, upload-time = "2026-11-12T17:54:36.663Z" }, + { url = "https://files.pythonhosted.org/packages/07/9c/d7cad341b4c19237948a6dd1fcea1c9c39c9d08b70f22f0e157d1236ebd6/ruff-0.17.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0e5c125c5b31dc8efc948d41357496a4c4a312977565ccba740030efdff83580", size = 10038961, upload-time = "2026-11-12T17:54:39.452Z" }, + { url = "https://files.pythonhosted.org/packages/cc/a1/9cd0d4c371ddc70267d3bd557e718e2bdfb94c25e49d25605edfabb764bd/ruff-0.17.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:50dfc3c6b3ebd0a932f11dfd579bd42234b0b7137e68940eb6abdbfdb9d69697", size = 10385012, upload-time = "2026-11-12T17:54:41.808Z" }, + { url = "https://files.pythonhosted.org/packages/8f/a9/35f078ce98d4df318328ea5270382b5b65e680f7953b3db54f8e009c420c/ruff-0.17.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:86bd1f3b83c25f9b8055c6e796f0685b39d3127ce947322098c3108cf82fd586", size = 10793672, upload-time = "2026-11-12T17:54:44.342Z" }, + { url = "https://files.pythonhosted.org/packages/2c/a5/2e136dede2a88aaaf54498bbbdc81bc810f788ef6ef01efb97037d73cd1d/ruff-0.17.5-py3-none-win32.whl", hash = "sha256:e1546609b2ad73f1d6c5c076881b788672b7b3cc3283981182cbdbb6524ed88a", size = 9929908, upload-time = "2026-11-12T17:54:47.067Z" }, + { url = "https://files.pythonhosted.org/packages/ec/8c/e4db9ae1e0ee233c04df007ab6d0d42f799ae9abd95d352b6092ee7bc4bf/ruff-0.17.5-py3-none-win_amd64.whl", hash = "sha256:aa415d57c244299279901d776607fee3df7831c2a7435433fbfacde8632c6550", size = 10275454, upload-time = "2026-11-12T17:54:49.401Z" }, + { url = "https://files.pythonhosted.org/packages/e6/65/a1648bc1550e7683bf7bf1e2ce2485c9f8535cbca6cca9ec7b73cc12fb8e/ruff-0.17.5-py3-none-win_arm64.whl", hash = "sha256:64a6fd668a336df959c522991de33e9e3c8be463afc0c9ac8f029f9d19ef756e", size = 9849020, upload-time = "2026-11-12T17:54:52.055Z" }, +] + +[[package]] +name = "scipy" +version = "1.17.1" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.12'", +] +dependencies = [ + { name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" } }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7a/97/5a3609c4f8d58b039179648e62dd220f89864f56f7357f5d4f45c29eb2cc/scipy-1.17.1.tar.gz", hash = "sha256:95d8e012d8cb8816c226aef832200b1d45109ed4464303e997c5b13122b297c0", size = 30573822, upload-time = "2026-02-23T00:26:24.851Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/df/75/b4ce781849931fef6fd529afa6b63711d5a733065722d0c3e2724af9e40a/scipy-1.17.1-cp311-cp311-macosx_10_14_x86_64.whl", hash = "sha256:1f95b894f13729334fb990162e911c9e5dc1ab390c58aa6cbecb389c5b5e28ec", size = 31613675, upload-time = "2026-02-23T00:16:00.13Z" }, + { url = "https://files.pythonhosted.org/packages/f7/58/bccc2861b305abdd1b8663d6130c0b3d7cc22e8d86663edbc8401bfd40d4/scipy-1.17.1-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:e18f12c6b0bc5a592ed23d3f7b891f68fd7f8241d69b7883769eb5d5dfb52696", size = 28162057, upload-time = "2026-02-23T00:16:09.456Z" }, + { url = "https://files.pythonhosted.org/packages/6d/ee/18146b7757ed4976276b9c9819108adbc73c5aad636e5353e20746b73069/scipy-1.17.1-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:a3472cfbca0a54177d0faa68f697d8ba4c80bbdc19908c3465556d9f7efce9ee", size = 20334032, upload-time = "2026-02-23T00:16:17.358Z" }, + { url = "https://files.pythonhosted.org/packages/ec/e6/cef1cf3557f0c54954198554a10016b6a03b2ec9e22a4e1df734936bd99c/scipy-1.17.1-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:766e0dc5a616d026a3a1cffa379af959671729083882f50307e18175797b3dfd", size = 22709533, upload-time = "2026-02-23T00:16:25.791Z" }, + { url = "https://files.pythonhosted.org/packages/4d/60/8804678875fc59362b0fb759ab3ecce1f09c10a735680318ac30da8cd76b/scipy-1.17.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:744b2bf3640d907b79f3fd7874efe432d1cf171ee721243e350f55234b4cec4c", size = 33062057, upload-time = "2026-02-23T00:16:36.931Z" }, + { url = "https://files.pythonhosted.org/packages/09/7d/af933f0f6e0767995b4e2d705a0665e454d1c19402aa7e895de3951ebb04/scipy-1.17.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:43af8d1f3bea642559019edfe64e9b11192a8978efbd1539d7bc2aaa23d92de4", size = 35349300, upload-time = "2026-02-23T00:16:49.108Z" }, + { url = "https://files.pythonhosted.org/packages/b4/3d/7ccbbdcbb54c8fdc20d3b6930137c782a163fa626f0aef920349873421ba/scipy-1.17.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:cd96a1898c0a47be4520327e01f874acfd61fb48a9420f8aa9f6483412ffa444", size = 35127333, upload-time = "2026-02-23T00:17:01.293Z" }, + { url = "https://files.pythonhosted.org/packages/e8/19/f926cb11c42b15ba08e3a71e376d816ac08614f769b4f47e06c3580c836a/scipy-1.17.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:4eb6c25dd62ee8d5edf68a8e1c171dd71c292fdae95d8aeb3dd7d7de4c364082", size = 37741314, upload-time = "2026-02-23T00:17:12.576Z" }, + { url = "https://files.pythonhosted.org/packages/95/da/0d1df507cf574b3f224ccc3d45244c9a1d732c81dcb26b1e8a766ae271a8/scipy-1.17.1-cp311-cp311-win_amd64.whl", hash = "sha256:d30e57c72013c2a4fe441c2fcb8e77b14e152ad48b5464858e07e2ad9fbfceff", size = 36607512, upload-time = "2026-02-23T00:17:23.424Z" }, + { url = "https://files.pythonhosted.org/packages/68/7f/bdd79ceaad24b671543ffe0ef61ed8e659440eb683b66f033454dcee90eb/scipy-1.17.1-cp311-cp311-win_arm64.whl", hash = "sha256:9ecb4efb1cd6e8c4afea0daa91a87fbddbce1b99d2895d151596716c0b2e859d", size = 24599248, upload-time = "2026-02-23T00:17:34.561Z" }, + { url = "https://files.pythonhosted.org/packages/35/48/b992b488d6f299dbe3f11a20b24d3dda3d46f1a635ede1c46b5b17a7b163/scipy-1.17.1-cp312-cp312-macosx_10_14_x86_64.whl", hash = "sha256:35c3a56d2ef83efc372eaec584314bd0ef2e2f0d2adb21c55e6ad5b344c0dcb8", size = 31610954, upload-time = "2026-02-23T00:17:49.855Z" }, + { url = "https://files.pythonhosted.org/packages/b2/02/cf107b01494c19dc100f1d0b7ac3cc08666e96ba2d64db7626066cee895e/scipy-1.17.1-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:fcb310ddb270a06114bb64bbe53c94926b943f5b7f0842194d585c65eb4edd76", size = 28172662, upload-time = "2026-02-23T00:18:01.64Z" }, + { url = "https://files.pythonhosted.org/packages/cf/a9/599c28631bad314d219cf9ffd40e985b24d603fc8a2f4ccc5ae8419a535b/scipy-1.17.1-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:cc90d2e9c7e5c7f1a482c9875007c095c3194b1cfedca3c2f3291cdc2bc7c086", size = 20344366, upload-time = "2026-02-23T00:18:12.015Z" }, + { url = "https://files.pythonhosted.org/packages/35/f5/906eda513271c8deb5af284e5ef0206d17a96239af79f9fa0aebfe0e36b4/scipy-1.17.1-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:c80be5ede8f3f8eded4eff73cc99a25c388ce98e555b17d31da05287015ffa5b", size = 22704017, upload-time = "2026-02-23T00:18:21.502Z" }, + { url = "https://files.pythonhosted.org/packages/da/34/16f10e3042d2f1d6b66e0428308ab52224b6a23049cb2f5c1756f713815f/scipy-1.17.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e19ebea31758fac5893a2ac360fedd00116cbb7628e650842a6691ba7ca28a21", size = 32927842, upload-time = "2026-02-23T00:18:35.367Z" }, + { url = "https://files.pythonhosted.org/packages/01/8e/1e35281b8ab6d5d72ebe9911edcdffa3f36b04ed9d51dec6dd140396e220/scipy-1.17.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:02ae3b274fde71c5e92ac4d54bc06c42d80e399fec704383dcd99b301df37458", size = 35235890, upload-time = "2026-02-23T00:18:49.188Z" }, + { url = "https://files.pythonhosted.org/packages/c5/5c/9d7f4c88bea6e0d5a4f1bc0506a53a00e9fcb198de372bfe4d3652cef482/scipy-1.17.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8a604bae87c6195d8b1045eddece0514d041604b14f2727bbc2b3020172045eb", size = 35003557, upload-time = "2026-02-23T00:18:54.74Z" }, + { url = "https://files.pythonhosted.org/packages/65/94/7698add8f276dbab7a9de9fb6b0e02fc13ee61d51c7c3f85ac28b65e1239/scipy-1.17.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:f590cd684941912d10becc07325a3eeb77886fe981415660d9265c4c418d0bea", size = 37625856, upload-time = "2026-02-23T00:19:00.307Z" }, + { url = "https://files.pythonhosted.org/packages/a2/84/dc08d77fbf3d87d3ee27f6a0c6dcce1de5829a64f2eae85a0ecc1f0daa73/scipy-1.17.1-cp312-cp312-win_amd64.whl", hash = "sha256:41b71f4a3a4cab9d366cd9065b288efc4d4f3c0b37a91a8e0947fb5bd7f31d87", size = 36549682, upload-time = "2026-02-23T00:19:07.67Z" }, + { url = "https://files.pythonhosted.org/packages/bc/98/fe9ae9ffb3b54b62559f52dedaebe204b408db8109a8c66fdd04869e6424/scipy-1.17.1-cp312-cp312-win_arm64.whl", hash = "sha256:f4115102802df98b2b0db3cce5cb9b92572633a1197c77b7553e5203f284a5b3", size = 24547340, upload-time = "2026-02-23T00:19:12.024Z" }, + { url = "https://files.pythonhosted.org/packages/76/27/07ee1b57b65e92645f219b37148a7e7928b82e2b5dbeccecb4dff7c64f0b/scipy-1.17.1-cp313-cp313-macosx_10_14_x86_64.whl", hash = "sha256:5e3c5c011904115f88a39308379c17f91546f77c1667cea98739fe0fccea804c", size = 31590199, upload-time = "2026-02-23T00:19:17.192Z" }, + { url = "https://files.pythonhosted.org/packages/ec/ae/db19f8ab842e9b724bf5dbb7db29302a91f1e55bc4d04b1025d6d605a2c5/scipy-1.17.1-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:6fac755ca3d2c3edcb22f479fceaa241704111414831ddd3bc6056e18516892f", size = 28154001, upload-time = "2026-02-23T00:19:22.241Z" }, + { url = "https://files.pythonhosted.org/packages/5b/58/3ce96251560107b381cbd6e8413c483bbb1228a6b919fa8652b0d4090e7f/scipy-1.17.1-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:7ff200bf9d24f2e4d5dc6ee8c3ac64d739d3a89e2326ba68aaf6c4a2b838fd7d", size = 20325719, upload-time = "2026-02-23T00:19:26.329Z" }, + { url = "https://files.pythonhosted.org/packages/b2/83/15087d945e0e4d48ce2377498abf5ad171ae013232ae31d06f336e64c999/scipy-1.17.1-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:4b400bdc6f79fa02a4d86640310dde87a21fba0c979efff5248908c6f15fad1b", size = 22683595, upload-time = "2026-02-23T00:19:30.304Z" }, + { url = "https://files.pythonhosted.org/packages/b4/e0/e58fbde4a1a594c8be8114eb4aac1a55bcd6587047efc18a61eb1f5c0d30/scipy-1.17.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2b64ca7d4aee0102a97f3ba22124052b4bd2152522355073580bf4845e2550b6", size = 32896429, upload-time = "2026-02-23T00:19:35.536Z" }, + { url = "https://files.pythonhosted.org/packages/f5/5f/f17563f28ff03c7b6799c50d01d5d856a1d55f2676f537ca8d28c7f627cd/scipy-1.17.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:581b2264fc0aa555f3f435a5944da7504ea3a065d7029ad60e7c3d1ae09c5464", size = 35203952, upload-time = "2026-02-23T00:19:42.259Z" }, + { url = "https://files.pythonhosted.org/packages/8d/a5/9afd17de24f657fdfe4df9a3f1ea049b39aef7c06000c13db1530d81ccca/scipy-1.17.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:beeda3d4ae615106d7094f7e7cef6218392e4465cc95d25f900bebabfded0950", size = 34979063, upload-time = "2026-02-23T00:19:47.547Z" }, + { url = "https://files.pythonhosted.org/packages/8b/13/88b1d2384b424bf7c924f2038c1c409f8d88bb2a8d49d097861dd64a57b2/scipy-1.17.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6609bc224e9568f65064cfa72edc0f24ee6655b47575954ec6339534b2798369", size = 37598449, upload-time = "2026-02-23T00:19:53.238Z" }, + { url = "https://files.pythonhosted.org/packages/35/e5/d6d0e51fc888f692a35134336866341c08655d92614f492c6860dc45bb2c/scipy-1.17.1-cp313-cp313-win_amd64.whl", hash = "sha256:37425bc9175607b0268f493d79a292c39f9d001a357bebb6b88fdfaff13f6448", size = 36510943, upload-time = "2026-02-23T00:20:50.89Z" }, + { url = "https://files.pythonhosted.org/packages/2a/fd/3be73c564e2a01e690e19cc618811540ba5354c67c8680dce3281123fb79/scipy-1.17.1-cp313-cp313-win_arm64.whl", hash = "sha256:5cf36e801231b6a2059bf354720274b7558746f3b1a4efb43fcf557ccd484a87", size = 24545621, upload-time = "2026-02-23T00:20:55.871Z" }, + { url = "https://files.pythonhosted.org/packages/6f/6b/17787db8b8114933a66f9dcc479a8272e4b4da75fe03b0c282f7b0ade8cd/scipy-1.17.1-cp313-cp313t-macosx_10_14_x86_64.whl", hash = "sha256:d59c30000a16d8edc7e64152e30220bfbd724c9bbb08368c054e24c651314f0a", size = 31936708, upload-time = "2026-02-23T00:19:58.694Z" }, + { url = "https://files.pythonhosted.org/packages/38/2e/524405c2b6392765ab1e2b722a41d5da33dc5c7b7278184a8ad29b6cb206/scipy-1.17.1-cp313-cp313t-macosx_12_0_arm64.whl", hash = "sha256:010f4333c96c9bb1a4516269e33cb5917b08ef2166d5556ca2fd9f082a9e6ea0", size = 28570135, upload-time = "2026-02-23T00:20:03.934Z" }, + { url = "https://files.pythonhosted.org/packages/fd/c3/5bd7199f4ea8556c0c8e39f04ccb014ac37d1468e6cfa6a95c6b3562b76e/scipy-1.17.1-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:2ceb2d3e01c5f1d83c4189737a42d9cb2fc38a6eeed225e7515eef71ad301dce", size = 20741977, upload-time = "2026-02-23T00:20:07.935Z" }, + { url = "https://files.pythonhosted.org/packages/d9/b8/8ccd9b766ad14c78386599708eb745f6b44f08400a5fd0ade7cf89b6fc93/scipy-1.17.1-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:844e165636711ef41f80b4103ed234181646b98a53c8f05da12ca5ca289134f6", size = 23029601, upload-time = "2026-02-23T00:20:12.161Z" }, + { url = "https://files.pythonhosted.org/packages/6d/a0/3cb6f4d2fb3e17428ad2880333cac878909ad1a89f678527b5328b93c1d4/scipy-1.17.1-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:158dd96d2207e21c966063e1635b1063cd7787b627b6f07305315dd73d9c679e", size = 33019667, upload-time = "2026-02-23T00:20:17.208Z" }, + { url = "https://files.pythonhosted.org/packages/f3/c3/2d834a5ac7bf3a0c806ad1508efc02dda3c8c61472a56132d7894c312dea/scipy-1.17.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:74cbb80d93260fe2ffa334efa24cb8f2f0f622a9b9febf8b483c0b865bfb3475", size = 35264159, upload-time = "2026-02-23T00:20:23.087Z" }, + { url = "https://files.pythonhosted.org/packages/4d/77/d3ed4becfdbd217c52062fafe35a72388d1bd82c2d0ba5ca19d6fcc93e11/scipy-1.17.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:dbc12c9f3d185f5c737d801da555fb74b3dcfa1a50b66a1a93e09190f41fab50", size = 35102771, upload-time = "2026-02-23T00:20:28.636Z" }, + { url = "https://files.pythonhosted.org/packages/bd/12/d19da97efde68ca1ee5538bb261d5d2c062f0c055575128f11a2730e3ac1/scipy-1.17.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:94055a11dfebe37c656e70317e1996dc197e1a15bbcc351bcdd4610e128fe1ca", size = 37665910, upload-time = "2026-02-23T00:20:34.743Z" }, + { url = "https://files.pythonhosted.org/packages/06/1c/1172a88d507a4baaf72c5a09bb6c018fe2ae0ab622e5830b703a46cc9e44/scipy-1.17.1-cp313-cp313t-win_amd64.whl", hash = "sha256:e30bdeaa5deed6bc27b4cc490823cd0347d7dae09119b8803ae576ea0ce52e4c", size = 36562980, upload-time = "2026-02-23T00:20:40.575Z" }, + { url = "https://files.pythonhosted.org/packages/70/b0/eb757336e5a76dfa7911f63252e3b7d1de00935d7705cf772db5b45ec238/scipy-1.17.1-cp313-cp313t-win_arm64.whl", hash = "sha256:a720477885a9d2411f94a93d16f9d89bad0f28ca23c3f8daa521e2dcc3f44d49", size = 24856543, upload-time = "2026-02-23T00:20:45.313Z" }, + { url = "https://files.pythonhosted.org/packages/cf/83/333afb452af6f0fd70414dc04f898647ee1423979ce02efa75c3b0f2c28e/scipy-1.17.1-cp314-cp314-macosx_10_14_x86_64.whl", hash = "sha256:a48a72c77a310327f6a3a920092fa2b8fd03d7deaa60f093038f22d98e096717", size = 31584510, upload-time = "2026-02-23T00:21:01.015Z" }, + { url = "https://files.pythonhosted.org/packages/ed/a6/d05a85fd51daeb2e4ea71d102f15b34fedca8e931af02594193ae4fd25f7/scipy-1.17.1-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:45abad819184f07240d8a696117a7aacd39787af9e0b719d00285549ed19a1e9", size = 28170131, upload-time = "2026-02-23T00:21:05.888Z" }, + { url = "https://files.pythonhosted.org/packages/db/7b/8624a203326675d7746a254083a187398090a179335b2e4a20e2ddc46e83/scipy-1.17.1-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:3fd1fcdab3ea951b610dc4cef356d416d5802991e7e32b5254828d342f7b7e0b", size = 20342032, upload-time = "2026-02-23T00:21:09.904Z" }, + { url = "https://files.pythonhosted.org/packages/c9/35/2c342897c00775d688d8ff3987aced3426858fd89d5a0e26e020b660b301/scipy-1.17.1-cp314-cp314-macosx_14_0_x86_64.whl", hash = "sha256:7bdf2da170b67fdf10bca777614b1c7d96ae3ca5794fd9587dce41eb2966e866", size = 22678766, upload-time = "2026-02-23T00:21:14.313Z" }, + { url = "https://files.pythonhosted.org/packages/ef/f2/7cdb8eb308a1a6ae1e19f945913c82c23c0c442a462a46480ce487fdc0ac/scipy-1.17.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:adb2642e060a6549c343603a3851ba76ef0b74cc8c079a9a58121c7ec9fe2350", size = 32957007, upload-time = "2026-02-23T00:21:19.663Z" }, + { url = "https://files.pythonhosted.org/packages/0b/2e/7eea398450457ecb54e18e9d10110993fa65561c4f3add5e8eccd2b9cd41/scipy-1.17.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:eee2cfda04c00a857206a4330f0c5e3e56535494e30ca445eb19ec624ae75118", size = 35221333, upload-time = "2026-02-23T00:21:25.278Z" }, + { url = "https://files.pythonhosted.org/packages/d9/77/5b8509d03b77f093a0d52e606d3c4f79e8b06d1d38c441dacb1e26cacf46/scipy-1.17.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:d2650c1fb97e184d12d8ba010493ee7b322864f7d3d00d3f9bb97d9c21de4068", size = 35042066, upload-time = "2026-02-23T00:21:31.358Z" }, + { url = "https://files.pythonhosted.org/packages/f9/df/18f80fb99df40b4070328d5ae5c596f2f00fffb50167e31439e932f29e7d/scipy-1.17.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:08b900519463543aa604a06bec02461558a6e1cef8fdbb8098f77a48a83c8118", size = 37612763, upload-time = "2026-02-23T00:21:37.247Z" }, + { url = "https://files.pythonhosted.org/packages/4b/39/f0e8ea762a764a9dc52aa7dabcfad51a354819de1f0d4652b6a1122424d6/scipy-1.17.1-cp314-cp314-win_amd64.whl", hash = "sha256:3877ac408e14da24a6196de0ddcace62092bfc12a83823e92e49e40747e52c19", size = 37290984, upload-time = "2026-02-23T00:22:35.023Z" }, + { url = "https://files.pythonhosted.org/packages/7c/56/fe201e3b0f93d1a8bcf75d3379affd228a63d7e2d80ab45467a74b494947/scipy-1.17.1-cp314-cp314-win_arm64.whl", hash = "sha256:f8885db0bc2bffa59d5c1b72fad7a6a92d3e80e7257f967dd81abb553a90d293", size = 25192877, upload-time = "2026-02-23T00:22:39.798Z" }, + { url = "https://files.pythonhosted.org/packages/96/ad/f8c414e121f82e02d76f310f16db9899c4fcde36710329502a6b2a3c0392/scipy-1.17.1-cp314-cp314t-macosx_10_14_x86_64.whl", hash = "sha256:1cc682cea2ae55524432f3cdff9e9a3be743d52a7443d0cba9017c23c87ae2f6", size = 31949750, upload-time = "2026-02-23T00:21:42.289Z" }, + { url = "https://files.pythonhosted.org/packages/7c/b0/c741e8865d61b67c81e255f4f0a832846c064e426636cd7de84e74d209be/scipy-1.17.1-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:2040ad4d1795a0ae89bfc7e8429677f365d45aa9fd5e4587cf1ea737f927b4a1", size = 28585858, upload-time = "2026-02-23T00:21:47.706Z" }, + { url = "https://files.pythonhosted.org/packages/ed/1b/3985219c6177866628fa7c2595bfd23f193ceebbe472c98a08824b9466ff/scipy-1.17.1-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:131f5aaea57602008f9822e2115029b55d4b5f7c070287699fe45c661d051e39", size = 20757723, upload-time = "2026-02-23T00:21:52.039Z" }, + { url = "https://files.pythonhosted.org/packages/c0/19/2a04aa25050d656d6f7b9e7b685cc83d6957fb101665bfd9369ca6534563/scipy-1.17.1-cp314-cp314t-macosx_14_0_x86_64.whl", hash = "sha256:9cdc1a2fcfd5c52cfb3045feb399f7b3ce822abdde3a193a6b9a60b3cb5854ca", size = 23043098, upload-time = "2026-02-23T00:21:56.185Z" }, + { url = "https://files.pythonhosted.org/packages/86/f1/3383beb9b5d0dbddd030335bf8a8b32d4317185efe495374f134d8be6cce/scipy-1.17.1-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6e3dcd57ab780c741fde8dc68619de988b966db759a3c3152e8e9142c26295ad", size = 33030397, upload-time = "2026-02-23T00:22:01.404Z" }, + { url = "https://files.pythonhosted.org/packages/41/68/8f21e8a65a5a03f25a79165ec9d2b28c00e66dc80546cf5eb803aeeff35b/scipy-1.17.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a9956e4d4f4a301ebf6cde39850333a6b6110799d470dbbb1e25326ac447f52a", size = 35281163, upload-time = "2026-02-23T00:22:07.024Z" }, + { url = "https://files.pythonhosted.org/packages/84/8d/c8a5e19479554007a5632ed7529e665c315ae7492b4f946b0deb39870e39/scipy-1.17.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:a4328d245944d09fd639771de275701ccadf5f781ba0ff092ad141e017eccda4", size = 35116291, upload-time = "2026-02-23T00:22:12.585Z" }, + { url = "https://files.pythonhosted.org/packages/52/52/e57eceff0e342a1f50e274264ed47497b59e6a4e3118808ee58ddda7b74a/scipy-1.17.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:a77cbd07b940d326d39a1d1b37817e2ee4d79cb30e7338f3d0cddffae70fcaa2", size = 37682317, upload-time = "2026-02-23T00:22:18.513Z" }, + { url = "https://files.pythonhosted.org/packages/11/2f/b29eafe4a3fbc3d6de9662b36e028d5f039e72d345e05c250e121a230dd4/scipy-1.17.1-cp314-cp314t-win_amd64.whl", hash = "sha256:eb092099205ef62cd1782b006658db09e2fed75bffcae7cc0d44052d8aa0f484", size = 37345327, upload-time = "2026-02-23T00:22:24.442Z" }, + { url = "https://files.pythonhosted.org/packages/07/39/338d9219c4e87f3e708f18857ecd24d22a0c3094752393319553096b98af/scipy-1.17.1-cp314-cp314t-win_arm64.whl", hash = "sha256:200e1050faffacc162be6a486a984a0497866ec54149a01270adc8a59b7c7d21", size = 25489165, upload-time = "2026-02-23T00:22:29.563Z" }, +] + +[[package]] +name = "scipy" +version = "1.18.1" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.15'", + "python_full_version == '3.14.*'", + "python_full_version >= '3.12' and python_full_version < '3.14'", +] +dependencies = [ + { name = "numpy", version = "2.5.4", source = { registry = "https://pypi.org/simple" } }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7e/74/66de6258867beb2ef08f35f9f2ac017a52cacd5081714d239ff1a442d458/scipy-1.18.1.tar.gz", hash = "sha256:52c4b7422442aba924d03ad4019852b08a92e64ea187b933135687bfe2747307", size = 30781235, upload-time = "2026-08-21T23:28:50.599Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/f7/240c110c08693826b4513a52f5717d62ec7c7af72f2920821247c03b17b3/scipy-1.18.1-cp312-cp312-macosx_10_15_x86_64.whl", hash = "sha256:457fd7a2a8edeb044ab6ffbc0aa03ff6cd18491356e5e0c834d76ce621b916d1", size = 31111061, upload-time = "2026-08-21T23:23:44.522Z" }, + { url = "https://files.pythonhosted.org/packages/05/4a/78c6285577c375e7cf27277ea8ee6961224327f1e1a0c44af5f17f23635c/scipy-1.18.1-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:e708533e8b2ae2497d65346538a7dcc92814410b25b81432eac66de0f2af8265", size = 28733332, upload-time = "2026-08-21T23:23:50.015Z" }, + { url = "https://files.pythonhosted.org/packages/a5/f6/a5b82f8abbe14d134691b8b903696f701d25a081353a29dc655c364d9e62/scipy-1.18.1-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:7bbf207c4453ce1ad2e00b17313852b33310b83090c2311bdaf97f93c0380d12", size = 20475078, upload-time = "2026-08-21T23:23:54.138Z" }, + { url = "https://files.pythonhosted.org/packages/23/22/0858a0bbd6b3e825ceb8cd9baf9eaf3b2f2b1d77727eb6be40500bcdc92f/scipy-1.18.1-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:78c0665edead396b1abb4897c41a5c1d9bf090c8a637a4c20a61678e0a264e66", size = 23108904, upload-time = "2026-08-21T23:23:57.824Z" }, + { url = "https://files.pythonhosted.org/packages/75/9a/2e71719f31eaefe0e3a1706c4a1ded94e664bfd95ffca2b219a671faee01/scipy-1.18.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3c085faa2cfa879c5141df483f836f4d691045a078224a670fa570fa01612d89", size = 34025113, upload-time = "2026-08-21T23:24:02.209Z" }, + { url = "https://files.pythonhosted.org/packages/df/64/ff35eb9e54894cf471ff4716abd3c81eb0a0626869217ce3e6ba4ccf17d7/scipy-1.18.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f55fa87b6c612ecd6b058f167c53231b1d14e412efe361d3d6e38b3631c73218", size = 35344199, upload-time = "2026-08-21T23:24:07.844Z" }, + { url = "https://files.pythonhosted.org/packages/d3/af/c5538be1792f7034c12c7db6ee67cace58253c7b87b122d68253eaf5de89/scipy-1.18.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:c35d74ce0e193ff740c2f2be2ac913ddc232fe6c1ff40b26cfecb9c670c63314", size = 35639587, upload-time = "2026-08-21T23:24:13.05Z" }, + { url = "https://files.pythonhosted.org/packages/91/4c/075e4f66471bac101141ac739e9e135549be1bae584571bd03a530c056e1/scipy-1.18.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:d2924a03db38dc2e848bca2fe9f077dafb891480b91a00a0963a8cf86dfc31c1", size = 37480330, upload-time = "2026-08-21T23:24:19.608Z" }, + { url = "https://files.pythonhosted.org/packages/39/e7/979fd14e75008623df31ba70d6bb144700f68feadcea042021c06a05bf82/scipy-1.18.1-cp312-cp312-win_amd64.whl", hash = "sha256:5e4d44984abc0020154ea81b247adeddcc3ac5527b975ff798bd1ba0adc513c2", size = 36658278, upload-time = "2026-08-21T23:24:25.463Z" }, + { url = "https://files.pythonhosted.org/packages/c7/0b/e1525354ff9d7d5feb6d1b31af6d14072e5c91e9607b421fa1ec889660b3/scipy-1.18.1-cp312-cp312-win_arm64.whl", hash = "sha256:d65d448389b8436493abcf629cc94ad0cf32aecaf06e1acca1de53cc795f2f12", size = 24400588, upload-time = "2026-08-21T23:24:30.579Z" }, + { url = "https://files.pythonhosted.org/packages/b6/55/4540ee0f9c42a9ad7109d0d1a8cc70de54c3572b01c6693a2b1c70e90ceb/scipy-1.18.1-cp313-cp313-macosx_10_15_x86_64.whl", hash = "sha256:3ab3523da44749156e1f68b464dc56af11ae4cbc5c739a49d05f32b982eca9f3", size = 31089958, upload-time = "2026-08-21T23:24:35.8Z" }, + { url = "https://files.pythonhosted.org/packages/2a/f5/769f36d14922b8071a43e95d24d18b6bdafad10d7f5cf647867e1ac052bc/scipy-1.18.1-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:e6fb6a55cc0ba97b59a1f288fb86dc6fce8bdfc0fffcbfd015e3a954bf2a2d93", size = 28715106, upload-time = "2026-08-21T23:24:40.775Z" }, + { url = "https://files.pythonhosted.org/packages/9a/d7/21d890274f75ea37a8209d5519e72da3da90302e3b9fb8397a0918386a62/scipy-1.18.1-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:ea324d9dd34c38bfb9bec8ca4d1b407db97dbb74029f566b8e322b1b6fe56fe6", size = 20456846, upload-time = "2026-08-21T23:24:45.066Z" }, + { url = "https://files.pythonhosted.org/packages/ec/01/798430ecea2e78ec7c02663d5f71c007bb6abeca931080debd40d7fa55ea/scipy-1.18.1-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:75b00eb8fb802090aa903f4ea1c7f5a584779f967361e68b7e98e531cc2d7174", size = 23087986, upload-time = "2026-08-21T23:24:49.539Z" }, + { url = "https://files.pythonhosted.org/packages/e6/5f/4634e9d35c68496e4e34cb6946eafab044458e6cedab42b40b6588e475b6/scipy-1.18.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d416b16cccfd70fbf62400e84d0bb2f4e6af519a45557f1692c749b37f14b315", size = 33998146, upload-time = "2026-08-21T23:24:54.714Z" }, + { url = "https://files.pythonhosted.org/packages/41/48/6450ed9243315322bbc19ac57b9b70d66a20bf1d38d124c96bc4bf6af9ea/scipy-1.18.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fdaf5ea890a6183d0565f51a61799d67081bd5b1cf03c5f4b3fd3732108625c9", size = 35312578, upload-time = "2026-08-21T23:25:00.44Z" }, + { url = "https://files.pythonhosted.org/packages/00/bd/bf5a4be6a3525676499f6dff307991739ff6fdcad1481b1aeb6745339f58/scipy-1.18.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:c825cef2f49e46753726a7181a8e199804a912b29519ada542c6ebc654951899", size = 35612621, upload-time = "2026-08-21T23:25:06.144Z" }, + { url = "https://files.pythonhosted.org/packages/bd/4e/3c45c33e00a77996c4b1cb707929f833ba7b1d522ee29f882512c330676d/scipy-1.18.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e3b417bf8c2c7c16e8f58ad91db17783ec911ac16e7b50eb6eab6e809b4f5b07", size = 37457323, upload-time = "2026-08-21T23:25:12.483Z" }, + { url = "https://files.pythonhosted.org/packages/93/0e/e0348fbc0dbab65c114cf78957e7dfeb49f8e8b556b4d930cc12ff195e18/scipy-1.18.1-cp313-cp313-win_amd64.whl", hash = "sha256:559ed65f60c1af5a03f3912605a1b5114f522c7c32fb23c3376ae8f03219fe28", size = 36622841, upload-time = "2026-08-21T23:25:18.722Z" }, + { url = "https://files.pythonhosted.org/packages/50/a8/6a77f5f267c555108f0a864b6db714363dab567a8266422a79a385f9232b/scipy-1.18.1-cp313-cp313-win_arm64.whl", hash = "sha256:cd479fc04dd9401e3b4f49e76518768ef99c4f517a98c284eb091fd725719adf", size = 24399315, upload-time = "2026-08-21T23:25:23.458Z" }, + { url = "https://files.pythonhosted.org/packages/06/d5/d8eb4e280ddb56a4ab2c6f02ee49b56b23f6e977cf0802fd6d68dbef14f5/scipy-1.18.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:83de5453a7799afc9048b4616bd085cef126e36412f0ea2f6370c36a2a3a51e7", size = 31090936, upload-time = "2026-08-21T23:25:28.686Z" }, + { url = "https://files.pythonhosted.org/packages/2a/49/59ea385dc3a62ff498ddf3cfff7c2b41b0f9f9d3c4122b3f1dcb6d6327fe/scipy-1.18.1-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:9554bcc6d715ee87a633a3cc8e7703c6628b100dd29cb8a2efc4c0533c7ff729", size = 28725221, upload-time = "2026-08-21T23:25:33.244Z" }, + { url = "https://files.pythonhosted.org/packages/70/e8/6b0c288c50942d78193696c9f15f9a0874f5178aa0ddf40f83d9924b3e8d/scipy-1.18.1-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:011413b7426b75012840e35649e00fe0a2c3bae89fed433876e3a99251572efc", size = 20466839, upload-time = "2026-08-21T23:25:37.516Z" }, + { url = "https://files.pythonhosted.org/packages/4b/e0/54fd3793c729e3b936782f181b59cbb1205bf250ab605a16cb1ba61cdd5e/scipy-1.18.1-cp314-cp314-macosx_14_0_x86_64.whl", hash = "sha256:88f0e784020649f88ea48c9f5ddfa403bf9205820667c0914740b392035afb82", size = 23089121, upload-time = "2026-08-21T23:25:42.019Z" }, + { url = "https://files.pythonhosted.org/packages/0b/56/030af62bea3cf878e0028515dff78c123b01633606a879b63f42d2db99cc/scipy-1.18.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2d3ab0e8c69a17dd3559eab8cbb88f258e285c94d572c2719033f90f83290c89", size = 34053851, upload-time = "2026-08-21T23:25:47.998Z" }, + { url = "https://files.pythonhosted.org/packages/6b/89/2a844506d49651e9aa1af6ef95b6bd8031cb1d5a4375edec6155037e04cf/scipy-1.18.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ac0333bdf38309aa3dcbe7e3fa7ea29e7a2c37c6ea306a757b700ded8e4596ad", size = 35329183, upload-time = "2026-08-21T23:25:53.522Z" }, + { url = "https://files.pythonhosted.org/packages/eb/56/c7370c3640e92ac9613cbf26cb3f729f9b12ddf1727b55b94b53b24d6f48/scipy-1.18.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:911de823097db8b63f034299d12662db93344e6ffa0b881cbb57748974b70168", size = 35672551, upload-time = "2026-08-21T23:25:59.387Z" }, + { url = "https://files.pythonhosted.org/packages/24/16/ec8536f351421f8bf60a1120930638f83790f4710b8230446aca3d6159d4/scipy-1.18.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:95298364e251be3e60249facbeeca03631d3bb7584f85879516ec55ac717b81f", size = 37469416, upload-time = "2026-08-21T23:26:05.432Z" }, + { url = "https://files.pythonhosted.org/packages/52/94/d73da0d28f16c45bb9b0a5691b91610b0275c5ef0eb5e43c87cf2dc1bf31/scipy-1.18.1-cp314-cp314-win_amd64.whl", hash = "sha256:78a0d7c918e74a232394117160e7e3db503377572a45bcef8826e4ab8a35feba", size = 37362755, upload-time = "2026-08-21T23:26:11.366Z" }, + { url = "https://files.pythonhosted.org/packages/89/25/e996e4dc74e10e227b1e14db5eaf6608bb6dd33884a64851c38f18dd4249/scipy-1.18.1-cp314-cp314-win_arm64.whl", hash = "sha256:cbf38d043c1aa4ab306e1ada6ab6eddacc3322a20b7af1b30bc93254b366fe09", size = 25036090, upload-time = "2026-08-21T23:26:15.887Z" }, + { url = "https://files.pythonhosted.org/packages/fa/c9/c00213f92309d753b48903e6a451b87eb52ff5b7a16e789d1568bbf221c4/scipy-1.18.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:0fcb3c93519f27bb4f0c4b0f7802cdcaca7fcf93267b75edda2e9f4e8a55cbd7", size = 31485550, upload-time = "2026-08-21T23:26:20.776Z" }, + { url = "https://files.pythonhosted.org/packages/74/b2/e3067c487982d4eeab2938928529410370c06fea84a4d3f4925e7d96647d/scipy-1.18.1-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:ddef79fb382df40104a19bb7151b3b23e57c1778fcf857c71ceecd9bd264513f", size = 29174642, upload-time = "2026-08-21T23:26:25.395Z" }, + { url = "https://files.pythonhosted.org/packages/d5/ab/374c9fe2d1ec014e576c781a4b5d8e1ba340e8f6b4638c16f711d2b194f0/scipy-1.18.1-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:0e82073ecc7acc6436fac4b31674109c7e1d3e596789767eda01258a8c9e8123", size = 20916357, upload-time = "2026-08-21T23:26:30.112Z" }, + { url = "https://files.pythonhosted.org/packages/90/38/223915c88a17317cafbf8ca2a42b11c265a9fb1e804aa665544132b5fe8a/scipy-1.18.1-cp314-cp314t-macosx_14_0_x86_64.whl", hash = "sha256:8bcf3c1ba5d6456e2effd30fcbd3459b044d683fcdac79a2e6830f0bdf7de487", size = 23482611, upload-time = "2026-08-21T23:26:34.846Z" }, + { url = "https://files.pythonhosted.org/packages/c4/d1/db0948da8ca57a80b36520ef0a768b967d99f3af65f4b6f1bf6362ad4dd4/scipy-1.18.1-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:cfbf154f2ba187f2ed6cce2639efff7d105f1140573642c0161615b6d91d6a87", size = 34143202, upload-time = "2026-08-21T23:26:40.4Z" }, + { url = "https://files.pythonhosted.org/packages/87/53/39d046cc7574ed6acacb6bd5723e220107ece80bff12faaf3efc4ddeede4/scipy-1.18.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a1d33a7836f7ddc1993427966a0823468ec41bcbdb1a9f9942d1d7e57f803ba3", size = 35380876, upload-time = "2026-08-21T23:26:46.1Z" }, + { url = "https://files.pythonhosted.org/packages/f9/da/32e0e799d875a85ca57d9bde6c78148afcc0e38276df683d95854eadc8c3/scipy-1.18.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:7f4b8bc363b6d65ee2152bec57568e3c52639bb34c46057b09857a307ed5e21d", size = 35770885, upload-time = "2026-08-21T23:26:51.533Z" }, + { url = "https://files.pythonhosted.org/packages/88/2e/f97a666d362fee68b18f41c9c30ed502ca5c98b549749bfcb52a8b74d1eb/scipy-1.18.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:11c423f1049c5755ad4409af52a9ada1cff96fe9b50795d4af3619f292901239", size = 37525424, upload-time = "2026-08-21T23:26:56.751Z" }, + { url = "https://files.pythonhosted.org/packages/ca/d5/a9e765a84654ebba8479a1fd1b059ced1af72b168a3b2a3a46540ea38d20/scipy-1.18.1-cp314-cp314t-win_amd64.whl", hash = "sha256:c24acac1e18912761c4700239bbc1fd32f615af690f1584d49b35859be51324d", size = 37416961, upload-time = "2026-08-21T23:27:01.546Z" }, + { url = "https://files.pythonhosted.org/packages/ee/16/e79e0d1c63ef698879d85439d37e9fb434e3b804e506a6991038d086ebd9/scipy-1.18.1-cp314-cp314t-win_arm64.whl", hash = "sha256:9f2897bf7737392ad0d5213ea7b6add72a4edf5679b3153106aeb88b6507b3b9", size = 25331848, upload-time = "2026-08-21T23:27:05.884Z" }, + { url = "https://files.pythonhosted.org/packages/be/4f/1bd37c883b67163e2ca1f60977a399500e6879c15defecac62831c8d078d/scipy-1.18.1-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:eb0dfcf4e28a99c12c999744a2ff67c9b06200e20401c7c88186e33552a46331", size = 31091484, upload-time = "2026-08-21T23:27:11.051Z" }, + { url = "https://files.pythonhosted.org/packages/8c/c5/ba929d7feb9b2332f96827c12e0e924b61973b59b4dea383b603372c65ce/scipy-1.18.1-cp315-cp315-macosx_12_0_arm64.whl", hash = "sha256:30f464bee641fa8e282577c7dce027308403213c6ca8270bba73285c91024bc5", size = 28725057, upload-time = "2026-08-21T23:27:15.9Z" }, + { url = "https://files.pythonhosted.org/packages/a4/19/68f1c50f609d955d230e66d25d02bd3e1e167ec540232135354fb9a4b9e3/scipy-1.18.1-cp315-cp315-macosx_14_0_arm64.whl", hash = "sha256:1bca3b943fc2567ea49cd02c99abde49da4d5178ec46f624bd8255cda8755beb", size = 20466734, upload-time = "2026-08-21T23:27:20.044Z" }, + { url = "https://files.pythonhosted.org/packages/ef/6d/319fa29b73d1802fa80b32a6eaf3f5be456ef81526da2716a9493bcb5501/scipy-1.18.1-cp315-cp315-macosx_14_0_x86_64.whl", hash = "sha256:c9d18a33309122074ea483dd92dd444189166b8b2ec429fe9ed5ac73c7a0aa23", size = 23089664, upload-time = "2026-08-21T23:27:24.345Z" }, + { url = "https://files.pythonhosted.org/packages/b7/db/30992f9b51a63de671daf3888ffd18378b6cb9ec9f2c972264238ffa7fd6/scipy-1.18.1-cp315-cp315-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:82f201b4c878551d48558337aab270d3c6cca5507b8737c8d8a608d234cccde0", size = 34054035, upload-time = "2026-08-21T23:27:29.409Z" }, + { url = "https://files.pythonhosted.org/packages/91/d4/bf3e735dc0b9d5a8ff45079d2540e17d3aff7a2f0048dd8f552ffd031d2b/scipy-1.18.1-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0ac49ea97594532dd44b7136094d35f5440fa06e6d9c6384a74c01764df388c5", size = 35333883, upload-time = "2026-08-21T23:27:34.293Z" }, + { url = "https://files.pythonhosted.org/packages/19/93/12d78ce9f871fe945fca588d32644e6e63f553c2a35c564d73f3b22a3313/scipy-1.18.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:ceb30a00ce7c92d459819443d29ca486d882b83fb6738bdcbb2a1cce94ac5daa", size = 35673124, upload-time = "2026-08-21T23:27:39.059Z" }, + { url = "https://files.pythonhosted.org/packages/70/cd/886219313a1012a48e6ae0ec4f302c837151beb92e1ff0d709ef8fdfc488/scipy-1.18.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:f29633129f9fa7e88a3f0fca835de2d030bfc9643f7799e1a0c46cee24d38fc7", size = 37470753, upload-time = "2026-08-21T23:27:44.435Z" }, + { url = "https://files.pythonhosted.org/packages/17/6c/a776888ce618bee54fbde26172f0f46ac1da70d27b63861797fe78e1904b/scipy-1.18.1-cp315-cp315-win_amd64.whl", hash = "sha256:92c14f5bdbfb6216315ce33e78080474082de8b3830122ba97809bfbe65f75c0", size = 37361483, upload-time = "2026-08-21T23:27:49.334Z" }, + { url = "https://files.pythonhosted.org/packages/ab/09/97b651691322ebee97999b017ffc18a15a0b815103844c97e8da9d469731/scipy-1.18.1-cp315-cp315-win_arm64.whl", hash = "sha256:e402cf31eb68f453dbb2d36fc6d722b33f24a55d68b2ae1d92fa6305ca71c298", size = 25035883, upload-time = "2026-08-21T23:27:53.596Z" }, + { url = "https://files.pythonhosted.org/packages/ed/0f/9ec20467bbabd0d44e2a77d0fd3d124f884b4d67df92af82c91d2d6a486f/scipy-1.18.1-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:2a0b02f9fc46f8520330c23d45e6560db7e3a0d927232139427637f98943e11d", size = 31474926, upload-time = "2026-08-21T23:27:57.993Z" }, + { url = "https://files.pythonhosted.org/packages/8a/58/dcb79161e56efbedc50079fcd2f5fe427a0ebb53022eb476aa73c015ad8f/scipy-1.18.1-cp315-cp315t-macosx_12_0_arm64.whl", hash = "sha256:1d73131e358976663dd969e1fb4ed1404b815cd977eaaedc3b3a133ba2d81c35", size = 29164940, upload-time = "2026-08-21T23:28:03.062Z" }, + { url = "https://files.pythonhosted.org/packages/71/d3/1eeea80c817fcb8ef7bd4a05a58824977a0e57a375cfc3d7ea7c911c01ad/scipy-1.18.1-cp315-cp315t-macosx_14_0_arm64.whl", hash = "sha256:bff0b729edd992766136b34e39cc76bc2fad905aa58897ee72a9cd000a6d8443", size = 20906742, upload-time = "2026-08-21T23:28:07.642Z" }, + { url = "https://files.pythonhosted.org/packages/54/46/e59350428b6099301a20128108c995e2eb175a43f383af9a346e38824f9b/scipy-1.18.1-cp315-cp315t-macosx_14_0_x86_64.whl", hash = "sha256:10ac20c69d880f77f375db44c22e3e6a644f9fefa291d4cd2fb9790a89fc99fd", size = 23472183, upload-time = "2026-08-21T23:28:12.109Z" }, + { url = "https://files.pythonhosted.org/packages/89/31/cc91623fa98f0621766a0f0aaaadb2c66de74a7ea7e3837164f6e4354260/scipy-1.18.1-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:33a834464fdabc0f26a45508df31b3cc5d028e04dbf6c5ed398541418e0a12fe", size = 34130796, upload-time = "2026-08-21T23:28:17.906Z" }, + { url = "https://files.pythonhosted.org/packages/fc/3e/8572ef536957ddb8aa81bb4090d9e25f257e3b4e05d97deb54319deb8a3a/scipy-1.18.1-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:49023963c193dacee096301452f223ee24d86ec5807f8df93c0f7221d119e305", size = 35374253, upload-time = "2026-08-21T23:28:23.732Z" }, + { url = "https://files.pythonhosted.org/packages/b5/c6/59fdeffb4f1435299f93d9dc8140b43ad2916e6cfc944be6c3041fcec86d/scipy-1.18.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:d84a09d0dad90ba6525d8ac1c2334b33e64bf3ccfe9e841f02feb867a22681e4", size = 35758543, upload-time = "2026-08-21T23:28:29.431Z" }, + { url = "https://files.pythonhosted.org/packages/cf/d9/135be205d9de8783193aff9cc3bf483a03a38e4b29432c954e8cb66ac14e/scipy-1.18.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:179ce34a8d0fe273d8883ba59e17e052247d08973dfcb743ca52bb1cce2d60b0", size = 37521946, upload-time = "2026-08-21T23:28:35.245Z" }, + { url = "https://files.pythonhosted.org/packages/5c/a2/5b7d5270621ab7cfa3f7766067bf95dc360b5efb6394694e8143b4156e2b/scipy-1.18.1-cp315-cp315t-win_amd64.whl", hash = "sha256:5632e3ae3d09197c446310cd5187de63e28448ce22f0f67b2b93d97503c0c230", size = 37408295, upload-time = "2026-08-21T23:28:40.724Z" }, + { url = "https://files.pythonhosted.org/packages/63/ad/741c19fcb66755ff953daf9243af8480e4bf3d7fbe57583c178c7d2b6b51/scipy-1.18.1-cp315-cp315t-win_arm64.whl", hash = "sha256:eda632a7981f69730d6281f451db9c1c370993a2c0d7ddb43e2a809a2862b83a", size = 25319710, upload-time = "2026-08-21T23:28:45.713Z" }, +] + +[[package]] +name = "sse-starlette" +version = "3.7.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "starlette" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/41/43/a232e3cd804293bd4f6d01e8895bc0f6f83ea148d712baf9d783c7d93d23/sse_starlette-3.7.0.tar.gz", hash = "sha256:326416da2ab52e9a41b3f409d3ff897eda45aa68c9f3b7b17d0913aab8d219c3", size = 43869, upload-time = "2026-11-07T11:15:49.389Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6a/11/25cabac0a24fa76f58637d8671b549c90d818d69d26beecf0c59a3b186e0/sse_starlette-3.7.0-py3-none-any.whl", hash = "sha256:f1d3136caa12d129284fca3d2ded79bc9af943320b6472712955fea52a6d3eea", size = 18432, upload-time = "2026-11-07T11:15:47.86Z" }, +] + +[[package]] +name = "stack-data" +version = "0.6.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "asttokens" }, + { name = "executing" }, + { name = "pure-eval" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/28/e3/55dcc2cfbc3ca9c29519eb6884dd1415ecb53b0e934862d3559ddcb7e20b/stack_data-0.6.3.tar.gz", hash = "sha256:836a778de4fec4dcd1dcd89ed8abff8a221f58308462e1c4aa2a3cf30148f0b9", size = 44707, upload-time = "2023-09-30T13:58:05.479Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f1/7b/ce1eafaf1a76852e2ec9b22edecf1daa58175c090266e9f6c64afcd81d91/stack_data-0.6.3-py3-none-any.whl", hash = "sha256:d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695", size = 24521, upload-time = "2023-09-30T13:58:03.53Z" }, +] + +[[package]] +name = "starlette" +version = "1.10.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/48/bb/3d8757f21e9a53d9035c9eb039a777047139a16bfdbedfc7a58241c3d914/starlette-1.10.0.tar.gz", hash = "sha256:b8399098d4c1e3522734f7235dc79b1fc967f96cf139c81e0fa30479e0685f9b", size = 2734356, upload-time = "2026-10-24T15:04:12.342Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/2e/947cfe02def9371c07cd5bf5b6b61c829e9aecb9904db02a66cfafbc1eec/starlette-1.10.0-py3-none-any.whl", hash = "sha256:478c0ab3b4ced6e82719849c118fa406f0278a3499c1a898cd15cd31bdc38ce4", size = 80571, upload-time = "2026-10-24T15:04:10.371Z" }, +] + +[[package]] +name = "tornado" +version = "6.6.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/64/2b/8ff2b41620cbba0eeb0862fed21dcaa5a2ad36c6dd9bb465f9ff7a147be2/tornado-6.6.1.tar.gz", hash = "sha256:28e6311402af59c8b02e3fa0f5e7d8eb465b25081381803b127d97e6a4395d5a", size = 623388, upload-time = "2026-11-09T21:09:22.71Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/77/d3/ef3a4d38d1a72c52ad07483ed760dbb93027d28f19c3a2d98148abdd63e1/tornado-6.6.1-cp311-abi3-macosx_10_9_universal2.whl", hash = "sha256:a8d3e6acde5a80d13b13b5e4c7c226ca682f31d0a62b6c33cea038714bc2de1b", size = 533249, upload-time = "2026-11-09T21:08:22.475Z" }, + { url = "https://files.pythonhosted.org/packages/38/4d/c65ea949a3cdc185f1afac8c337074d4f2d029b48293d2db4d2c3dea4849/tornado-6.6.1-cp311-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:1b6ff57cc69b339f8feb9e7b567b0e0eacb16bfaf234159496623ef7a67ba640", size = 534470, upload-time = "2026-11-09T21:08:24.27Z" }, + { url = "https://files.pythonhosted.org/packages/03/ff/20911f85dd399b56761496e8138810e8608ea25f0912377f4205d52af853/tornado-6.6.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:da6ce2da215810d56539fa6cac77d9e27f4d8139c6868c53436b2fe933f43c79", size = 535446, upload-time = "2026-11-09T21:08:25.625Z" }, + { url = "https://files.pythonhosted.org/packages/be/70/a4a159dd4f1fef39ff8eadae655b133a85722b39087a89e21ce463af9832/tornado-6.6.1-cp311-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:8cd28b2cacbe63d53e28a38546a3492b488417eeb3f7ecf10954476fc2508882", size = 535664, upload-time = "2026-11-09T21:08:27.191Z" }, + { url = "https://files.pythonhosted.org/packages/ed/d5/db70d5d23d3b4eaea0b26b710f28d2ca387bb44e68ccfede60ba3bbc2096/tornado-6.6.1-cp311-abi3-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:25b2619274bca77d0eb7b4d96dcf2d1142bb9bf172ad6a7491a1e1f82e6e48fa", size = 534660, upload-time = "2026-11-09T21:08:28.78Z" }, + { url = "https://files.pythonhosted.org/packages/f7/f6/0528ee039266902e707edd9996ee3ce7364dc1baf08bed585d8e6fb3ccd0/tornado-6.6.1-cp311-abi3-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:77dd6e0c659fdc45824e0746988ac5c060c2a9fee9b8cbbcdb999b3f29d3cd10", size = 532834, upload-time = "2026-11-09T21:08:30.432Z" }, + { url = "https://files.pythonhosted.org/packages/a6/bb/b733df2d487a78283080663bd6d96955121b58b6d445d9cb832607da9786/tornado-6.6.1-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:b62fded687e55acaf9e36c1230b006066a35b3f6df093ba1fd3b2ff592070e1d", size = 535289, upload-time = "2026-11-09T21:08:31.692Z" }, + { url = "https://files.pythonhosted.org/packages/a7/7c/c81cb83f2bbb5740fcba1eb83d794b6d6fab2063b16a475cc9039266091e/tornado-6.6.1-cp311-abi3-musllinux_1_2_ppc64le.whl", hash = "sha256:ecef88054d8a77878f61061ff67dfc5e1c17d1f7334890ab508b310e8e68ee46", size = 535382, upload-time = "2026-11-09T21:08:33.282Z" }, + { url = "https://files.pythonhosted.org/packages/8a/ae/c499da4cc8be1c1f31a5d8df2328f2aae091de2db13302ad5c20ed704ec4/tornado-6.6.1-cp311-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:ca95e762df1ca761f330e3f2a034c15ac144569844b52527a5a9eca9f524c0f1", size = 534534, upload-time = "2026-11-09T21:08:34.57Z" }, + { url = "https://files.pythonhosted.org/packages/61/7c/6b163c9e58ca9df0c941bda9ba2dcabbd87ecb81c5fa546f54eeac689232/tornado-6.6.1-cp311-abi3-musllinux_1_2_s390x.whl", hash = "sha256:8cae3d8f2585be01670da9fd5010c61724c51b61ecd4c06820e95874739daf7c", size = 534728, upload-time = "2026-11-09T21:08:35.828Z" }, + { url = "https://files.pythonhosted.org/packages/18/11/b5107ac6a278387635d73d283e7ab5a5c76fb8ccf402efa57006ea25852f/tornado-6.6.1-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:6596f3e939962f13099ce8d1a96b83226e908ca369b193370a6efa84585a1601", size = 534676, upload-time = "2026-11-09T21:08:37.209Z" }, + { url = "https://files.pythonhosted.org/packages/65/df/0574c4479c565d9233def796afc9179fa840f41f8c240f740609f746da67/tornado-6.6.1-cp311-abi3-win32.whl", hash = "sha256:0f0f596a0dab6826aa21d103c7bc242e3fb7cfc99c5c3d44a35ba8c83abbdca4", size = 535565, upload-time = "2026-11-09T21:08:38.518Z" }, + { url = "https://files.pythonhosted.org/packages/36/57/35439a779582e3b19c98e799b6a41519fb3bdaa3a21b7a94ce4dd7b3b732/tornado-6.6.1-cp311-abi3-win_amd64.whl", hash = "sha256:5cb82ca38596e1350fceaf994f287847f82f7b8436380d36ba0937a03107d0ee", size = 535806, upload-time = "2026-11-09T21:08:39.892Z" }, + { url = "https://files.pythonhosted.org/packages/89/b8/2cb42845af01ea7e70ac23e6f6fe2f26b9b158bce186c6991c057c9abe1d/tornado-6.6.1-cp311-abi3-win_arm64.whl", hash = "sha256:58d2f47e7b54fded3407dbbbe4e59d29ca627f85bf6c0f21f0b151c6c7fc9c53", size = 535825, upload-time = "2026-11-09T21:08:41.339Z" }, + { url = "https://files.pythonhosted.org/packages/10/de/cfeae9e75c144ca22018ee3b858e343c1658d6edd2184f35d810ec1ef789/tornado-6.6.1-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:ed0bc5a1a9f6346e7bdadc106fa2d4c6e79d71d8b2df4366260ab3baf36a8399", size = 533356, upload-time = "2026-11-09T21:08:42.603Z" }, + { url = "https://files.pythonhosted.org/packages/3d/d8/7812a729c797fb8c15748c9a69faeaaa13630075cf9b76ba9f7fbcfb7f42/tornado-6.6.1-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:54c80f9bed0bf1533ecf5a90dc59651645622d62b0bcffa2692d108a1f794917", size = 537511, upload-time = "2026-11-09T21:08:43.84Z" }, + { url = "https://files.pythonhosted.org/packages/70/47/ebef304487feea6d8efb6a7d2642964ecb1f5cc785f687628e1d7cac4326/tornado-6.6.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:eb67ba2cbf598e842f14684eab029a5a4ba7ab587e8c4e40940a77ed0596b31e", size = 538566, upload-time = "2026-11-09T21:08:45.203Z" }, + { url = "https://files.pythonhosted.org/packages/a3/6a/87532e6745c415eb2daa9bc1c9c89c69ce9e8255b1c0bde9938f3299440b/tornado-6.6.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:d83bac141bd9360d8e995ec512097be19ead2e9213c3e7088510a036f3192b8d", size = 538793, upload-time = "2026-11-09T21:08:46.478Z" }, + { url = "https://files.pythonhosted.org/packages/e4/c7/26af60f71f7c32f19257bad58711500628f579edf1a2c3d8328ad15aae04/tornado-6.6.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:60aad449dbcebaa8d69bff50c6ba39858fab8d256e779a99bb30ebf6724b9b48", size = 537691, upload-time = "2026-11-09T21:08:47.975Z" }, + { url = "https://files.pythonhosted.org/packages/ba/9d/af233b8bf4311d3466099ab267eb595ec6f1655607d290dc7f706b6dbd6f/tornado-6.6.1-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b9ce0d6548bd73b1329075b247d3fdc61538922f558ee42059e08f5df53fc197", size = 535877, upload-time = "2026-11-09T21:08:49.76Z" }, + { url = "https://files.pythonhosted.org/packages/95/66/78e7583ce69f66e5177c65988a98373be2ab25c1d22405d274e037acbc58/tornado-6.6.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:ce5a18654f5d56d11400ab5d87103660e14deceab41818a06a42acc8dbbe427d", size = 538295, upload-time = "2026-11-09T21:08:51.221Z" }, + { url = "https://files.pythonhosted.org/packages/a3/3a/ad336d4994547cf268a3bd6d10f6ef691e1e888fc776940c0bfe02e8d85c/tornado-6.6.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:3298fce72c35f836eab4c4db8b960104ff1ea718033a6b5e236f04efe3a1b6e1", size = 538349, upload-time = "2026-11-09T21:08:52.761Z" }, + { url = "https://files.pythonhosted.org/packages/cf/cf/563d24516afd266f6b3c3f1c7ac15ad39b8668966d2bccce917c169ab0c0/tornado-6.6.1-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:0223e827cedf4e35ebb035e57a0d9974563cd043e3a53f8bb72a859b6f53777e", size = 537469, upload-time = "2026-11-09T21:08:54.279Z" }, + { url = "https://files.pythonhosted.org/packages/c8/ea/1705ff4014c8bad5d7045022647156cfebd6c7014886da47e13512d27c08/tornado-6.6.1-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:533185c89be3ffb01656c9425da4ff42587a3af784b37d39fe762e8fce3b2dbe", size = 537624, upload-time = "2026-11-09T21:08:55.648Z" }, + { url = "https://files.pythonhosted.org/packages/50/5d/421168e62c8b80e3ef88f80d642e9a7e5b1d0c6e8cd136d99064f663951c/tornado-6.6.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:fbaa022a49a27b65668592cf43b898ff3978cbe4e6926fdfe24dbef59053bd26", size = 537632, upload-time = "2026-11-09T21:08:57.797Z" }, + { url = "https://files.pythonhosted.org/packages/6a/b4/13b2f98a3141c152915fa3e69531a04bdc1cd7dd203f442136f3792a486f/tornado-6.6.1-cp314-cp314t-win32.whl", hash = "sha256:4bc6c60faf86162df25ba2ff5611d27b6ef8226de9d61c07a0fab53c169630a5", size = 535424, upload-time = "2026-11-09T21:08:59.145Z" }, + { url = "https://files.pythonhosted.org/packages/84/83/6d54c37b3e437ab0ff2bddd71249c6ea2a17051104dd2995cb4e181e95a7/tornado-6.6.1-cp314-cp314t-win_amd64.whl", hash = "sha256:71c16b382b22d3234913a3f74a1ea84bede197d11eb03871df17bb123088dfa5", size = 535715, upload-time = "2026-11-09T21:09:00.456Z" }, + { url = "https://files.pythonhosted.org/packages/d4/38/75419d8cd577b7c4f335f4c5e75f127af286545ad49047a73afffdf877fe/tornado-6.6.1-cp314-cp314t-win_arm64.whl", hash = "sha256:510c7261ed986ecd6f74edc1a13412759e7abc2e8be3a6c85e15f6c53e1f3c84", size = 535718, upload-time = "2026-11-09T21:09:01.783Z" }, + { url = "https://files.pythonhosted.org/packages/91/8b/96e460653f3e2ad83d70328414394132d73d5655047c692ce7b69ae2f6c0/tornado-6.6.1-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:01dc73e3697eb94d78c42e03931ab621da97d12fdfb6339e64ff5a934b220fcf", size = 533376, upload-time = "2026-11-09T21:09:03.097Z" }, + { url = "https://files.pythonhosted.org/packages/1a/1e/644bace0700e533235f01ffa68a7b5e3d6cc9eb7380e3929039d04b648b9/tornado-6.6.1-cp315-cp315t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:95bd4751357bef52aa655e236b9667ff054885de4b118e4ce9ba5c06e12ef5d0", size = 537696, upload-time = "2026-11-09T21:09:04.519Z" }, + { url = "https://files.pythonhosted.org/packages/e6/0a/afccc23d1ed71bcb1ce4a5b6e0f61f82c7a0b275f3b377ee7aee6680a565/tornado-6.6.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:29bce3190c2973fcd2171c95eeab8bf06d2f7a7eb107455ce3e4662c704aecdb", size = 538796, upload-time = "2026-11-09T21:09:05.956Z" }, + { url = "https://files.pythonhosted.org/packages/e5/24/69692f8ba851ed2738c2623eab592360d646f0a2e16b6deea16516aa8595/tornado-6.6.1-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b777fbe0bdb2c4dc764aadf5f70e9b23b2e536c339d61c799d3ea1b575a7c285", size = 538951, upload-time = "2026-11-09T21:09:07.298Z" }, + { url = "https://files.pythonhosted.org/packages/00/82/234306b41b33600a470da7e595b8064b85e2f509f64f5c1d39387c0abbb8/tornado-6.6.1-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:15443805d6b7aa11610cc6c5be7e71b4a93369aeb2ca5a13c2def53a3af5ba45", size = 537861, upload-time = "2026-11-09T21:09:08.857Z" }, + { url = "https://files.pythonhosted.org/packages/5b/87/6d13a60c320c0379cbfa4c2520b4ba076780c33e6a01ba3073fff74b71db/tornado-6.6.1-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b77ab23d1520c807d11e703e79b020d3bc3676a0f5ebc8531f46d3fac8aecb2f", size = 536178, upload-time = "2026-11-09T21:09:10.424Z" }, + { url = "https://files.pythonhosted.org/packages/96/c7/e27f2a21e05d7c5aa9886db7368436e6436880b85349072988b4f62422e3/tornado-6.6.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:872249311539281c1e8a5d8d6f27f478bf705a9bd931bf374b6b31b05177dfda", size = 538491, upload-time = "2026-11-09T21:09:11.968Z" }, + { url = "https://files.pythonhosted.org/packages/f3/c7/1f981336039c51d81ee6f895e3412178edc409bd709e38767365c55c0daa/tornado-6.6.1-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:08b808e8d3312c268f9fe1ffebfcfaaf342e7fe4ac40d219a7e1b58bac547d6f", size = 538491, upload-time = "2026-11-09T21:09:13.226Z" }, + { url = "https://files.pythonhosted.org/packages/5d/4f/7dafc65726778ac148b68c91920605892e84bf0ffcc02890aaf1a7d0ba8d/tornado-6.6.1-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:8d475f4053c693b5c1483eb4845824129b0b51c65712e736b3c2ea1c8f6080cd", size = 537775, upload-time = "2026-11-09T21:09:14.697Z" }, + { url = "https://files.pythonhosted.org/packages/a1/25/85c852307f9e49896b6dc5119f6a0131f5f6d97c478a687654c2c0c3f0f4/tornado-6.6.1-cp315-cp315t-musllinux_1_2_s390x.whl", hash = "sha256:e923e75c9d641cdb8bbac60070a2dccdb684fc555af2bff48b0eaded0f88c2dc", size = 537798, upload-time = "2026-11-09T21:09:15.946Z" }, + { url = "https://files.pythonhosted.org/packages/60/43/a37ec29b0f98c3c639da495e1d547d6c44c69a6727b9864cf149bf346433/tornado-6.6.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:a72f70b1aa630fa2106d39a025e2be75c272b7ec8233da94e2f407ea754cc32d", size = 537809, upload-time = "2026-11-09T21:09:17.265Z" }, + { url = "https://files.pythonhosted.org/packages/3b/d4/13973391071552e03acb308d93f6deb4fb535a769a6bbdafdb4cafcb2f91/tornado-6.6.1-cp315-cp315t-win32.whl", hash = "sha256:2fbfd2510b6163b189773155a8246c025cb260ccc7cd12ad18c36c54f5617bb9", size = 535422, upload-time = "2026-11-09T21:09:18.525Z" }, + { url = "https://files.pythonhosted.org/packages/19/94/c952b625904b63fdac5b747f2eeaca64ab5d36cdb8faff57effa57162d87/tornado-6.6.1-cp315-cp315t-win_amd64.whl", hash = "sha256:3c35091add5863feb9cf651851bb1b23592f1f9551b5dfed72837c83ea4e5b85", size = 535713, upload-time = "2026-11-09T21:09:20.061Z" }, + { url = "https://files.pythonhosted.org/packages/f8/62/8d0c0c42f3346f3f2455738d3bc689bbd8efba38abf7b90ab2b8294eae83/tornado-6.6.1-cp315-cp315t-win_arm64.whl", hash = "sha256:065bc741478b168df9baf754956a3010c04d1330bb45a84833d807c29e11b257", size = 535719, upload-time = "2026-11-09T21:09:21.317Z" }, +] + +[[package]] +name = "traitlets" +version = "5.16.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/2c/2e/a7fbfe268c8a3b32546930c0297c101d65a4a14c304ad5790a9f478f0e4e/traitlets-5.16.1.tar.gz", hash = "sha256:ed900c2b631aa3a112811139fa97b8d2c3bad5e989656bba4b7e52c7852c18c1", size = 166137, upload-time = "2026-08-03T08:32:36.848Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ad/66/0d785f0bc5e4315a96c989bb476d0fc07ea4f85132550c7b156ca2035d52/traitlets-5.16.1-py3-none-any.whl", hash = "sha256:f775618166caa0396c8e337099240f2bd3e5e917d203b2e6fbe21a58d3cb1f6b", size = 86211, upload-time = "2026-08-03T08:32:34.48Z" }, +] + +[[package]] +name = "tree-sitter" +version = "0.26.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e6/ca/3d69b21b2328dadee34a6cae65bc84e2b4e0c72bfb9147b7a2d4ba8110a0/tree_sitter-0.26.1.tar.gz", hash = "sha256:9919cbaf02d17fa9a4cd0e6da496aecf901b758e6eacf122eee393e3ef08aacd", size = 194642, upload-time = "2026-11-09T15:18:09.448Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/83/a9/7d55957f5beec32bd041ed1076d2096e59396555c42843da37d89720ceea/tree_sitter-0.26.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f1ec14b8eb354c9afb9de1a9cf16c6ffb770aa31962509d062ae513735a90c63", size = 150328, upload-time = "2026-11-09T15:17:27.96Z" }, + { url = "https://files.pythonhosted.org/packages/52/68/3a267561dc7552b073b39eec74df0e2bfffd5da078855c6e3f84ce99fc14/tree_sitter-0.26.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c3c207bb7cd28aaa804f7062b680fa5dbceb2135c55018c62c43fbda3dac6d0f", size = 142096, upload-time = "2026-11-09T15:17:29.081Z" }, + { url = "https://files.pythonhosted.org/packages/8a/31/374923548e16509763ce774dfe969a5988e8bd69a2536c92dd1dabf64a9c/tree_sitter-0.26.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0a7a9ee719645d656fe252afbb437b4bb5e9a535e5287fc04c0831876b2de07a", size = 645270, upload-time = "2026-11-09T15:17:30.469Z" }, + { url = "https://files.pythonhosted.org/packages/3d/06/fabf2bd1a4159ae54fc6dc55fe532d88426e34824a0eda2d24542e9839cd/tree_sitter-0.26.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1529457e099ee5963b9738d42ed8133316d936157e912aa4a985f4fdaf018ada", size = 674059, upload-time = "2026-11-09T15:17:32.363Z" }, + { url = "https://files.pythonhosted.org/packages/9d/6c/f466186b3c844c22095a7eca00307ae14166d3f1c4cc2bf4b03a7253a3c2/tree_sitter-0.26.1-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:9b3b6ea0867ad88b04323260dfd1c746315e6e45ec1a4884ac7d9182a32b3e11", size = 657129, upload-time = "2026-11-09T15:17:33.523Z" }, + { url = "https://files.pythonhosted.org/packages/a3/06/9a3bf38815add3ca23079ca43b178f6a114eb6ae61cbea4de9db3aacfb4a/tree_sitter-0.26.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ae770e688436c80991ef21410c66f20d307a5d6daec58f9eadd384e94d77ce14", size = 671598, upload-time = "2026-11-09T15:17:34.839Z" }, + { url = "https://files.pythonhosted.org/packages/7d/ff/52b6fbdcef205d238ad12ead21f48a2a443b15ee93cbeeaa428882598262/tree_sitter-0.26.1-cp311-cp311-win_amd64.whl", hash = "sha256:10ffee79cfddbb16231d6f5152f895240d425e359ea9785dc2fa043cabf7281c", size = 130635, upload-time = "2026-11-09T15:17:36.105Z" }, + { url = "https://files.pythonhosted.org/packages/78/89/574ce07e57307f7ef7d7a67bea2777ecf0f4c3daa7b037119513d64816ac/tree_sitter-0.26.1-cp311-cp311-win_arm64.whl", hash = "sha256:bcfc3d54a486946a17f58139630fdd49c61d9c9b4a790e2a9f35579679c92307", size = 120679, upload-time = "2026-11-09T15:17:37.112Z" }, + { url = "https://files.pythonhosted.org/packages/65/7d/67970014769483318f7ea91cae46a8dd68168c69f7407f4eb61b0213891a/tree_sitter-0.26.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c413bfec1dbee3fc17b967537d26da1429c07a593da251a71843f5e34c8ea0ff", size = 150472, upload-time = "2026-11-09T15:17:38.382Z" }, + { url = "https://files.pythonhosted.org/packages/a6/cd/da10e28e5305b5900d1bc503ac78214efca97fa5bc09b86cf466125a1bde/tree_sitter-0.26.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8ac2d0d115e73be14dbd569b353a4f762368c134a64248aa4483afdc297dd4b4", size = 142047, upload-time = "2026-11-09T15:17:39.467Z" }, + { url = "https://files.pythonhosted.org/packages/e7/b2/9dc423a8cb2e57e2ee982bcfd44fe44e37d7ae2a7ba8e03d93bc6a7b8fb2/tree_sitter-0.26.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8ecef3db771e6f50a7010310056a54bca11279e0f10597fff78c215a879de965", size = 647888, upload-time = "2026-11-09T15:17:40.96Z" }, + { url = "https://files.pythonhosted.org/packages/9a/d9/238f956bff9be77ad43b7efe5b03fdc0c5ccef41b1018888c420d7eb604b/tree_sitter-0.26.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b14ac81a2afdcf75610f714f1d2eeaac40da93965c104cabb5c4c2b536a488a", size = 678547, upload-time = "2026-11-09T15:17:42.536Z" }, + { url = "https://files.pythonhosted.org/packages/94/47/3e02e6cd037fc83a4cad9c031a7af6195a5040ec226bd6f1da872fab8754/tree_sitter-0.26.1-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0d95e054892e378fe3dbd75d709ecc05c97609eec916ccc30eb301b5c21a6f86", size = 659146, upload-time = "2026-11-09T15:17:44.172Z" }, + { url = "https://files.pythonhosted.org/packages/39/33/e6e4c2c9dc4ab88f6a7e1ca4f3b8a263ba273ea1ca83f643d191ab6e1289/tree_sitter-0.26.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:90c03a777889b8f767b8d4b5d700fbfe2db6cdc05f8ee7fb8d33ab2ef1097972", size = 675175, upload-time = "2026-11-09T15:17:45.493Z" }, + { url = "https://files.pythonhosted.org/packages/f8/b3/ae76ad04f059594603f58003da40b9c4238d960823a8a05aba2ecb057976/tree_sitter-0.26.1-cp312-cp312-win_amd64.whl", hash = "sha256:df8663ce8106bd49d379697cc4471c92537e0c25a8c63bf1246958fdfe22a979", size = 130915, upload-time = "2026-11-09T15:17:46.707Z" }, + { url = "https://files.pythonhosted.org/packages/61/57/7b7625a80da743562673d69e0b26cc281380ce95b78f34369b5d6eeb016f/tree_sitter-0.26.1-cp312-cp312-win_arm64.whl", hash = "sha256:5d28096eef96c2111b2244394a3340e0d3d7ac8f124eb9806eb8f783cd87c30c", size = 120726, upload-time = "2026-11-09T15:17:47.728Z" }, + { url = "https://files.pythonhosted.org/packages/3c/f5/f5b7e8deeccb5e10987775c3e7bd1f98030459329a6d570d0eb580ed52f5/tree_sitter-0.26.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:904bcb36111fa74241d920c5785ee206b8f9fe41b6d5348daa52d563faafba6b", size = 150473, upload-time = "2026-11-09T15:17:48.829Z" }, + { url = "https://files.pythonhosted.org/packages/41/88/e25eb561b8bb902bac508baf1e2be624fbcc7c6c5f84fdf9a09bc07e7197/tree_sitter-0.26.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:16ada9e60b91cbaba7715c649655351cdf97ddc2f07fb11388924e027abf53e7", size = 142067, upload-time = "2026-11-09T15:17:49.948Z" }, + { url = "https://files.pythonhosted.org/packages/07/30/379b9ccdac8d658cca2aac6416cc6f01f5dec49ff919b485f394500719a6/tree_sitter-0.26.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:92aaec1a5d4318b7e563075365336d89dcfb613f716a4491bfd9a012a133aa74", size = 648685, upload-time = "2026-11-09T15:17:51.03Z" }, + { url = "https://files.pythonhosted.org/packages/52/1c/e48d13bc08a7130d33df55a58762b5b6b8974407e9c254d0253feb2b300f/tree_sitter-0.26.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00e55f823de46b2bbcab9ca58a4c2a7ccc2b1dc28ed3fad7355fb32726008e21", size = 679201, upload-time = "2026-11-09T15:17:52.392Z" }, + { url = "https://files.pythonhosted.org/packages/fe/f5/06ff88ed355becea5e0900dd0289d33fc02a37f4af482025c255f64d6bc3/tree_sitter-0.26.1-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:57fa04154e292972b8970a9728515bdf0addedafb10452156e0667381c77805e", size = 659819, upload-time = "2026-11-09T15:17:54.028Z" }, + { url = "https://files.pythonhosted.org/packages/82/3b/2652e78b52d72f061a50e82af446df7c1497fbb7a8afbbd3cab8a0d9936c/tree_sitter-0.26.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:59ee219cdd35bbcfe9ed2cc8faba16ab4d88b19574f7ac15074d89de5c0c273c", size = 675285, upload-time = "2026-11-09T15:17:55.429Z" }, + { url = "https://files.pythonhosted.org/packages/e9/cd/77c0cc542e76e96da58b01f27ec454aadd6300fcff96abbb31b77f7515fc/tree_sitter-0.26.1-cp313-cp313-win_amd64.whl", hash = "sha256:0f8ca207d7f6e50b9a883bafa5fd3474758387156050057f269f56cd1b240bb2", size = 130907, upload-time = "2026-11-09T15:17:57.073Z" }, + { url = "https://files.pythonhosted.org/packages/c0/5c/80da017e9c4f4b01eb0d153ed7f3341c355d4455000b95d390dc70d756f8/tree_sitter-0.26.1-cp313-cp313-win_arm64.whl", hash = "sha256:8f69e35087b72cd3f370400c173d0a45e16cee426f283b116d5eb6a936bd0600", size = 120723, upload-time = "2026-11-09T15:17:58.103Z" }, + { url = "https://files.pythonhosted.org/packages/ba/47/8bb05ae418983720aafc5367ff3253e608b2b18f56462a20b923a014dc7a/tree_sitter-0.26.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:c66af3fb35e2380248a2c5a000d735528c116f65b028d1e4f8d44b378d006fcf", size = 150510, upload-time = "2026-11-09T15:17:59.422Z" }, + { url = "https://files.pythonhosted.org/packages/c7/62/79fe26c919e8d081094df31bef84eb8a75c64768bc505c36eda72d382edb/tree_sitter-0.26.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c46becdb79b49d68f1084e335eddc74318b25f2d4fcd33de46fe259fd031ba1c", size = 142148, upload-time = "2026-11-09T15:18:00.489Z" }, + { url = "https://files.pythonhosted.org/packages/05/97/858b27d159c69cc14a1ae86c77633f25bddb4c80be8505dba8367c4741ca/tree_sitter-0.26.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:02d73ec124fa74e64558f5fdb3ae58d8af19d5e8b4a70197b45ebf22c83e822f", size = 650625, upload-time = "2026-11-09T15:18:01.937Z" }, + { url = "https://files.pythonhosted.org/packages/29/e4/035caa6a831379b378f4a9e44c44348bd33bbd9a7d8b2d64549bc891e610/tree_sitter-0.26.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0c1b48e17b26cf555060c1285b35f49eeb345222e62c2a35d70c393a7c61c65b", size = 680138, upload-time = "2026-11-09T15:18:03.867Z" }, + { url = "https://files.pythonhosted.org/packages/fe/ed/5462539303dbe7d5c4a653fa2cc5aeac3692f9b83a2b53875dba935fdd64/tree_sitter-0.26.1-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:82f82e39d0da2f552d5ddbbf8d6fcd71571ec4b09814196ac5bf8233a13e751f", size = 660875, upload-time = "2026-11-09T15:18:05.208Z" }, + { url = "https://files.pythonhosted.org/packages/80/64/ce86bba1987ba13b8337afdef34a189912fe1d29dd60ccfda0443fb20214/tree_sitter-0.26.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:25ebcf9ab2f5e4687a2ee9943e3ddfa7df67eb180058825887e461ba4750a336", size = 675316, upload-time = "2026-11-09T15:18:06.309Z" }, + { url = "https://files.pythonhosted.org/packages/e9/da/2bc600b0e1aa6c6160abea62dfae4da8b7d934d45cb550e25553519c0d72/tree_sitter-0.26.1-cp314-cp314-win_amd64.whl", hash = "sha256:b1e079af889beed37ae2f8aa24078018ed63ff3bb566f47212a4f90d7990528e", size = 133677, upload-time = "2026-11-09T15:18:07.338Z" }, + { url = "https://files.pythonhosted.org/packages/9f/75/c3db59cd8a8dd5fbb382b21a19c71665ba67739a8b36eca4712c921f892d/tree_sitter-0.26.1-cp314-cp314-win_arm64.whl", hash = "sha256:5c24824174a374916365cab0469243fa5220d51fd6b168a145cbb61afba8e9f5", size = 124621, upload-time = "2026-11-09T15:18:08.413Z" }, +] + +[[package]] +name = "tree-sitter-matlab" +version = "1.3.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/34/b5/6b38c951a67f70119ae1e41391c0e5cd76bd5c39bf5295c11831cbbc9a9a/tree_sitter_matlab-1.3.3.tar.gz", hash = "sha256:860af9a1f7d0ed6eb30123cacde318836397a099759ae147ec54ed9f1857090a", size = 183331, upload-time = "2026-11-06T16:44:41.011Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b5/b6/f59d078bf068d3f34cb2b1cf34fdd40439ef5b0fa3d53897e46430ed6568/tree_sitter_matlab-1.3.3-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:9ed1afbf15bd9928918617fbecb88261fd3a64fc90e25bb889797c1d455322a7", size = 91854, upload-time = "2026-11-06T16:44:18.806Z" }, + { url = "https://files.pythonhosted.org/packages/ad/d0/69b7deee0b6531c0bb6d9c8e3dee99d2b7adeaa509025e7cad67f52821db/tree_sitter_matlab-1.3.3-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:455e3e8bc3941159e9ad8ee93a46de34171b0158113646913f625f71b0621782", size = 121275, upload-time = "2026-11-06T16:44:20.332Z" }, + { url = "https://files.pythonhosted.org/packages/28/81/2e84fb7e2e8736b3e86378b5113f2f2333466c0a64c52f1a75422fabd0db/tree_sitter_matlab-1.3.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7784f26af3179527313ac1bb8eff801aceb80d235a29bc06e24ac1aff8fce1c1", size = 128415, upload-time = "2026-11-06T16:44:21.824Z" }, + { url = "https://files.pythonhosted.org/packages/6a/b3/8874cad6c79cacf69b12ea2a66359d740e6a9a848f599a860be7ab185c4b/tree_sitter_matlab-1.3.3-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:2746dbae6c7f494ea0227614c03bc0a8977b1a3d7af343db08a777088cdcd2ef", size = 126214, upload-time = "2026-11-06T16:44:23.21Z" }, + { url = "https://files.pythonhosted.org/packages/f5/45/eedfa6403e0d1796915f0bf992138f4c910735769df818f5925146708e2e/tree_sitter_matlab-1.3.3-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ab3c24964726cf2033f24b2e87d4f5a35d084fa94c9de29b3fb241692956cbb4", size = 120013, upload-time = "2026-11-06T16:44:24.56Z" }, + { url = "https://files.pythonhosted.org/packages/2c/55/be68422ef0b6d43beba9e2b756968e1eeb22ccffd0167a59ca4b6845913a/tree_sitter_matlab-1.3.3-cp310-abi3-win32.whl", hash = "sha256:1655949d0764b9e230ef6345e6ef37e37f239ad521128a4ed770f814a47d92b5", size = 86119, upload-time = "2026-11-06T16:44:25.894Z" }, + { url = "https://files.pythonhosted.org/packages/ca/59/6346e7a6ee3c481e4635a526c1311b480b3213de4103c688ad5ba8fd0d10/tree_sitter_matlab-1.3.3-cp310-abi3-win_amd64.whl", hash = "sha256:8f1b0c3ce908f2a6b98c97adeba84a5621ca2a8489ef37582f75f6a69cf3cf37", size = 86792, upload-time = "2026-11-06T16:44:27.262Z" }, + { url = "https://files.pythonhosted.org/packages/d6/b1/b25a1d38b3e74a20f22e9a3e4cd2244c0bcffb14bcc66cf8aadd63b074c9/tree_sitter_matlab-1.3.3-cp310-abi3-win_arm64.whl", hash = "sha256:389433926a4569aef3c7c3b16c2f1d46e6d874f4aa7111a596e3cdd662c65837", size = 86527, upload-time = "2026-11-06T16:44:28.527Z" }, + { url = "https://files.pythonhosted.org/packages/80/e2/0767aa8a19c10a2dea7eddc96a260fa2db262d7d48533757a1bc4873b8ae/tree_sitter_matlab-1.3.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:61479e722b2f407bd6eaa12aaabfe1c554a5e5fa866cca71372b3a5dd38aeeb7", size = 91868, upload-time = "2026-11-06T16:44:30.042Z" }, + { url = "https://files.pythonhosted.org/packages/9a/38/2f4d6bc9dbc208bb5d7fea513d4c804f76b9f7a84be7bef3ccd055945c89/tree_sitter_matlab-1.3.3-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:953f7f57ddbf5d0e4a7fabf2dcdf1876668fa8ceb8978e37bf00b0b8d7701009", size = 124051, upload-time = "2026-11-06T16:44:31.459Z" }, + { url = "https://files.pythonhosted.org/packages/61/16/95a40daf3466b7197282eeaefceef781a6a4b1b448c40b7226f0777d551f/tree_sitter_matlab-1.3.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5b42f308cd960aa5af001fdb2b58d89488345667e115613e3a286bc532654c54", size = 131368, upload-time = "2026-11-06T16:44:32.856Z" }, + { url = "https://files.pythonhosted.org/packages/6e/35/3923da75b405b5929d1476a47c24e3b05bd7fd3c29a6189097d434f1ea29/tree_sitter_matlab-1.3.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:c96b97a684e54584f9d5c4c4eadf55cdca56072e6ee22a9702496cc85d8cc1ad", size = 129066, upload-time = "2026-11-06T16:44:34.375Z" }, + { url = "https://files.pythonhosted.org/packages/16/b0/cbdb595c0eb2c92b282c753db718c6d940bd3d25386c2d927ebc95ce4bc8/tree_sitter_matlab-1.3.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:e6be180d0e02620d58b10751474c6bd5114d483e8a2f59ac2209a601199e94de", size = 122819, upload-time = "2026-11-06T16:44:35.615Z" }, + { url = "https://files.pythonhosted.org/packages/dc/44/1d632a2df8633b96a12705591fc7517123a5e7bcadb24a5104895f718067/tree_sitter_matlab-1.3.3-cp314-cp314t-win32.whl", hash = "sha256:651e8da8d386888ecc44634aa9a46ff16c30ca3d599794eb50e4723253190ba8", size = 88909, upload-time = "2026-11-06T16:44:36.974Z" }, + { url = "https://files.pythonhosted.org/packages/f6/5c/23ce0fa93164ac077d9fde7ae9adc470a8d8b23783eb862ea7d50ccd759e/tree_sitter_matlab-1.3.3-cp314-cp314t-win_amd64.whl", hash = "sha256:ff9c4dc6adf90acaf7f318392487eda6049fadd48846e8abc86a7455e37c9720", size = 89193, upload-time = "2026-11-06T16:44:38.515Z" }, + { url = "https://files.pythonhosted.org/packages/d5/c8/e2f74f49355e12d0f4118aab59528becf9d0134d0c7c221d6702f4f33085/tree_sitter_matlab-1.3.3-cp314-cp314t-win_arm64.whl", hash = "sha256:0f01557a65cbe5a5e3b623743a2301a22ed0e294ed9b40fa877afe263981a1dd", size = 88961, upload-time = "2026-11-06T16:44:39.725Z" }, +] + +[[package]] +name = "truststore" +version = "0.10.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ee/9f/c5201d42a484c061e528825fc8e2d565f5abd50a4ced6fb7d29c4ec99b2b/truststore-0.10.5.tar.gz", hash = "sha256:30d36967ccaded5cbb38d602c433f53600036c79d502f4533a49b60a03bbefcd", size = 28091, upload-time = "2026-10-12T22:27:31.808Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/e9/3a7820be2bb0fe53b6bc9c3be26d3d1158004e4c3ab953aa6840b955b1e9/truststore-0.10.5-py3-none-any.whl", hash = "sha256:9aaaedaefaf06d8b206278cf8b5012bc897f485a874503501e12d776df78951c", size = 19017, upload-time = "2026-10-12T22:27:30.377Z" }, +] + +[[package]] +name = "types-jsonschema" +version = "4.26.0.20261006" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "referencing" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/29/d2/1f742605f5a6d39f993134885b8de41c98af606871d3ebddaf3e776bd1eb/types_jsonschema-4.26.0.20261006.tar.gz", hash = "sha256:3eb7db61b6819d40addfdaac7173e749071a7d4a9a4394f0c844598ec84b2500", size = 16843, upload-time = "2026-10-06T08:16:07.318Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8b/a0/4f2e3c0dc3d5cad958006f2e0307065cc8fe4fbf0393ff0b69d55ee9bbe5/types_jsonschema-4.26.0.20261006-py3-none-any.whl", hash = "sha256:29301f4e65e3928540cdf5e23ad716e38bb0c0b416a48dada213edd3d70206ec", size = 16113, upload-time = "2026-10-06T08:16:06.355Z" }, +] + +[[package]] +name = "types-pyyaml" +version = "6.0.12.20261111" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/80/49/96041fdb54de08a5b47bcfcbb4881873b25bae367d1e4dec79d19dfeb84b/types_pyyaml-6.0.12.20261111.tar.gz", hash = "sha256:c511f563eaf820b948c4ff6f43fe0b9d48b227be442a69058d9f68f139cae1fb", size = 18970, upload-time = "2026-11-11T08:32:30.036Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/ec/b23dd6911cd0e870e9396b48929ef7c92b58a551c3651d184bb573f371eb/types_pyyaml-6.0.12.20261111-py3-none-any.whl", hash = "sha256:b7e46cbc847dc235305e95e3e3570792d72e6ccf64bf9b831306f48da490322d", size = 21317, upload-time = "2026-11-11T08:32:29.148Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" }, +] + +[[package]] +name = "typing-inspection" +version = "0.4.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ff/50/0195198eb1d75bab716bb0a813abea4cc394bfa17a92a189f021a34859af/typing_inspection-0.4.5.tar.gz", hash = "sha256:7f16c411e7930dc79596d42ab44672a3fe5f60eb34b781a1647e7872363120c7", size = 81194, upload-time = "2026-11-04T14:13:23.774Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/de/0c/ea2544850a7c135e15033a5c7a8e7211136184b7ae63e2239d557c2b3019/typing_inspection-0.4.5-py3-none-any.whl", hash = "sha256:bc210535442b39e1bf2805e0c7a17dfd6a4ace760c84c7f7d16245d23a6b1c39", size = 14874, upload-time = "2026-11-04T14:13:22.616Z" }, +] + +[[package]] +name = "tzdata" +version = "2026.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7a/29/6a1391d31cd00ff9e927215a224a880e1e84e826b64ba80a499e51c074d8/tzdata-2026.6.tar.gz", hash = "sha256:85d2cd9c09f81f0bb29db27759fc83af4f1e620efb814f8c5bf8b4cc4feece6d", size = 201017, upload-time = "2026-10-28T09:57:09.137Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0a/66/9a06c2227fedfd4919f0eaaa8b94377d9730882a7e4f95823c9a331ab5e1/tzdata-2026.6-py2.py3-none-any.whl", hash = "sha256:0a10eec6e13ef16b627fabed9a5f2ba61a62b1c67f327305f4e7e412a70b4aec", size = 348210, upload-time = "2026-10-28T09:57:07.276Z" }, +] + +[[package]] +name = "uvicorn" +version = "0.54.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/da/34/30e9280707135d2cfc589dfff3cb796bd07a3aeb1a3e415ba09dd89d7bb4/uvicorn-0.54.0.tar.gz", hash = "sha256:a2e33cbfaa0306f8e6b0c13e0cb89d7d7a2da3e62b90c66e18c33d9807b28620", size = 112283, upload-time = "2026-09-25T06:52:37.601Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/0c/b54a4fdd7f90a3af8b02ebc9ce6712c2c208b7926a2f7bad95c33ebbe943/uvicorn-0.54.0-py3-none-any.whl", hash = "sha256:505bdb0f318731d45f1f712071fc781a8981f6847a31c902c9f5e652d4f67faf", size = 87427, upload-time = "2026-09-25T06:52:35.829Z" }, +] + +[[package]] +name = "wcwidth" +version = "0.9.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ea/01/e5ac23733628a6bbb91913a765fcf55ee8070d8d991bc88fdaaf805052c7/wcwidth-0.9.4.tar.gz", hash = "sha256:fd8d57d3cdfe570e3265c8fab1885c24e34ef40889c0759c0c304a19e9835954", size = 970051, upload-time = "2026-10-24T18:11:44.954Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bf/b8/d251589a100250b71a7b8e83fedfcabfd8bd60e78cd1e3329372f63bcc93/wcwidth-0.9.4-cp310-abi3-macosx_10_9_x86_64.whl", hash = "sha256:b7969c9aa258d536df54c8ac8af5cad0c74a6268c9972e1fb60a5f29feffb66d", size = 612952, upload-time = "2026-10-24T18:10:55.925Z" }, + { url = "https://files.pythonhosted.org/packages/04/e9/dfdca30ca36c472de3e260406dee29fc108499ec590c63b3fe279887ee9d/wcwidth-0.9.4-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:f279f32c8e206a9092fa350e53ca0c2bd8072e45b1c9fd31bb6d476b59b591c4", size = 618904, upload-time = "2026-10-24T18:11:02.008Z" }, + { url = "https://files.pythonhosted.org/packages/5d/b6/d7416f38054a107d2fb17c2b73b68723c6c334f69c4e29545fb9e6df81eb/wcwidth-0.9.4-cp310-abi3-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:a1526cd25c6420e5153bb7d764c7509e692215ee3ad9b725db1ad665d47eae09", size = 778780, upload-time = "2026-10-24T18:11:17.299Z" }, + { url = "https://files.pythonhosted.org/packages/7d/5b/42bdf9a4b0e4f9126584af2ec73642de495f3bd8add907430f13c3bb98d2/wcwidth-0.9.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:093469e01d881bff3db93ff3f56c364dc87c441ea01f9f41c22de0c0bdf5c6ef", size = 789012, upload-time = "2026-10-24T18:11:07.829Z" }, + { url = "https://files.pythonhosted.org/packages/fa/e8/0485850748dfdba9443f4151c7b2442cfa4987ba6cd871038eb5d6b8eca9/wcwidth-0.9.4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b185c8b927b23af2721be1783499d1cfa5c028b098b0858951b4ae224477f1c2", size = 785946, upload-time = "2026-10-24T18:11:18.748Z" }, + { url = "https://files.pythonhosted.org/packages/e9/11/dd3d0379c6094524df6585b76ae3d9727161ff29c003177e3661c36437c1/wcwidth-0.9.4-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:17619066f95c10f44d7ae08ee456602456bc66cc9d5e91966ec73d799acebc5f", size = 795348, upload-time = "2026-10-24T18:11:09.931Z" }, + { url = "https://files.pythonhosted.org/packages/3c/48/1b5299983d9ec084be897162b7cc6014622dfe62847224fa3272b6d79ea5/wcwidth-0.9.4-cp310-abi3-musllinux_1_2_i686.whl", hash = "sha256:b52f265a694dda6b3ad9050c8bd89158ad519109ef7c5eb110b906cc49f25763", size = 793420, upload-time = "2026-10-24T18:11:20.551Z" }, + { url = "https://files.pythonhosted.org/packages/7a/be/e3097d859b075344a7be57774a58d468eafb0ca88e02aad93eb31d69f6ba/wcwidth-0.9.4-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:d8905f1390d828d745fdd1904374c90386d902d3cfa9ee88e9875099f75a4e17", size = 796192, upload-time = "2026-10-24T18:11:22.552Z" }, + { url = "https://files.pythonhosted.org/packages/5e/cd/739710c8cf0de461239db5bb6ee678c9a33d30aaa22beff55cc356781818/wcwidth-0.9.4-cp310-abi3-win32.whl", hash = "sha256:4831662c396dd4c59a016ec53c0ac96738006d653a00482777d9a2e2ea323d62", size = 593229, upload-time = "2026-10-24T18:11:35.609Z" }, + { url = "https://files.pythonhosted.org/packages/d6/f1/c123f902bc2ff9e9c2ab66241b8872204df87cbb18ecdf035e120860fedc/wcwidth-0.9.4-cp310-abi3-win_amd64.whl", hash = "sha256:f28d77153303450ee13ebbe888297e75cf532c754555b6cabafc9bdda16c421c", size = 597780, upload-time = "2026-10-24T18:11:36.952Z" }, + { url = "https://files.pythonhosted.org/packages/4b/88/1cb5ddaf5510b918e01aa95fc4b68df91dead784b63e4931037c5673e85f/wcwidth-0.9.4-cp310-abi3-win_arm64.whl", hash = "sha256:2b58fc8cf2de1bf9cdb68b8beaa5be198742414a7c8cd97aa51ec039783ffa49", size = 598786, upload-time = "2026-10-24T18:11:30.886Z" }, + { url = "https://files.pythonhosted.org/packages/b0/cc/46a31c12b4cdad04f546a3c0aca5d000d77aa5069ae88b4db24525cc29c4/wcwidth-0.9.4-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:87e4101789415a6cf55ec4c53eceeb4782c2654c88692941cb588f19dca1959f", size = 613805, upload-time = "2026-10-24T18:10:58.887Z" }, + { url = "https://files.pythonhosted.org/packages/18/f6/5a8327af9a65153ea9823d6a12fc182f325264050aa25c05a5deadc189c9/wcwidth-0.9.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:ab1e5190fb82476e75fbf963e9d59b4fb1c1e1f4ced82069a0c989016aa959f7", size = 619936, upload-time = "2026-10-24T18:11:04.073Z" }, + { url = "https://files.pythonhosted.org/packages/1f/d3/bb8a7f4aa9b915e56e09841b07636ba49c82ec987ad3d2022e1696c038d9/wcwidth-0.9.4-cp314-cp314t-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:8f892713ab5795d3abae181e9c02db0eb24de4084f9ee080535369d3d98d7bb5", size = 794563, upload-time = "2026-10-24T18:11:24.4Z" }, + { url = "https://files.pythonhosted.org/packages/12/0c/986acadef534688a57502d484a40e0f30bdca2d39514fe0a311f7d575f70/wcwidth-0.9.4-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:befbf46467100e43fd8c8cc0c031a0105f13f5418c3be95fdcf0c47214487967", size = 806565, upload-time = "2026-10-24T18:11:14.297Z" }, + { url = "https://files.pythonhosted.org/packages/9b/1d/66a94b9ac07037d7cf2c1f1288867c9932215d467893eaa5ec8d548c7f2f/wcwidth-0.9.4-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9c4b0dd04cca520792100f6110d10be262c94b285a281d1759c551f159214633", size = 802372, upload-time = "2026-10-24T18:11:26.275Z" }, + { url = "https://files.pythonhosted.org/packages/d1/00/1d50b8e8b45a8330b582695bf8196081a609317928a3718cf21b3d14a899/wcwidth-0.9.4-cp314-cp314t-win32.whl", hash = "sha256:14410eb73178cc492aa9bf22f7c12e3bf930e5470b7220cf6f530efbfa2e03f3", size = 598917, upload-time = "2026-10-24T18:11:38.369Z" }, + { url = "https://files.pythonhosted.org/packages/b4/fc/3e39a33fc8f5c4e07611578710275039c9d4a6655e2be7cf3459401a30cc/wcwidth-0.9.4-cp314-cp314t-win_amd64.whl", hash = "sha256:c36954849aafae1092d6f9de9548c5280c1d6841637a27ca288b2241c802c4ab", size = 603536, upload-time = "2026-10-24T18:11:39.922Z" }, + { url = "https://files.pythonhosted.org/packages/e1/8c/b1f399fd2f8449e42978192967ab6df441d7cf894b10117983c36c062b18/wcwidth-0.9.4-cp314-cp314t-win_arm64.whl", hash = "sha256:79e09e9824c88f5e275ca99e921685567a5c5c1bb6165c16e27ddd1adab33a95", size = 605127, upload-time = "2026-10-24T18:11:32.367Z" }, + { url = "https://files.pythonhosted.org/packages/04/46/839780e772e9068580619d4d691348b7a5f9c4fa5ffe501e522eefeb27cc/wcwidth-0.9.4-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:a8c9ce14c6b4a499e61de6de7e9e456de11be8bc991554e2ab2ed4feb40b9664", size = 613850, upload-time = "2026-10-24T18:11:00.725Z" }, + { url = "https://files.pythonhosted.org/packages/d2/66/b2559c7012bbd4268f5b5c0288cb793c78235d354e306871a55893aa9d1a/wcwidth-0.9.4-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:d68f09093c9bec9226a52edc47487042ed4f64c5df91d06f00419495071c0279", size = 620207, upload-time = "2026-10-24T18:11:05.975Z" }, + { url = "https://files.pythonhosted.org/packages/d1/fe/7d2c39e28924b2430b20099e36276f14e00e75c7bbe4ba5b1ed44d1d465a/wcwidth-0.9.4-cp315-cp315t-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:d76b7c715c5ca0103b28915f699f1020ae21f06f1d22cdd85a7a97f7b1536eed", size = 797056, upload-time = "2026-10-24T18:11:27.911Z" }, + { url = "https://files.pythonhosted.org/packages/2b/d7/f4f9967a411e02b89b74df2f49f44977c4badccf29738f3ae6941619e27c/wcwidth-0.9.4-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:29c0685f5f5f8815b88308fdcbe2cd12a92996a21a5b1e18352d165174ef7a6d", size = 806169, upload-time = "2026-10-24T18:11:15.724Z" }, + { url = "https://files.pythonhosted.org/packages/ac/bb/e2b40c6522f3aa1222558487dda3551d297e07e245761b4816f6caeebc29/wcwidth-0.9.4-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:e05458491759aa42b7b85f36345b3e6df082d6d2d9bf616299668fd598e0209d", size = 803462, upload-time = "2026-10-24T18:11:29.269Z" }, + { url = "https://files.pythonhosted.org/packages/a8/f2/ab69009f2dd0d3772d3e07f025fa046b33c60c195e4f2e5f000297d23547/wcwidth-0.9.4-cp315-cp315t-win32.whl", hash = "sha256:9e5090d253f5df99659cddfd3ed90dd21f6ff51989b0421331a63fb2681cbe27", size = 598931, upload-time = "2026-10-24T18:11:41.659Z" }, + { url = "https://files.pythonhosted.org/packages/63/6f/b321f10c2298e7d16cffc1a5f05f3d7e5231b45f9e68af5ee378e23bb2e5/wcwidth-0.9.4-cp315-cp315t-win_amd64.whl", hash = "sha256:12786620375dc83fabf4b2b2aa52416fef2bc6094522ea29c8a53c75b0dfe9b6", size = 603485, upload-time = "2026-10-24T18:11:43.052Z" }, + { url = "https://files.pythonhosted.org/packages/4e/cc/7eeb28059186cae72a770df79e744f232ef068192a5a588b718473e35bb4/wcwidth-0.9.4-cp315-cp315t-win_arm64.whl", hash = "sha256:2cca7b5d0b9d0ae49068d3ce806e965326a987f555b62eaa322223396e10d01b", size = 605198, upload-time = "2026-10-24T18:11:33.75Z" }, + { url = "https://files.pythonhosted.org/packages/6f/0c/309b1813b230d1dbbd6f2c2ab2bb21ef68992358977605d9ef289bbfedcc/wcwidth-0.9.4-py3-none-any.whl", hash = "sha256:901eace6d2dd25ebb917d0ce5db18e5c537e1504c905cf32f0d006c12098b05d", size = 301806, upload-time = "2026-10-24T18:10:52.651Z" }, +]