샘플
pymatting 1.1.15: estimate_alpha_rw
검증된 샘플 — pypi pymatting 1.1.15: estimate_alpha_rw. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: assert estimate_alpha_rw computes random…
sha256:c7c3e5d40f19203a353073f207117f4015b7c0032022fee17f557828ce0291b9
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip 24
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-02 |
케이스
HOW- 목표
- verify pymatting.estimate_alpha_rw in pkg:pypi/pymatting@1.1.15
- 패키지
- 심벌
-
- pymatting.estimate_alpha_rw
- 환경
- python 3.12
- 생성일
- 2026-09-02T10:19:13Z
컨트랙트
- assert estimate_alpha_rw computes random walk alpha matte bounded in [0, 1] matching trimap constraints
- assert estimate_alpha_rw accepts custom laplacian_kwargs and cg_kwargs parameters
- assert estimate_alpha_rw raises ValueError when trimap is missing background values
파일
- 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 pymatting.estimate_alpha_rw in pkg:pypi/pymatting@1.1.15
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/pymatting@1.1.15
Demonstrate these symbols/APIs:
- pymatting.estimate_alpha_rw
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:b779f6e1f55847768cf323f818a5728f2ed4bc537033ae5753f565dd1fa68bdd","constraints":{"executionContext":"python"},"contract":["assert estimate_alpha_rw computes random walk alpha matte bounded in [0, 1] matching trimap constraints","assert estimate_alpha_rw accepts custom laplacian_kwargs and cg_kwargs parameters","assert estimate_alpha_rw raises ValueError when trimap is missing background values"],"goal":"verify pymatting.estimate_alpha_rw in pkg:pypi/pymatting@1.1.15","kind":"HOW","packages":["pkg:pypi/pymatting@1.1.15"],"schemaVersion":1,"symbols":["pymatting.estimate_alpha_rw"]},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","moduleSystem":"standard","os":"linux","osVersionBucket":"24","packageManager":"pip","packageManagerVersion":"24.0","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/pymatting@1.1.15"],"schemaVersion":1,"subject":"pkg:pypi/pymatting@1.1.15","symbols":["pymatting.estimate_alpha_rw"],"verifierAdapter":"python@1"}
[project]
name = "verify-pymatting"
version = "0.1.0"
dependencies = [
"pymatting==1.1.15",
]
pymatting==1.1.15
numpy
scipy
pillow
{
"schemaVersion": 1,
"goal": "verify pymatting.estimate_alpha_rw in pkg:pypi/pymatting@1.1.15",
"kind": "HOW",
"packages": [
"pkg:pypi/pymatting@1.1.15"
],
"symbols": [
"pymatting.estimate_alpha_rw"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import numpy as np
from pymatting import estimate_alpha_rw
def test_estimate_alpha_rw_basic():
h, w = 12, 12
image = np.zeros((h, w, 3), dtype=np.float64)
trimap = np.full((h, w), 0.5, dtype=np.float64)
trimap[:, :4] = 0.0
trimap[:, 8:] = 1.0
image[:, :4] = [0.1, 0.1, 0.1]
image[:, 8:] = [0.9, 0.9, 0.9]
image[:, 4:8] = [0.5, 0.5, 0.5]
alpha = estimate_alpha_rw(image, trimap)
assert alpha.shape == (h, w)
assert np.all(alpha >= -1e-5) and np.all(alpha <= 1.0 + 1e-5)
assert np.all(alpha[:, :4] < 0.1)
assert np.all(alpha[:, 8:] > 0.9)
def test_estimate_alpha_rw_custom_parameters():
h, w = 10, 10
image = np.zeros((h, w, 3), dtype=np.float64)
trimap = np.full((h, w), 0.5, dtype=np.float64)
trimap[:, :3] = 0.0
trimap[:, 7:] = 1.0
image[:, :3] = [0.2, 0.2, 0.2]
image[:, 7:] = [0.8, 0.8, 0.8]
image[:, 3:7] = [0.5, 0.5, 0.5]
alpha = estimate_alpha_rw(
image,
trimap,
laplacian_kwargs={"sigma": 0.05, "radius": 1},
cg_kwargs={"maxiter": 100},
)
assert alpha.shape == (h, w)
assert np.all(alpha >= -1e-5) and np.all(alpha <= 1.0 + 1e-5)
assert np.all(alpha[:, :3] < 0.1)
assert np.all(alpha[:, 7:] > 0.9)
def test_estimate_alpha_rw_invalid_trimap():
h, w = 8, 8
image = np.zeros((h, w, 3), dtype=np.float64)
no_bg_trimap = np.ones((h, w), dtype=np.float64)
try:
estimate_alpha_rw(image, no_bg_trimap)
assert False, "estimate_alpha_rw should raise ValueError when trimap is missing background"
except ValueError as exc:
assert isinstance(exc, ValueError)
def main():
test_estimate_alpha_rw_basic()
test_estimate_alpha_rw_custom_parameters()
test_estimate_alpha_rw_invalid_trimap()
print("All contract assertions passed.")
if __name__ == "__main__":
main()
오리진 시더
익명