サンプル
scipy 1.18.0: ndimage
検証済みサンプル — pypi scipy 1.18.0: ndimage. python 3.12 · linux alpine/x64 · docker で contract を実行し、成功しました: assert gaussian_filter smooths multidimensional array…
sha256:1abd373b80ca31003cf734e0e88817d6ad30a109a8496688134b86e3fe3bc43e
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 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-27 |
ケース
HOW- ゴール
- verify scipy.ndimage in pkg:pypi/scipy@1.18.0
- パッケージ
- シンボル
-
- scipy.ndimage
- 作成日
- 2026-08-27T19:57:50Z
コントラクト
- assert gaussian_filter smooths multidimensional array with specified standard deviation
- assert label and find_objects identify contiguous connected components and return slice tuples
- assert binary_dilation and binary_erosion expand and shrink binary structures
- assert center_of_mass computes spatial centroids for labeled regions
- assert rotate and zoom perform array scaling and rotation transformations
ファイル
- 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 scipy.ndimage in pkg:pypi/scipy@1.18.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/scipy@1.18.0
Demonstrate these symbols/APIs:
- scipy.ndimage
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:9afe217477421b616d963d6631b5bc74b0f3d771fac79127140f3ac671c8b227","contract":["assert gaussian_filter smooths multidimensional array with specified standard deviation","assert label and find_objects identify contiguous connected components and return slice tuples","assert binary_dilation and binary_erosion expand and shrink binary structures","assert center_of_mass computes spatial centroids for labeled regions","assert rotate and zoom perform array scaling and rotation transformations"],"goal":"verify scipy.ndimage in pkg:pypi/scipy@1.18.0","kind":"HOW","packages":["pkg:pypi/scipy@1.18.0"],"schemaVersion":1,"symbols":["scipy.ndimage"]},"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/scipy@1.18.0"],"schemaVersion":1,"subject":"pkg:pypi/scipy@1.18.0","symbols":["scipy.ndimage"],"verifierAdapter":"python@1"}
[project]
name = "verify-scipy-ndimage"
version = "0.1.0"
dependencies = [
"scipy==1.18.0",
"numpy==2.5.2",
]
scipy==1.18.0
numpy==2.5.2
{
"schemaVersion": 1,
"goal": "verify scipy.ndimage in pkg:pypi/scipy@1.18.0",
"kind": "HOW",
"packages": [
"pkg:pypi/scipy@1.18.0"
],
"symbols": [
"scipy.ndimage"
]
}
import numpy as np
import scipy.ndimage as ndi
def test_gaussian_filter():
arr = np.zeros((5, 5), dtype=np.float64)
arr[2, 2] = 1.0
filtered = ndi.gaussian_filter(arr, sigma=1.0)
assert filtered.shape == (5, 5)
assert filtered[2, 2] > filtered[0, 0]
assert np.isclose(filtered.sum(), 1.0, atol=1e-2)
def test_label_and_find_objects():
binary_grid = np.array([
[1, 1, 0, 0],
[1, 1, 0, 0],
[0, 0, 1, 1],
[0, 0, 1, 1],
], dtype=np.int32)
labeled, num_features = ndi.label(binary_grid)
assert num_features == 2
slices = ndi.find_objects(labeled)
assert len(slices) == 2
assert slices[0] == (slice(0, 2, None), slice(0, 2, None))
assert slices[1] == (slice(2, 4, None), slice(2, 4, None))
def test_morphology_dilation_and_erosion():
grid = np.zeros((7, 7), dtype=bool)
grid[3, 3] = True
struct = ndi.generate_binary_structure(2, 1)
dilated = ndi.binary_dilation(grid, structure=struct)
assert dilated.sum() == 5
assert bool(dilated[3, 3]) is True
assert bool(dilated[2, 3]) is True
eroded = ndi.binary_erosion(dilated, structure=struct)
assert np.array_equal(eroded, grid)
def test_center_of_mass():
grid = np.array([
[1, 1, 0, 0],
[1, 1, 0, 0],
[0, 0, 1, 1],
[0, 0, 1, 1],
], dtype=np.float64)
labeled, _ = ndi.label(grid)
com = ndi.center_of_mass(grid, labels=labeled, index=[1, 2])
assert np.allclose(com[0], (0.5, 0.5))
assert np.allclose(com[1], (2.5, 2.5))
def test_geometric_transforms():
img = np.ones((4, 4), dtype=np.float64)
zoomed = ndi.zoom(img, zoom=2.0)
assert zoomed.shape == (8, 8)
rotated = ndi.rotate(img, angle=90.0, reshape=False)
assert rotated.shape == (4, 4)
def main():
test_gaussian_filter()
test_label_and_find_objects()
test_morphology_dilation_and_erosion()
test_center_of_mass()
test_geometric_transforms()
print("All scipy.ndimage contract assertions passed.")
if __name__ == "__main__":
main()
オリジンシーダー
匿名