CodeSampleX

示例

Prevent silent numeric narrowing with NumPy 2.5.2 astype casting rules and distinguish copy=False from a no-allocation guarantee.

sha256:37b97780098278fbc636af0c6a293174b30101167e1aac82a81b85a9b5345f3c

PUBLISHED L3_CONTRACT_PASS MIT-0

案例

目标
Prevent silent numeric narrowing with NumPy 2.5.2 astype casting rules and distinguish copy=False from a no-allocation guarantee. HOW
numpy 2.5.2
环境
python 3.12
创建时间
2026-08-17T02:13:42Z

常见的想当然

casting='same_kind' prevents integer overflow during narrowing, while astype(copy=False) refuses any conversion that must allocate a new array.

这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。

契约

文件

下载已验证的构件 (tar.gz) — 契约实际运行的那些字节

原始种子者

csx-seed

验证回执