CodeSampleX

샘플

scipy 1.18.0

검증된 샘플 — pypi scipy 1.18.0. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: scipy.ndimage.gaussian_filter applies multidimensional Gaussian…

sha256:a923af51ef20cc61ba1c4772803c783e75cc7577751b40614d30ff870a7f209d

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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 pkg:pypi/scipy@1.18.0
패키지
생성일
2026-08-27T19:55:06Z

컨트랙트

  1. scipy.ndimage.gaussian_filter applies multidimensional Gaussian smoothing while preserving array shape and mass
  2. scipy.ndimage.label identifies 2D connected components and returns component labels and count
  3. scipy.ndimage.binary_dilation expands foreground features in boolean mask arrays
  4. scipy.ndimage.binary_erosion shrinks foreground features in boolean mask arrays
  5. scipy.ndimage.rotate rotates 2D grid around center preserving dimensions when reshape=False
  6. scipy.ndimage.center_of_mass calculates coordinate center of mass for array values

파일

  • PROMPT.md
  • csx.json
  • pyproject.toml
  • requirements.txt
  • spec.json
  • src/ndimage_ops.py
  • 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 pkg:pypi/scipy@1.18.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/scipy@1.18.0

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:ccc15298a38b5fef81010fe77b932c2305286444e9e18cb8413200dcf07c0577","contract":["scipy.ndimage.gaussian_filter applies multidimensional Gaussian smoothing while preserving array shape and mass","scipy.ndimage.label identifies 2D connected components and returns component labels and count","scipy.ndimage.binary_dilation expands foreground features in boolean mask arrays","scipy.ndimage.binary_erosion shrinks foreground features in boolean mask arrays","scipy.ndimage.rotate rotates 2D grid around center preserving dimensions when reshape=False","scipy.ndimage.center_of_mass calculates coordinate center of mass for array values"],"goal":"verify pkg:pypi/scipy@1.18.0","kind":"HOW","packages":["pkg:pypi/scipy@1.18.0"],"schemaVersion":1},"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","verifierAdapter":"python@1"}
pyproject.toml
[project]
name = "verify-scipy"
version = "0.1.0"
dependencies = [
    "scipy==1.18.0",
]
requirements.txt
scipy==1.18.0
numpy==2.2.3
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/scipy@1.18.0",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/scipy@1.18.0"
  ]
}
src/ndimage_ops.py
"""Multi-dimensional image processing helpers using scipy.ndimage."""

import numpy as np
import scipy.ndimage as ndi


def apply_gaussian(input_array: np.ndarray, sigma: float = 1.0) -> np.ndarray:
    """Apply multidimensional Gaussian filter to input array."""
    return ndi.gaussian_filter(input_array, sigma=sigma)


def count_connected_components(binary_grid: np.ndarray) -> tuple[np.ndarray, int]:
    """Label connected components in a binary grid and return labeled array and count."""
    return ndi.label(binary_grid)


def dilate_mask(binary_grid: np.ndarray, iterations: int = 1) -> np.ndarray:
    """Perform binary dilation on a mask array."""
    return ndi.binary_dilation(binary_grid, iterations=iterations)


def erode_mask(binary_grid: np.ndarray, iterations: int = 1) -> np.ndarray:
    """Perform binary erosion on a mask array."""
    return ndi.binary_erosion(binary_grid, iterations=iterations)


def rotate_grid(grid: np.ndarray, angle: float) -> np.ndarray:
    """Rotate a 2D grid by specified angle without resizing original grid dimensions."""
    return ndi.rotate(grid, angle=angle, reshape=False)


def compute_center(grid: np.ndarray) -> tuple[float, ...]:
    """Compute center of mass coordinates for an array."""
    return ndi.center_of_mass(grid)
test/contract.py
"""Contract verification test for scipy.ndimage in pkg:pypi/scipy@1.18.0."""

import os
import sys
import numpy as np
import scipy.ndimage as ndi

# Ensure root directory is on sys.path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from src.ndimage_ops import (
    apply_gaussian,
    count_connected_components,
    dilate_mask,
    erode_mask,
    rotate_grid,
    compute_center,
)


def test_gaussian_filter():
    arr = np.zeros((7, 7), dtype=float)
    arr[3, 3] = 100.0

    smoothed = apply_gaussian(arr, sigma=1.0)
    assert smoothed.shape == (7, 7)
    assert smoothed[3, 3] < 100.0
    assert smoothed[3, 3] > 0.0
    assert smoothed[3, 2] > 0.0
    assert np.allclose(smoothed.sum(), 100.0, rtol=1e-2)


def test_label_connected_components():
    grid = np.array([
        [1, 1, 0, 0, 0],
        [1, 1, 0, 0, 0],
        [0, 0, 0, 1, 1],
        [0, 0, 0, 1, 1],
    ], dtype=int)

    labeled, num_features = count_connected_components(grid)
    assert num_features == 2
    assert labeled.shape == grid.shape
    assert labeled[0, 0] == labeled[1, 1]
    assert labeled[2, 3] == labeled[3, 4]
    assert labeled[0, 0] != labeled[2, 3]
    assert labeled[0, 2] == 0


def test_binary_dilation_and_erosion():
    mask = np.zeros((5, 5), dtype=bool)
    mask[2, 2] = True

    dilated = dilate_mask(mask, iterations=1)
    assert dilated[2, 2] is np.True_ or dilated[2, 2] == True
    assert dilated[1, 2] == True
    assert dilated[3, 2] == True
    assert dilated[2, 1] == True
    assert dilated[2, 3] == True
    assert dilated.sum() == 5

    eroded = erode_mask(dilated, iterations=1)
    assert eroded[2, 2] == True
    assert eroded.sum() == 1


def test_rotate():
    grid = np.zeros((5, 5), dtype=float)
    grid[2, 3] = 10.0

    rotated_180 = rotate_grid(grid, 180.0)
    assert rotated_180.shape == (5, 5)
    assert np.isclose(rotated_180[2, 1], 10.0, atol=1e-1)


def test_center_of_mass():
    arr = np.zeros((5, 5), dtype=float)
    arr[2, 2] = 50.0

    center = compute_center(arr)
    assert np.isclose(center[0], 2.0)
    assert np.isclose(center[1], 2.0)


def main():
    test_gaussian_filter()
    test_label_connected_components()
    test_binary_dilation_and_erosion()
    test_rotate()
    test_center_of_mass()
    print("All scipy.ndimage contract assertions passed.")
    return 0


if __name__ == "__main__":
    sys.exit(main())

오리진 시더

익명