샘플
numpy 2.5.1: broadcast_to
검증된 샘플 — pypi numpy 2.5.1: broadcast_to. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: assert numpy.broadcast_to broadcasts 1D array to…
sha256:9eabce8c33c420f6100a7e2b6d48863406206f85eb79ba3af81aa3612e5e10a0
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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.broadcast_to in pkg:pypi/numpy@2.5.1
- 패키지
- 심벌
-
- numpy.broadcast_to
- 생성일
- 2026-09-01T21:58:03Z
컨트랙트
- assert numpy.broadcast_to broadcasts 1D array to compatible 2D shape producing a view with zero stride
- assert numpy.broadcast_to broadcasts scalar and 0D array to arbitrary target shape
- assert numpy.broadcast_to expands singleton dimensions to target shape
- assert numpy.broadcast_to returns read-only view with writeable flag set to False
- assert numpy.broadcast_to raises ValueError when target shape is incompatible with input shape
- assert numpy.broadcast_to preserves ndarray subclasses when subok is True and forces base ndarray when subok is False
파일
- 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.broadcast_to 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.broadcast_to
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:1993163957d610a0d0df4506244a594a56920f1b2db5c0b7523af0ecf6428f23","contract":["assert numpy.broadcast_to broadcasts 1D array to compatible 2D shape producing a view with zero stride","assert numpy.broadcast_to broadcasts scalar and 0D array to arbitrary target shape","assert numpy.broadcast_to expands singleton dimensions to target shape","assert numpy.broadcast_to returns read-only view with writeable flag set to False","assert numpy.broadcast_to raises ValueError when target shape is incompatible with input shape","assert numpy.broadcast_to preserves ndarray subclasses when subok is True and forces base ndarray when subok is False"],"goal":"verify numpy.broadcast_to in pkg:pypi/numpy@2.5.1","kind":"HOW","packages":["pkg:pypi/numpy@2.5.1"],"schemaVersion":1,"symbols":["numpy.broadcast_to"]},"contractCommand":["python3","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.broadcast_to"],"verifierAdapter":"python@1"}
[project]
name = "verify-numpy-broadcast-to"
version = "0.1.0"
dependencies = [
"numpy==2.5.1",
]
numpy==2.5.1
{
"schemaVersion": 1,
"goal": "verify numpy.broadcast_to in pkg:pypi/numpy@2.5.1",
"kind": "HOW",
"packages": [
"pkg:pypi/numpy@2.5.1"
],
"symbols": [
"numpy.broadcast_to"
]
}
import numpy as np
def test_broadcast_to_1d_to_2d():
arr = np.array([1, 2, 3])
b = np.broadcast_to(arr, (2, 3))
assert b.shape == (2, 3)
assert np.array_equal(b, np.array([[1, 2, 3], [1, 2, 3]]))
assert b.strides[0] == 0
assert b.strides[1] == arr.strides[0]
def test_broadcast_to_scalar_and_0d():
b_scalar = np.broadcast_to(7, (2, 3))
assert b_scalar.shape == (2, 3)
assert np.all(b_scalar == 7)
arr_0d = np.array(42)
b_0d = np.broadcast_to(arr_0d, (3, 1, 2))
assert b_0d.shape == (3, 1, 2)
assert np.all(b_0d == 42)
def test_broadcast_to_singleton_expansion():
arr = np.array([[1], [2], [3]])
b = np.broadcast_to(arr, (3, 4))
assert b.shape == (3, 4)
assert np.array_equal(b, np.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]))
assert b.strides == (arr.strides[0], 0)
arr_2d = np.array([[10, 20], [30, 40]])
b_3d = np.broadcast_to(arr_2d, (3, 2, 2))
assert b_3d.shape == (3, 2, 2)
assert b_3d.strides[0] == 0
assert np.array_equal(b_3d[0], arr_2d)
assert np.array_equal(b_3d[1], arr_2d)
assert np.array_equal(b_3d[2], arr_2d)
def test_broadcast_to_readonly_view():
arr = np.array([1, 2, 3])
b = np.broadcast_to(arr, (2, 3))
assert b.flags.writeable is False
try:
b[0, 0] = 99
assert False, "Assignment to broadcast_to view should raise ValueError"
except ValueError:
pass
def test_broadcast_to_incompatible_shape():
arr = np.array([1, 2, 3])
try:
np.broadcast_to(arr, (2, 2))
assert False, "Incompatible shape should raise ValueError"
except ValueError:
pass
try:
np.broadcast_to(arr, (2,))
assert False, "Incompatible shape should raise ValueError"
except ValueError:
pass
def test_broadcast_to_subok():
class CustomArray(np.ndarray):
pass
sub_arr = np.array([1, 2, 3]).view(CustomArray)
b_subok_true = np.broadcast_to(sub_arr, (2, 3), subok=True)
assert isinstance(b_subok_true, CustomArray)
assert b_subok_true.shape == (2, 3)
b_subok_false = np.broadcast_to(sub_arr, (2, 3), subok=False)
assert type(b_subok_false) is np.ndarray
assert b_subok_false.shape == (2, 3)
def main():
test_broadcast_to_1d_to_2d()
test_broadcast_to_scalar_and_0d()
test_broadcast_to_singleton_expansion()
test_broadcast_to_readonly_view()
test_broadcast_to_incompatible_shape()
test_broadcast_to_subok()
print("All contract assertions passed.")
if __name__ == "__main__":
main()
오리진 시더
익명