CodeSampleX

Beispiel

numpy 2.5.1: numpy

Verifiziertes Beispiel für pypi numpy 2.5.1: numpy. Der Vertrag lief auf python 3.12 · linux alpine/x64 · docker und bestand: numpy.zeros, numpy.ones, and…

sha256:37a21ac8d7f32824bc7d29e720b19690020377a99c9831bf0e77f85714ae263d

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 python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962…
2026-08-28

Fall

HOW
Ziel
verify numpy in pkg:pypi/numpy@2.5.1
Pakete
Symbole
  • numpy
Umgebung
python 3.12
Erstellt
2026-08-28T03:57:06Z

Contract

  1. numpy.zeros, numpy.ones, and numpy.full allocate ndarrays with specified shapes, dtypes, and fill values.
  2. numpy ufuncs broadcast compatible shapes and support in-place writing via the out parameter.
  3. numpy.sum and numpy.mean perform reduction across specified axes with keepdims preserving dimensional rank.
  4. numpy.reshape and ndarray.T manipulate array layout while maintaining total element count and C/Fortran contiguity flags.
  5. numpy.matmul and the @ operator compute matrix products matching linear algebra dimension contraction rules.
  6. numpy.linalg.solve computes exact solutions to linear matrix systems AX = B.
  7. numpy.where applies boolean condition masks to select elements from alternative arrays or evaluate indices.

Dateien

  • PROMPT.md
  • csx.json
  • 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 numpy in pkg:pypi/numpy@2.5.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/numpy@2.5.1
Demonstrate these symbols/APIs:
  - numpy
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:f75db267c175dbf921ab2a3babe2fb3f8e5a3e4d87993f4c9f01c7bd8d555c3a","contract":["numpy.zeros, numpy.ones, and numpy.full allocate ndarrays with specified shapes, dtypes, and fill values.","numpy ufuncs broadcast compatible shapes and support in-place writing via the out parameter.","numpy.sum and numpy.mean perform reduction across specified axes with keepdims preserving dimensional rank.","numpy.reshape and ndarray.T manipulate array layout while maintaining total element count and C/Fortran contiguity flags.","numpy.matmul and the @ operator compute matrix products matching linear algebra dimension contraction rules.","numpy.linalg.solve computes exact solutions to linear matrix systems AX = B.","numpy.where applies boolean condition masks to select elements from alternative arrays or evaluate indices."],"goal":"verify numpy in pkg:pypi/numpy@2.5.1","kind":"HOW","packages":["pkg:pypi/numpy@2.5.1"],"schemaVersion":1,"symbols":["numpy"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/numpy@2.5.1"],"schemaVersion":1,"subject":"pkg:pypi/numpy@2.5.1","symbols":["numpy"],"verifierAdapter":"python@1"}
requirements.txt
numpy==2.5.1
spec.json
{
  "schemaVersion": 1,
  "goal": "verify numpy in pkg:pypi/numpy@2.5.1",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/numpy@2.5.1"
  ],
  "symbols": [
    "numpy"
  ],
  "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


def test_array_creation():
    # numpy.zeros, numpy.ones, and numpy.full allocate ndarrays with specified shapes, dtypes, and fill values
    z = np.zeros((2, 3), dtype=np.int32)
    assert z.shape == (2, 3)
    assert z.dtype == np.int32
    assert z.size == 6
    assert np.all(z == 0)

    o = np.ones((3, 2), dtype=np.float64)
    assert o.shape == (3, 2)
    assert o.dtype == np.float64
    assert np.all(o == 1.0)

    f = np.full((2, 2), 42, dtype=np.int64)
    assert f.shape == (2, 2)
    assert f.dtype == np.int64
    assert np.all(f == 42)


def test_broadcasting_and_ufuncs():
    # numpy ufuncs broadcast compatible shapes and support in-place writing via the out parameter
    a = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float64)
    b = np.array([10, 20, 30], dtype=np.float64)

    # (2, 3) + (3,) -> (2, 3) via broadcasting
    c = np.add(a, b)
    expected = np.array([[11.0, 22.0, 33.0], [14.0, 25.0, 36.0]], dtype=np.float64)
    assert np.array_equal(c, expected)

    # In-place write via out parameter
    out_buf = np.empty_like(a)
    result = np.multiply(a, 2.0, out=out_buf)
    assert result is out_buf
    assert np.array_equal(out_buf, np.array([[2.0, 4.0, 6.0], [8.0, 10.0, 12.0]]))


def test_axis_reductions():
    # numpy.sum and numpy.mean perform reduction across specified axes with keepdims preserving dimensional rank
    arr = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float64)

    sum_axis0 = np.sum(arr, axis=0)
    assert np.array_equal(sum_axis0, np.array([5.0, 7.0, 9.0]))
    assert sum_axis0.shape == (3,)

    sum_axis1_keep = np.sum(arr, axis=1, keepdims=True)
    assert np.array_equal(sum_axis1_keep, np.array([[6.0], [15.0]]))
    assert sum_axis1_keep.shape == (2, 1)

    mean_all = np.mean(arr)
    assert mean_all == 3.5


def test_reshaping_and_transpose():
    # numpy.reshape and ndarray.T manipulate array layout while maintaining total element count and C/Fortran contiguity flags
    arr = np.arange(6, dtype=np.int32)
    reshaped = np.reshape(arr, (2, 3))
    assert reshaped.shape == (2, 3)
    assert reshaped.flags.c_contiguous is True

    transposed = reshaped.T
    assert transposed.shape == (3, 2)
    assert transposed.flags.f_contiguous is True
    assert np.array_equal(transposed, np.array([[0, 3], [1, 4], [2, 5]]))


def test_matmul_and_linear_algebra():
    # numpy.matmul and the @ operator compute matrix products matching linear algebra dimension contraction rules
    m1 = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float64)
    m2 = np.array([[5.0, 6.0], [7.0, 8.0]], dtype=np.float64)

    prod_matmul = np.matmul(m1, m2)
    prod_operator = m1 @ m2
    expected_prod = np.array([[19.0, 22.0], [43.0, 50.0]], dtype=np.float64)

    assert np.array_equal(prod_matmul, expected_prod)
    assert np.array_equal(prod_operator, expected_prod)

    # numpy.linalg.solve computes exact solutions to linear matrix systems AX = B
    A = np.array([[3.0, 1.0], [1.0, 2.0]], dtype=np.float64)
    B = np.array([9.0, 8.0], dtype=np.float64)
    X = np.linalg.solve(A, B)
    assert np.allclose(X, np.array([2.0, 3.0]))
    assert np.allclose(A @ X, B)


def test_boolean_masking_and_where():
    # numpy.where applies boolean condition masks to select elements from alternative arrays or evaluate indices
    x = np.array([10, 20, 30, 40, 50], dtype=np.int32)
    cond = x > 25

    selected = np.where(cond, x, -1)
    assert np.array_equal(selected, np.array([-1, -1, 30, 40, 50]))

    indices = np.where(cond)
    assert np.array_equal(indices[0], np.array([2, 3, 4]))


def main():
    test_array_creation()
    test_broadcasting_and_ufuncs()
    test_axis_reductions()
    test_reshaping_and_transpose()
    test_matmul_and_linear_algebra()
    test_boolean_masking_and_where()
    print("CONTRACT PASS: verify numpy in pkg:pypi/numpy@2.5.1")


if __name__ == "__main__":
    main()

Ursprungs-Seeder

anonym