CodeSampleX

샘플

numpy 2.5.1: numpy

검증된 샘플 — pypi numpy 2.5.1: numpy. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: numpy.zeros, numpy.ones, and numpy.full allocate ndarrays…

sha256:37a21ac8d7f32824bc7d29e720b19690020377a99c9831bf0e77f85714ae263d

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify numpy in pkg:pypi/numpy@2.5.1
패키지
심벌
  • numpy
환경
python 3.12
생성일
2026-08-28T03:57:06Z

컨트랙트

  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.

파일

  • PROMPT.md
  • csx.json
  • 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 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()

오리진 시더

익명