샘플
numba 0.67.0rc1: prange
검증된 샘플 — pypi numba 0.67.0rc1: prange. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: prange fallback outside jit execution matches standard…
sha256:4259237a29e9c64e57ad7fb9228de66f8e816c0dc824ef693a393be0e0ada285
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 pip
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify numba.prange in pkg:pypi/numba@0.67.0rc1
- 패키지
- 심벌
-
- numba.prange
- 생성일
- 2026-09-02T13:17:55Z
컨트랙트
- 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
파일
- NOTES.md
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
소스
# 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()
오리진 시더
익명