Пример
numpy 2.5.1: shares_memory
Проверенный пример — pypi numpy 2.5.1: shares_memory. Контракт выполнен на python 3.12 · linux alpine/x64 · docker и пройден: numpy.shares_memory returns…
sha256:bbcdf5ff6bffcbd4db71efbbb94a361d18c625e8d4c4a7366779a312472ecad4
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
python 3.12 linux x64 python 3.12 python pip
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1 |
2026-08-19 |
Кейс
HOW- Цель
- verify numpy.shares_memory in pkg:pypi/numpy@2.5.1
- Пакеты
- Символы
-
- numpy.shares_memory
- Окружение
- python 3.12
- Создан
- 2026-08-18T13:26:09Z
Контракт
- numpy.shares_memory returns true when two ndarrays share internal buffer storage.
- numpy.shares_memory returns true for basic slicing views of an array.
- numpy.shares_memory returns false for advanced integer indexing copies and independently allocated arrays.
Файлы
- PROMPT.md
- csx.json
- 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.shares_memory 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.shares_memory
Required runtime conditions:
- ecosystem: golang
- language: go
- packageManager: go@1.26.5
- runtime: go@1.26.5
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:5c18b1762393a061ab8c148325328618d6f05536d50e755d69afb5b32c326afd","contract":["numpy.shares_memory returns true when two ndarrays share internal buffer storage.","numpy.shares_memory returns true for basic slicing views of an array.","numpy.shares_memory returns false for advanced integer indexing copies and independently allocated arrays."],"goal":"verify numpy.shares_memory in pkg:pypi/numpy@2.5.1","kind":"HOW","packages":["pkg:pypi/numpy@2.5.1"],"schemaVersion":1,"symbols":["numpy.shares_memory"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","ecosystem":"pypi","executionContext":"python","language":"python","os":"linux","packageManager":"pip","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/numpy@2.5.1"],"schemaVersion":1,"symbols":["numpy.shares_memory"],"verifierAdapter":"python@1"}
numpy==2.5.1
{
"schemaVersion": 1,
"goal": "verify numpy.shares_memory in pkg:pypi/numpy@2.5.1",
"kind": "HOW",
"packages": [
"pkg:pypi/numpy@2.5.1"
],
"symbols": [
"numpy.shares_memory"
],
"runtimeConditions": {
"ecosystem": "golang",
"language": "go",
"packageManager": "go@1.26.5",
"runtime": "go@1.26.5"
}
}
import numpy as np
source = np.array([1, 2, 3], dtype=np.int32)
# np.array copies an ndarray by default. copy=False can reuse the exact input
# when no dtype or layout change is requested.
array_default = np.array(source)
assert array_default is not source
assert not np.shares_memory(array_default, source)
array_default[0] = 99
assert source.tolist() == [1, 2, 3]
array_reused = np.array(source, copy=False)
assert array_reused is source
assert np.shares_memory(array_reused, source)
# Basic slicing creates a view that shares memory.
slice_view = source[1:]
assert np.shares_memory(slice_view, source)
# Advanced indexing creates a copy that does not share memory.
advanced_copy = source[[1, 2]]
assert not np.shares_memory(advanced_copy, source)
# Equal values do not imply memory sharing.
same_values = np.array([2, 3], dtype=np.int32)
assert not np.shares_memory(slice_view, same_values)
print("CONTRACT PASS: numpy.shares_memory in numpy 2.5.1")
Исходный сидер
аноним