據 AlphaMoat 統計,截至 2026-09,NumPy 累計下載 1,657 次、獲 0 個星標,在全部 5,078 個 AI 技能中排名第 4,669 位,在「開發程式設計」分類(577 個)中排名第 549 位。
| 平台 | 累計安裝 | 累計下載 | 星標 | 評論 |
|---|---|---|---|---|
| ClawHub ↗ | 40 | 1473 | - | - |
| SkillHub ↗ | 113 | 1657 | - | — |
各平台的計數口徑不同,統計時間不一致。
內容包括陣列形狀與型別、軸操作、內建數學函式、檢視與副本、資料整理和矩陣運算。技能說明計算在本地執行,但可能儲存偏好和程式碼片段;只在使用者明確同意後儲存必要資訊,並讓本地記錄可檢查和刪除。 初始化還建議寫入共享主記憶;寫入前須取得明確同意。
資料釋出於 2026-10-29
以下是根據技能文件生成的示例,不代表實際執行結果。
2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。
| 月份 | 累計下載 | 環比 | 星標 |
|---|---|---|---|
| 2026-09 | 1657 | — | - |
| 2026-08 | 1393 | +8.7% | - |
| 2026-07 | 1282 | +18.6% | - |
| 2026-06 | 1081 | +13.8% | - |
| 2026-05 | 950 | — | - |
| 2026-03 | 596 | — | - |
以下是作者釋出的原始檔案,按純文字顯示,本站未做修改或稽核;其中的連結不可點選,命令請核實後再執行。抓取於 2026-10-23。
---
name: NumPy
slug: numpy
version: 1.0.0
homepage: https://clawic.com/skills/numpy
description: Write fast, memory-efficient numerical code with arrays, broadcasting, vectorization, and linear algebra.
metadata: {"clawdbot":{"emoji":"🔢","requires":{"bins":["python3"]},"os":["linux","darwin","win32"]}}
---
## Setup
On first use, read `setup.md` for integration guidelines. Creates `~/numpy/` to store preferences and snippets.
## When to Use
User needs numerical computing in Python. Agent handles array operations, mathematical computations, linear algebra, and data manipulation with NumPy.
## Architecture
Memory lives in `~/numpy/`. See `memory-template.md` for structure.
```
~/numpy/
├── memory.md # Preferences + common patterns used
└── snippets/ # User's saved code patterns
```
## Quick Reference
| Topic | File |
|-------|------|
| Setup process | `setup.md` |
| Memory template | `memory-template.md` |
## Core Rules
### 1. Vectorize First
Never use Python loops for array operations. NumPy's vectorized operations are 10-100x faster.
```python
# BAD - Python loop
result = []
for x in arr:
result.append(x * 2)
# GOOD - Vectorized
result = arr * 2
```
### 2. Understand Broadcasting
Broadcasting allows operations on arrays of different shapes. Know the rules:
- Dimensions align from the right
- Size-1 dimensions stretch to match
- Missing dimensions treated as size-1
```python
# Shape (3,1) + (4,) broadcasts to (3,4)
a = np.array([[1], [2], [3]]) # (3,1)
b = np.array([10, 20, 30, 40]) # (4,)
result = a + b # (3,4)
```
### 3. Prefer Views Over Copies
Slicing returns views (same memory). Use `.copy()` only when needed.
```python
# View - modifying b changes a
b = a[::2]
# Copy - independent
b = a[::2].copy()
```
### 4. Use Appropriate Dtypes
Choose the smallest dtype that fits your data. Saves memory and speeds up computation.
```python
# For integers 0-255
arr = np.array(data, dtype=np.uint8)
# For floats that don't need double precision
arr = np.array(data, dtype=np.float32)
```
### 5. Axis Awareness
Most functions accept `axis` parameter. Know your axes:
- `axis=0`: operate along rows (down columns)
- `axis=1`: operate along columns (across rows)
- `axis=None` or omit: operate on flattened array
```python
arr = np.array([[1, 2], [3, 4]])
np.sum(arr, axis=0) # [4, 6] - sum each column
np.sum(arr, axis=1) # [3, 7] - sum each row
```
### 6. Leverage Built-in Functions
NumPy has optimized functions for common operations. Don't reinvent them.
| Need | Use |
|------|-----|
| Element-wise math | `np.sin`, `np.exp`, `np.log` |
| Statistics | `np.mean`, `np.std`, `np.median` |
| Linear algebra | `np.dot`, `np.linalg.*` |
| Sorting | `np.sort`, `np.argsort` |
| Searching | `np.where`, `np.searchsorted` |
## NumPy Traps
### Shape Mismatches
```python
# TRAP: Confusing (n,) with (n,1) or (1,n)
a = np.array([1, 2, 3]) # shape (3,)
b = np.array([[1, 2, 3]]) # shape (1,3)
c = np.array([[1], [2], [3]]) # shape (3,1)
# FIX: Use reshape or newaxis
a.reshape(-1, 1) # (3,1)
a[np.newaxis, :] # (1,3)
```
### Silent Type Coercion
```python
# TRAP: Integer array silently truncates floats
arr = np.array([1, 2, 3]) # int64
arr[0] = 1.9 # becomes 1, not 1.9!
# FIX: Declare dtype upfront
arr = np.array([1, 2, 3], dtype=np.float64)
```
### View vs Copy Confusion
```python
# TRAP: Fancy indexing returns copy, slicing returns view
arr = np.array([1, 2, 3, 4, 5])
# This is a VIEW (changes affect original)
view = arr[1:4]
# This is a COPY (independent)
copy = arr[[1, 2, 3]]
```
### Broadcasting Surprises
```python
# TRAP: Unexpected broadcasting
a = np.array([1, 2, 3])
b = np.array([1, 2])
a + b # ERROR - shapes don't broadcast
# TRAP: Accidental broadcasting
a = np.zeros((3, 4))
b = np.array([1, 2, 3])
a + b # ERROR - (3,4) and (3,) don't align
a + b.reshape(-1, 1) # Works - (3,4) and (3,1)
```
### In-Place Operations
```python
# TRAP: Some operations modify in-place, others don't
np.sort(arr) # Returns sorted copy
arr.sort() # Sorts in-place
# Safe pattern: be explicit
arr = np.sort(arr) # Clear intent
```
## Essential Patterns
### Create Arrays
```python
np.zeros((3, 4)) # All zeros
np.ones((3, 4)) # All ones
np.full((3, 4), 7) # All sevens
np.eye(3) # Identity matrix
np.arange(0, 10, 2) # [0, 2, 4, 6, 8]
np.linspace(0, 1, 5) # [0, 0.25, 0.5, 0.75, 1]
np.random.rand(3, 4) # Uniform [0,1)
np.random.randn(3, 4) # Normal distribution
```
### Reshape and Stack
```python
arr.reshape(2, 6) # New shape (must match size)
arr.flatten() # 1D copy
arr.ravel() # 1D view
np.concatenate([a, b]) # Join along existing axis
np.stack([a, b]) # Join along new axis
np.vstack([a, b]) # Stack vertically
np.hstack([a, b]) # Stack horizontally
```
### Boolean Indexing
```python
arr = np.array([1, 5, 3, 8, 2])
mask = arr > 3
arr[mask] # [5, 8]
arr[arr > 3] = 0 # Replace values > 3 with 0
np.where(arr > 3, 1, 0) # 1 where >3, else 0
```
### Linear Algebra
```python
np.dot(a, b) # Matrix multiplication
a @ b # Same (Python 3.5+)
np.linalg.inv(a) # Inverse
np.linalg.det(a) # Determinant
np.linalg.eig(a) # Eigenvalues/vectors
np.linalg.solve(a, b) # Solve Ax = b
```
## Security & Privacy
**Data that stays local:**
- All computations run locally
- Code patterns saved in ~/numpy/
**This skill does NOT:**
- Send data externally
- Access files outside ~/numpy/
- Require network connectivity
## Related Skills
Install with `clawhub install <slug>` if user confirms:
- `data` — data processing workflows
- `math` — mathematical computations
- `statistics` — statistical analysis
## Feedback
- If useful: `clawhub star numpy`
- Stay updated: `clawhub sync`
用 gh 命令列工具檢視 GitHub 上的 PR 檢查、工作流執行與 API 查詢的技能。
聚合 16 個搜尋引擎、無需 API Key 的檢索技能。
用命令列直接列出、配置、授權並呼叫 MCP 服務與工具。
根據文字描述生成 Mermaid 圖表程式碼。
用受管 OAuth 訪問 YouTube Data API,檢索影片並管理頻道內容。
透過受管的 OAuth 連線訪問 GitHub REST API。
覆蓋規劃、實現、驗證與測試的編碼工作流技能。
整理 Docker 常用命令與容器工作流的技能。
將使用者明確糾正與自我檢視整理成分層記憶,並依使用情況升級或封存。
在保留公式、格式和活頁簿結構的前提下建立、檢查或編輯 Excel 檔案。
處理 Word 與 DOCX 文件的作業指南,著重維持樣式、編號與版面。
把資料庫、表格與匯出的原始資料變成可決策結論的資料分析技能。
協助編輯 PowerPoint 簡報,並在交付前檢查版面是否正常呈現。
資料月份:2026-09 · 下載/星標/安裝數聚合自公開技能註冊庫(ClawHub、SkillHub),按月更新。口徑說明見資料方法。