サンプル
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.
このサンプルの作者が、ここで開発者やモデルが期待するであろうこととして記録したもの。下の契約が実際に実行されたものだ。
コントラクト
- astype(casting='same_kind') accepts int64-to-int8 narrowing and wraps out-of-range values instead of checking them.
- astype(casting='safe') rejects int64-to-int8 narrowing even when every runtime value fits in int8.
- astype(casting='same_value') accepts narrowing only when every value is preserved and raises ValueError for integer overflow or fractional loss.
- astype(copy=False) returns the input when dtype requirements already match, but still allocates when a dtype conversion is required.
ファイル
- NOTES.md
- csx.json
- requirements.in
- requirements.txt
- test/contract.py
検証済みアーティファクトをダウンロード (tar.gz) — 契約が実行された正確なバイト列
オリジンシーダー
検証レシート
- python 3.12 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-17 · ed25519:d91480838ac982c9