Agent skill
numpy-set-ops
Install this agent skill to your Project
npx add-skill https://github.com/cuba6112/skillfactory/tree/main/skills/numpy-set-ops
SKILL.md
Overview
NumPy provides vectorized set operations for 1D arrays and multidimensional subarrays. These tools allow for deduplication, membership testing, and finding differences/intersections between datasets.
When to Use
- Deduplicating rows in a large feature matrix.
- Filtering a dataset to exclude a list of forbidden values.
- Synchronizing two datasets by finding their intersection.
- Compressing data by storing unique values and their index mappings.
Decision Tree
- Need to find non-duplicate elements?
- Use
np.unique.
- Use
- Need to reconstruct the original array from unique values?
- Set
return_inverse=Trueinnp.unique.
- Set
- Checking if elements exist in another list?
- Use
np.isin(data, target_list).
- Use
Workflows
-
Finding Unique Rows in a Dataset
- Create a 2D array.
- Call
np.unique(arr, axis=0). - Inspect the result to see the deduplicated records.
-
Reconstructing an Array from Sets
- Call
u, inv = np.unique(arr, return_inverse=True). - Store 'u' and 'inv' separately (useful for data compression).
- Rebuild the original array using
u[inv].
- Call
-
Filtering by Membership
- Define a 'forbidden' set of values.
- Generate a boolean mask using
~np.isin(data, forbidden). - Filter the data:
clean_data = data[mask].
Non-Obvious Insights
- Flattening by Default: Set operations work on flattened 1D versions of input arrays unless an
axisis explicitly specified. - NaN Handling: Like sorting,
uniquetreatsNaNas a value and sorts it to the end of the unique output. - Lexicographic Row Sort: When
axis=0is used inunique, the resulting unique rows are sorted lexicographically.
Evidence
- "Returns the sorted unique elements of an array." Source
- "isin(element, test_elements...)... broadcasting over element only." Source
Scripts
scripts/numpy-set-ops_tool.py: Routines for unique row detection and inverse reconstruction.scripts/numpy-set-ops_tool.js: Simulated set intersection logic.
Dependencies
numpy(Python)
References
- references/README.md
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
prompt-engineering
Comprehensive prompt engineering techniques for Claude models. Use this skill when crafting, optimizing, or debugging prompts for Claude API, Claude Code, or any Claude-powered application. Covers system prompts, role prompting, multishot examples, chain of thought, XML structuring, long context handling, extended thinking, prompt chaining, Claude 4.x-specific best practices, and agentic orchestration including subagents, agent loops, skills, MCP integration, and multi-agent workflows.
adk-rag-agent
Build RAG (Retrieval-Augmented Generation) agents with Google ADK and Vertex AI RAG Engine. Use when implementing document Q&A, knowledge base search, or citation-backed responses. Covers VertexAiRagRetrieval tool, corpus setup, and citation formatting.
headless-cli-agents
Build agentic systems using Claude CLI in headless mode or the Claude Agent SDK. Use when building automation pipelines, CI/CD integrations, multi-agent orchestration, or programmatic Claude interactions. Covers CLI flags (-p, --output-format), session management (--resume, --continue), Python SDK (claude-agent-sdk), custom tools, and agent loop patterns.
notion-knowledge-capture
Capture conversations and decisions into structured Notion pages; use when turning chats/notes into wiki entries, how-tos, decisions, or FAQs with proper linking.
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
gh-fix-ci
Inspect GitHub PR checks with gh, pull failing GitHub Actions logs, summarize failure context, then create a fix plan and implement after user approval. Use when a user asks to debug or fix failing PR CI/CD checks on GitHub Actions and wants a plan + code changes; for external checks (e.g., Buildkite), only report the details URL and mark them out of scope.
Didn't find tool you were looking for?