Beispiel
numba 0.67.0rc1: prange
Verifiziertes Beispiel für pypi numba 0.67.0rc1: prange. Der Vertrag lief auf python 3.12 · linux debian/x64 · docker und bestand.
sha256:4259237a29e9c64e57ad7fb9228de66f8e816c0dc824ef693a393be0e0ada285
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 pip
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104… |
2026-09-02 |
Fall
HOW- Ziel
- verify numba.prange in pkg:pypi/numba@0.67.0rc1
- Pakete
- Symbole
-
- numba.prange
- Erstellt
- 2026-09-02T13:17:55Z
Contract
- prange fallback outside jit execution matches standard range iteration with start, stop, and step arguments
- prange inside njit with parallel=True performs parallel reduction over array elements
- prange inside njit with parallel=True performs parallel array mutation and elementwise transformation
- prange supports start and stop slice boundary indexing in parallel execution
- prange supports nested multidimensional parallel loops for 2D array computation
- prange with step size other than 1 in parallel jit raises UnsupportedRewriteError
Dateien
- NOTES.md
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
Quelltext
# Numba prange parallel loop API
This sample pins `numba` 0.67.0rc1 and verifies `numba.prange` for parallel iteration in JIT-compiled functions.
The contract verifies:
- `prange` outside JIT context behaves as a drop-in replacement for standard `range` with start, stop, and step attributes.
- `prange` inside `@njit(parallel=True)` enables parallel reduction across threads.
- `prange` inside `@njit(parallel=True)` enables independent parallel array element mutation.
- `prange` supports start and stop slice boundary indexing in parallel execution.
- `prange` supports nested multi-dimensional parallel loops for 2D array computation.
- `prange` with step size other than 1 in `@njit(parallel=True)` raises `UnsupportedRewriteError`.
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify numba.prange in pkg:pypi/numba@0.67.0rc1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/numba@0.67.0rc1
Demonstrate these symbols/APIs:
- numba.prange
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:e091e9d46141a6e136c438aede7d9cbecbb11d6a8ccd7832582821f3d606e395","contract":["prange fallback outside jit execution matches standard range iteration with start, stop, and step arguments","prange inside njit with parallel=True performs parallel reduction over array elements","prange inside njit with parallel=True performs parallel array mutation and elementwise transformation","prange supports start and stop slice boundary indexing in parallel execution","prange supports nested multidimensional parallel loops for 2D array computation","prange with step size other than 1 in parallel jit raises UnsupportedRewriteError"],"goal":"verify numba.prange in pkg:pypi/numba@0.67.0rc1","kind":"HOW","packages":["pkg:pypi/numba@0.67.0rc1"],"schemaVersion":1,"symbols":["numba.prange"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/numba@0.67.0rc1"],"schemaVersion":1,"subject":"pkg:pypi/numba@0.67.0rc1","symbols":["numba.prange"],"verifierAdapter":"python@1"}
numba==0.67.0rc1
numpy==2.5.2
{
"schemaVersion": 1,
"goal": "verify numba.prange in pkg:pypi/numba@0.67.0rc1",
"kind": "HOW",
"packages": [
"pkg:pypi/numba@0.67.0rc1"
],
"symbols": [
"numba.prange"
]
}
import numpy as np
import numba
from numba import njit, prange
from numba.core.errors import UnsupportedRewriteError
def test_prange_outside_jit():
r1 = prange(5)
assert list(r1) == [0, 1, 2, 3, 4]
assert r1.start == 0 and r1.stop == 5 and r1.step == 1
r2 = prange(2, 7)
assert list(r2) == [2, 3, 4, 5, 6]
assert r2.start == 2 and r2.stop == 7 and r2.step == 1
r3 = prange(1, 10, 2)
assert list(r3) == [1, 3, 5, 7, 9]
assert r3.start == 1 and r3.stop == 10 and r3.step == 2
def test_prange_parallel_reduction():
@njit(parallel=True)
def parallel_sum(arr):
acc = 0.0
for i in prange(len(arr)):
acc += arr[i]
return acc
arr = np.linspace(1.0, 100.0, 200)
res = parallel_sum(arr)
expected = np.sum(arr)
assert np.isclose(res, expected)
def test_prange_parallel_array_mutation():
@njit(parallel=True)
def parallel_scale(arr, factor):
out = np.empty_like(arr)
for i in prange(len(arr)):
out[i] = arr[i] * factor
return out
arr = np.arange(50, dtype=np.float64)
scaled = parallel_scale(arr, 3.5)
expected = arr * 3.5
assert np.array_equal(scaled, expected)
def test_prange_slice_bounds():
@njit(parallel=True)
def parallel_slice_sum(arr, start, stop):
acc = 0.0
for i in prange(start, stop):
acc += arr[i]
return acc
arr = np.arange(100, dtype=np.float64)
res = parallel_slice_sum(arr, 15, 65)
expected = np.sum(arr[15:65])
assert np.isclose(res, expected)
def test_prange_multidimensional_nested():
@njit(parallel=True)
def parallel_matrix_add(a, b):
rows, cols = a.shape
out = np.empty((rows, cols), dtype=a.dtype)
for i in prange(rows):
for j in prange(cols):
out[i, j] = a[i, j] + b[i, j]
return out
a = np.ones((8, 8), dtype=np.float64)
b = np.full((8, 8), 2.5, dtype=np.float64)
out = parallel_matrix_add(a, b)
assert np.array_equal(out, a + b)
def test_prange_unsupported_non_unit_step_raises():
try:
@njit(parallel=True)
def bad_step(arr):
acc = 0.0
for i in prange(0, len(arr), 2):
acc += arr[i]
return acc
arr = np.arange(10, dtype=np.float64)
bad_step(arr)
assert False, "Expected UnsupportedRewriteError for non-unit step in prange"
except UnsupportedRewriteError as exc:
assert "Only constant step size of 1 is supported for prange" in str(exc)
def main():
test_prange_outside_jit()
test_prange_parallel_reduction()
test_prange_parallel_array_mutation()
test_prange_slice_bounds()
test_prange_multidimensional_nested()
test_prange_unsupported_non_unit_step_raises()
print("All contract assertions passed.")
if __name__ == "__main__":
main()
Ursprungs-Seeder
anonym