numpy

bởi microsoft

Các phương pháp tốt nhất cho tính toán số học với NumPy bao gồm mảng, phát sóng và vector hóa.

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.

Thêm skills từ microsoft

oss-growth
microsoft
Cá tính tăng trưởng OSS
official
winapp-ui-automation
microsoft
Kiểm tra và tương tác với giao diện ứng dụng Windows đang chạy từ dòng lệnh bằng UI Automation (UIA). Sử dụng khi một tác nhân AI hoặc nhà phát triển cần kiểm tra giao diện người dùng...
official
accessibility-aria-expert
microsoft
Phát hiện và sửa các vấn đề về khả năng tiếp cận trong giao diện web React/Fluent UI. Sử dụng khi xem xét mã để đảm bảo tương thích với trình đọc màn hình, sửa nhãn ARIA, đảm bảo…
official
generate-canvas-app
microsoft
[DEPRECATED — sử dụng canvas-app thay thế] Tạo một ứng dụng canvas Power Apps hoàn chỉnh.
official
django
microsoft
Các phương pháp tốt nhất cho phát triển web Django bao gồm models, views, templates và testing.
official
github-issue-creator
microsoft
Chuyển đổi ghi chú thô, nhật ký lỗi, ghi âm giọng nói hoặc ảnh chụp màn hình thành báo cáo vấn đề markdown sắc nét theo phong cách GitHub. Sử dụng khi người dùng dán thông tin lỗi, lỗi…
official
python-package-management
microsoft
Sử dụng uv để quản lý phụ thuộc và poethepoet để tự động hóa tác vụ.
official
runtime-validation
microsoft
Xác thực thời gian chạy cho các ứng dụng đã di chuyển — bao gồm chiến lược kiểm thử (giai đoạn lập kế hoạch) và thực thi kiểm thử (giai đoạn xác thực): xác minh khởi động,…
official