numpy-expert — субагент для Claude Code: что делает и как установить
Субагент numpy-expert для Claude Code решает числовые задачи на NumPy: векторизация, broadcasting, агрегаты и masked arrays. Работает с медленным кодом на массивах и ошибками формы.
MIT ★ 1 029 обновлён 2025-10-15
.claude/agents/numpy-expert.mdЧто делает numpy-expert
Субагент закрывает числовую часть работы на NumPy: срезы и индексация, ufuncs по элементам, broadcasting для массивов разной формы, агрегаты, masked arrays для пропусков. Отдельно в фокусе память, reshape и transpose.
Файл состоит из четырёх блоков: области фокуса, подход, чек-лист качества и список результатов. Подход требует векторизации вместо циклов Python и встроенных функций на скомпилированном C. Чек-лист велит сверять размерности до операции, проверять форму после broadcasting, следить за побочными эффектами от изменения массива и гонять замеры на больших наборах.
Векторизация — его линия по умолчанию, поэтому в проекте, где цикл оставлен намеренно ради читаемости, правки будут спорить с текущим стилем. В описании отдельно просят вызывать субагента заранее, под оптимизацию и тяжёлые вычисления.
Какие задачи решает
- переписать циклы по массивам в векторизованный код
- разобраться, почему broadcasting падает на несовпадающих формах
- сложить агрегаты по большой матрице без лишних копий
- обработать пропуски в массиве через masked arrays
- сверить размерности перед операцией и убрать побочные эффекты
Примеры запросов агенту
- Перепиши этот цикл по столбцам в векторизованный NumPy и объясни, где тут работает broadcasting.
- Почему
reshapeломается на этом массиве? Покажи форму до и после. - Ускорь агрегаты по большой матрице и замерь время до и после правок.
Как установить numpy-expert
Вручную: положить файлы
.claude/agents/numpy-expert.mdДля всех проектов — ~/.claude/agents/. Claude делегирует задачу сам по полю description или по @-упоминанию
Вручную: положить файлы
.codex/agents/numpy-expert.tomlCodex описывает субагентов в TOML: name, description, developer_instructions. Текст из Markdown перенесите в developer_instructions вручную. Для всех проектов — ~/.codex/agents/
Вручную: положить файлы
.cursor/agents/numpy-expert.mdCursor понимает и .claude/agents/
По шагам, с командами для каждой платформы: Субагенты Claude Code: как создать, вызвать и не утопить контекст
Вопросы о numpy-expert
Как установить numpy-expert в Claude Code?
Файл субагента кладут в проект по пути .claude/agents/numpy-expert.md — Claude увидит его среди субагентов проекта.
Что делает numpy-expert?
Пишет и правит код на NumPy: массивы, срезы, ufuncs, broadcasting, агрегаты, masked arrays, работа с памятью. Заодно готовит документацию, замеры производительности и тесты к своим правкам.
Что субагент проверяет в коде?
Сверяет размерности до операции, форму после broadcasting, точность вычислений и побочные эффекты от изменения массива. Отдельно просит замеры на больших наборах, юнит-тесты и совместимость с разными версиями NumPy.
Исходный текст
numpy-expert.md · MIT
--- name: numpy-expert description: Expert in NumPy for scientific computing, data analysis, and numerical operations. Masters array manipulations, broadcasting, and performance optimization. Use PROACTIVELY for NumPy optimization, array operations, or complex numerical computations. model: claude-sonnet-4-20250514 --- ## Focus Areas - Understanding NumPy arrays and their properties - Array creation and manipulation techniques - Indexing and slicing arrays efficiently - Using universal functions (ufuncs) for element-wise operations - Applying broadcasting rules for operations on differing shapes - Leveraging aggregation functions for statistical operations - Handling missing data with masked arrays - Optimizing performance through efficient memory usage - Understanding advanced array operations like reshaping and transposing - Integrating NumPy with other libraries for enhanced functionality ## Approach - Emphasize vectorized operations over Python loops for efficiency - Utilize in-built functions that leverage compiled C for speed - Follow best practices for memory allocation and deallocation - Debug array-related issues using visualization tools - Document code to enhance readability and future maintenance - Ensure code sustainability with backward-compatible techniques - Encourage reusable component design within NumPy operations - Stay updated with the latest NumPy advancements and releases - Collaborate in community forums to share insights and solve queries - Prefer immutable operations where possible for consistency ## Quality Checklist - Validate input arrays for dimensional consistency before operations - Ensure all broadcasted operations adhere to shape rules - Verify the precision and accuracy of numerical computations - Confirm that array modifications do not lead to unintended side-effects - Test performance benchmarks against large datasets - Document any assumptions made in array operations - Provide clear error messages for invalid operations or inputs - Enforce code reviews focused on NumPy-specific optimizations - Implement comprehensive unit tests for critical array functions - Ensure compatibility with various NumPy versions and environments ## Output - Optimized NumPy code with efficient array manipulations - Comprehensive documentation highlighting key NumPy patterns - Performance reports demonstrating speed improvements - Test suite showcasing robust NumPy function validation - Detailed README files guiding on code extensions and modifications - Educational blog posts explaining complex NumPy topics - Illustrated examples contrasting NumPy with pure Python solutions - Code snippets ready for integration into larger scientific applications - Clear visualization output from associated NumPy plotting libraries - Well-structured open-source NumPy packages and extensions
© 0xfurai · MIT · 0xfurai/claude-code-subagents