numpy

作成者: microsoft

NumPyを用いた数値計算のベストプラクティス(配列、ブロードキャスティング、ベクトル化を含む)

npx skills add https://github.com/microsoft/debugpy --skill numpy

Skill: NumPy

Best practices for numerical computing with NumPy including arrays, broadcasting, and vectorization.

When to Use

Apply this skill when doing numerical computing with NumPy — arrays, broadcasting, linear algebra, random sampling.

Arrays

  • Use explicit dtypes (np.float64, np.int32) when creating arrays.
  • Prefer np.zeros, np.ones, np.empty, np.arange, np.linspace over list-based construction.
  • Use structured arrays or separate arrays instead of object arrays.

Vectorization

  • Replace Python loops with vectorized NumPy operations wherever possible.
  • Use broadcasting rules to operate on arrays of different shapes without explicit expansion.
  • Use np.where() for conditional element-wise operations.

Memory

  • Use np.float32 instead of np.float64 when precision is not critical to halve memory.
  • Use views (reshape, slicing) instead of copies when data doesn't need mutation.
  • Use np.memmap for arrays too large to fit in RAM.

Random

  • Use np.random.default_rng(seed) (new Generator API) instead of np.random.seed().
  • Always seed random generators in tests for reproducibility.

Pitfalls

  • Don't compare floats with ==; use np.allclose() or np.isclose().
  • Beware of silent integer overflow in integer arrays.
  • Avoid np.matrix — it's deprecated; use 2D np.ndarray.

microsoftのその他のスキル

oss-growth
microsoft
OSS成長ハッカーのペルソナ
official
winapp-ui-automation
microsoft
コマンドラインからUI Automation(UIA)を使用して、実行中のWindowsアプリのUIを検査および操作します。AIエージェントや開発者がUIを検査する必要がある場合に使用します…
official
accessibility-aria-expert
microsoft
React/Fluent UIのWebビューにおけるアクセシビリティ問題を検出・修正します。スクリーンリーダー互換性のコードレビュー時、ARIAラベルの修正時、および…の確認時に使用します。
official
generate-canvas-app
microsoft
[DEPRECATED — 代わりに canvas-app を使用してください] 完全なPower Appsキャンバスアプリを生成します。
official
django
microsoft
Djangoウェブ開発のベストプラクティス(モデル、ビュー、テンプレート、テストを含む)
official
github-issue-creator
microsoft
生のメモ、エラーログ、音声入力、スクリーンショットを、簡潔なGitHub Flavored MarkdownのIssueレポートに変換します。ユーザーがバグ情報やエラーを貼り付けた際に使用します。
official
python-package-management
microsoft
依存関係管理にuvを使用し、タスク自動化にpoethepoetを使用します。
official
runtime-validation
microsoft
移行アプリケーションのランタイム検証 — テスト戦略(計画フェーズ)とテスト実行(検証フェーズ)をカバー:起動検証、…
official