샘플
numpy 2.5.1: pad
검증된 샘플 — pypi numpy 2.5.1: pad. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: numpy.pad() with constant mode pads array with default and…
sha256:ddef53007f9acd2a535577d579e373ff0231a97f30877ace5b41bd72b508dcb5
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-01 |
케이스
HOW- 목표
- verify numpy.pad in pkg:pypi/numpy@2.5.1
- 패키지
- 심벌
-
- numpy.pad
- 생성일
- 2026-09-01T21:54:40Z
컨트랙트
- numpy.pad() with constant mode pads array with default and specified constant values.
- numpy.pad() with edge mode extends boundary elements across specified pad widths.
- numpy.pad() with linear_ramp mode creates a linear gradient between end_values and array edges.
- numpy.pad() with reflect and symmetric modes reflects vector values without and with edge duplication.
- numpy.pad() with wrap mode cyclically tiles array values along the specified axis.
- numpy.pad() supports statistical modes (mean, maximum, minimum) along multi-dimensional axes.
- numpy.pad() accepts custom callable functions with pad_width, iaxis, and kwargs.
- numpy.pad() raises ValueError when passed an unrecognized padding mode or negative pad width.
파일
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- spec.json
- test/contract.py
소스
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.pad 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.pad
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:b1a34dea1285e2182ff4ffa5df91cf94c895e95016346c5b1bc17c9656d890eb","contract":["numpy.pad() with constant mode pads array with default and specified constant values.","numpy.pad() with edge mode extends boundary elements across specified pad widths.","numpy.pad() with linear_ramp mode creates a linear gradient between end_values and array edges.","numpy.pad() with reflect and symmetric modes reflects vector values without and with edge duplication.","numpy.pad() with wrap mode cyclically tiles array values along the specified axis.","numpy.pad() supports statistical modes (mean, maximum, minimum) along multi-dimensional axes.","numpy.pad() accepts custom callable functions with pad_width, iaxis, and kwargs.","numpy.pad() raises ValueError when passed an unrecognized padding mode or negative pad width."],"goal":"verify numpy.pad in pkg:pypi/numpy@2.5.1","kind":"HOW","packages":["pkg:pypi/numpy@2.5.1"],"schemaVersion":1,"symbols":["numpy.pad"]},"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/numpy@2.5.1"],"schemaVersion":1,"subject":"pkg:pypi/numpy@2.5.1","symbols":["numpy.pad"],"verifierAdapter":"python@1"}
[project]
name = "verify-numpy-pad"
version = "0.1.0"
dependencies = [
"numpy==2.5.1",
]
numpy==2.5.1
{
"schemaVersion": 1,
"goal": "verify numpy.pad in pkg:pypi/numpy@2.5.1",
"kind": "HOW",
"packages": [
"pkg:pypi/numpy@2.5.1"
],
"symbols": [
"numpy.pad"
]
}
import numpy as np
def test_constant_mode():
arr = np.array([1, 2, 3])
# Default constant_values=0
res_default = np.pad(arr, (2, 3), mode="constant")
assert np.array_equal(res_default, [0, 0, 1, 2, 3, 0, 0, 0]), f"Got {res_default}"
# Specified constant_values tuple
res_custom = np.pad(arr, (1, 2), mode="constant", constant_values=(7, 9))
assert np.array_equal(res_custom, [7, 1, 2, 3, 9, 9]), f"Got {res_custom}"
def test_edge_mode():
arr = np.array([1, 2, 3])
res = np.pad(arr, (2, 1), mode="edge")
assert np.array_equal(res, [1, 1, 1, 2, 3, 3]), f"Got {res}"
def test_linear_ramp_mode():
arr = np.array([1, 2, 3])
res = np.pad(arr, (2, 2), mode="linear_ramp", end_values=(0, 5))
assert np.array_equal(res, [0, 0, 1, 2, 3, 4, 5]), f"Got {res}"
def test_reflect_and_symmetric_modes():
arr = np.array([1, 2, 3])
# Reflect mode reflects without repeating the edge value
res_reflect = np.pad(arr, (2, 2), mode="reflect")
assert np.array_equal(res_reflect, [3, 2, 1, 2, 3, 2, 1]), f"Got {res_reflect}"
# Symmetric mode reflects with edge value repeated
res_symmetric = np.pad(arr, (2, 2), mode="symmetric")
assert np.array_equal(res_symmetric, [2, 1, 1, 2, 3, 3, 2]), f"Got {res_symmetric}"
def test_wrap_mode():
arr = np.array([1, 2, 3])
res = np.pad(arr, (2, 3), mode="wrap")
assert np.array_equal(res, [2, 3, 1, 2, 3, 1, 2, 3]), f"Got {res}"
def test_statistical_modes():
matrix = np.array([[1.0, 2.0], [3.0, 4.0]])
res_mean = np.pad(matrix, 1, mode="mean")
assert res_mean.shape == (4, 4), f"Got shape {res_mean.shape}"
assert np.array_equal(res_mean[1:3, 1:3], matrix)
res_max = np.pad(matrix, 1, mode="maximum")
assert res_max.shape == (4, 4), f"Got shape {res_max.shape}"
assert np.array_equal(res_max[1:3, 1:3], matrix)
res_min = np.pad(matrix, 1, mode="minimum")
assert res_min.shape == (4, 4), f"Got shape {res_min.shape}"
assert np.array_equal(res_min[1:3, 1:3], matrix)
def test_custom_callable():
def custom_padder(vector, pad_width, iaxis, kwargs):
pad_val = kwargs.get("val", 42)
vector[:pad_width[0]] = pad_val
vector[-pad_width[1]:] = pad_val
arr = np.array([1, 2, 3])
res = np.pad(arr, (1, 1), mode=custom_padder, val=99)
assert np.array_equal(res, [99, 1, 2, 3, 99]), f"Got {res}"
def test_error_handling():
arr = np.array([1, 2, 3])
try:
np.pad(arr, (1, 1), mode="nonexistent_mode")
raise AssertionError("Expected ValueError on invalid mode")
except (ValueError, KeyError):
pass
try:
np.pad(arr, (-1, 2), mode="constant")
raise AssertionError("Expected ValueError on negative pad width")
except ValueError:
pass
def main():
test_constant_mode()
test_edge_mode()
test_linear_ramp_mode()
test_reflect_and_symmetric_modes()
test_wrap_mode()
test_statistical_modes()
test_custom_callable()
test_error_handling()
print("CONTRACT PASS: numpy.pad verified offline")
if __name__ == "__main__":
main()
오리진 시더
익명