Ejemplo
scipy 1.18.0
Muestra verificada para pypi scipy 1.18.0. El contrato se ejecutó en python 3.12 · linux alpine/x64 · docker y pasó: scipy.ndimage.gaussian_filter applies…
sha256:a923af51ef20cc61ba1c4772803c783e75cc7577751b40614d30ff870a7f209d
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 pip
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify pkg:pypi/scipy@1.18.0
- Paquetes
- Creado
- 2026-08-27T19:55:06Z
Contrato
- 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
Archivos
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- spec.json
- src/ndimage_ops.py
- test/contract.py
Código fuente
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.
{"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"}
[project]
name = "verify-scipy"
version = "0.1.0"
dependencies = [
"scipy==1.18.0",
]
scipy==1.18.0
numpy==2.2.3
{
"schemaVersion": 1,
"goal": "verify pkg:pypi/scipy@1.18.0",
"kind": "HOW",
"packages": [
"pkg:pypi/scipy@1.18.0"
]
}
"""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)
"""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())
Seeder de origen
anónimo