CodeSampleX

샘플

numba 0.67.0rc1: vectorize

검증된 샘플 — pypi numba 0.67.0rc1: vectorize. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: assert vectorize compiles ufunc with explicit…

sha256:577410fef81fcea21ddb684de2ab824e575161ec1d6342e80adb34d6eea61413

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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.vectorize in pkg:pypi/numba@0.67.0rc1
패키지
심벌
  • numba.vectorize
생성일
2026-09-02T13:21:01Z

컨트랙트

  1. assert vectorize compiles ufunc with explicit integer and float signatures on scalar and 1D array inputs
  2. assert vectorize compiles dynamically without explicit signatures on invocation
  3. assert vectorize performs multi-dimensional array broadcasting
  4. assert vectorize generated ufunc supports reduce and accumulate methods
  5. assert vectorize with explicit signature raises TypeError when called with incompatible argument types

파일

  • PROMPT.md
  • csx.json
  • pyproject.toml
  • requirements.txt
  • spec.json
  • test/contract.py

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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.vectorize 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.vectorize
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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.
csx.json
{"case":{"caseId":"case:sha256:14fc57c4238e293e2114a9c09b0ea81810c06b988bb877df1d2fc5f2c848e52b","contract":["assert vectorize compiles ufunc with explicit integer and float signatures on scalar and 1D array inputs","assert vectorize compiles dynamically without explicit signatures on invocation","assert vectorize performs multi-dimensional array broadcasting","assert vectorize generated ufunc supports reduce and accumulate methods","assert vectorize with explicit signature raises TypeError when called with incompatible argument types"],"goal":"verify numba.vectorize in pkg:pypi/numba@0.67.0rc1","kind":"HOW","packages":["pkg:pypi/numba@0.67.0rc1"],"schemaVersion":1,"symbols":["numba.vectorize"]},"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.vectorize"],"verifierAdapter":"python@1"}
pyproject.toml
[project]
name = "verify-numba"
version = "0.1.0"
dependencies = [
    "llvmlite==0.49.0",
    "numba==0.67.0rc1",
    "numpy==2.5.2",
]
requirements.txt
llvmlite==0.49.0
numba==0.67.0rc1
numpy==2.5.2
spec.json
{
  "schemaVersion": 1,
  "goal": "verify numba.vectorize in pkg:pypi/numba@0.67.0rc1",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/numba@0.67.0rc1"
  ],
  "symbols": [
    "numba.vectorize"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.py
import numpy as np
import numba
from numba import vectorize, int64, float64


def test_vectorize_explicit_signatures():
    @vectorize([int64(int64, int64), float64(float64, float64)])
    def vec_add(x, y):
        return x + y

    # Scalar inputs
    assert vec_add(10, 20) == 30
    assert vec_add(1.5, 2.5) == 4.0

    # 1D array inputs
    a = np.array([1, 2, 3], dtype=np.int64)
    b = np.array([4, 5, 6], dtype=np.int64)
    res = vec_add(a, b)
    assert isinstance(res, np.ndarray)
    assert np.array_equal(res, np.array([5, 7, 9], dtype=np.int64))

    # Broadcasting: 1D array + scalar
    res_bcast = vec_add(a, 10)
    assert np.array_equal(res_bcast, np.array([11, 12, 13], dtype=np.int64))


def test_vectorize_dynamic_compilation():
    @vectorize
    def vec_mul(x, y):
        return x * y

    # Compiles dynamically on invocation
    res_scalar = vec_mul(3, 4)
    assert res_scalar == 12

    arr1 = np.array([1.0, 2.0, 3.0], dtype=np.float64)
    arr2 = np.array([2.0, 3.0, 4.0], dtype=np.float64)
    res_arr = vec_mul(arr1, arr2)
    assert np.allclose(res_arr, np.array([2.0, 6.0, 12.0]))


def test_vectorize_multidimensional_broadcasting():
    @vectorize([float64(float64, float64)])
    def vec_sub(x, y):
        return x - y

    mat = np.array([[10.0, 20.0, 30.0], [40.0, 50.0, 60.0]], dtype=np.float64)
    row = np.array([1.0, 2.0, 3.0], dtype=np.float64)
    res = vec_sub(mat, row)
    expected = np.array([[9.0, 18.0, 27.0], [39.0, 48.0, 57.0]], dtype=np.float64)
    assert res.shape == (2, 3)
    assert np.allclose(res, expected)


def test_vectorize_ufunc_methods():
    @vectorize([int64(int64, int64)])
    def vec_sum(x, y):
        return x + y

    arr = np.array([1, 2, 3, 4, 5], dtype=np.int64)

    # ufunc reduce method
    total = vec_sum.reduce(arr)
    assert total == 15

    # ufunc accumulate method
    accum = vec_sum.accumulate(arr)
    assert np.array_equal(accum, np.array([1, 3, 6, 10, 15], dtype=np.int64))


def test_vectorize_type_error():
    @vectorize([int64(int64, int64)])
    def vec_int_add(x, y):
        return x + y

    try:
        vec_int_add("invalid", "strings")
        assert False, "Should have raised TypeError"
    except TypeError as e:
        assert isinstance(e, TypeError)


def main():
    test_vectorize_explicit_signatures()
    test_vectorize_dynamic_compilation()
    test_vectorize_multidimensional_broadcasting()
    test_vectorize_ufunc_methods()
    test_vectorize_type_error()
    print("All vectorize contract assertions passed.")


if __name__ == "__main__":
    main()

오리진 시더

익명