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.

Skills เพิ่มเติมจาก microsoft

oss-growth
microsoft
บุคลิกภาพนักเติบโตโอเอสเอส
official
winapp-ui-automation
microsoft
ตรวจสอบและโต้ตอบกับ UI ของแอปพลิเคชัน Windows ที่กำลังทำงานจากบรรทัดคำสั่งโดยใช้ UI Automation (UIA) ใช้เมื่อเอเจนต์ AI หรือนักพัฒนาจำเป็นต้องตรวจสอบ UI...
official
accessibility-aria-expert
microsoft
ตรวจจับและแก้ไขปัญหาการเข้าถึงใน React/Fluent UI webviews ใช้เมื่อตรวจสอบโค้ดเพื่อความเข้ากันได้กับโปรแกรมอ่านหน้าจอ แก้ไขป้ายกำกับ ARIA ทำให้มั่นใจว่า…
official
generate-canvas-app
microsoft
[เลิกใช้งานแล้ว — ใช้ canvas-app แทน] สร้างแอป Canvas ของ Power Apps ที่สมบูรณ์
official
django
microsoft
แนวทางปฏิบัติที่ดีที่สุดสำหรับการพัฒนาเว็บ Django รวมถึงโมเดล วิว เทมเพลต และการทดสอบ
official
github-issue-creator
microsoft
แปลงบันทึกดิบ บันทึกข้อผิดพลาด การเขียนตามคำบอก หรือภาพหน้าจอ ให้เป็นรายงานปัญหาที่ชัดเจนในรูปแบบ GitHub-flavored markdown ใช้เมื่อผู้ใช้วางข้อมูลบั๊ก ข้อผิดพลาด...
official
python-package-management
microsoft
ใช้ uv สำหรับการจัดการ dependencies และ poethepoet สำหรับการทำงานอัตโนมัติ
official
runtime-validation
microsoft
การตรวจสอบความถูกต้องขณะรันไทม์สำหรับแอปพลิเคชันที่ถูกย้าย — ครอบคลุมกลยุทธ์การทดสอบ (ระยะการวางแผน) และการดำเนินการทดสอบ (ระยะการตรวจสอบความถูกต้อง): การตรวจสอบการเริ่มต้นระบบ,…
official