CodeSampleX

Beispiel

numba 0.67.0rc1: vectorize

Verifiziertes Beispiel für pypi numba 0.67.0rc1: vectorize. Der Vertrag lief auf python 3.12 · linux debian/x64 · docker und bestand.

sha256:577410fef81fcea21ddb684de2ab824e575161ec1d6342e80adb34d6eea61413

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.vectorize in pkg:pypi/numba@0.67.0rc1
Pakete
Symbole
  • numba.vectorize
Erstellt
2026-09-02T13:21:01Z

Contract

  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

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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()

Ursprungs-Seeder

anonym