SciPy
Solve optimization, statistics, signal processing, and linear algebra problems with SciPy recipes and ready-to-run code.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/ivangdavila/scipySetup
On first use, read setup.md for guidance on how to help the user effectively.
When to Use
User needs scientific computing in Python: optimization, curve fitting, statistical tests, signal processing, interpolation, integration, or linear algebra. Agent provides working code, not theory.
Architecture
This skill is stateless — no persistent storage needed. All code runs in user's Python environment.
See memory-template.md for optional preference tracking.
Quick Reference
| Topic | File |
|---|---|
| Usage guidance | setup.md |
| Optional preferences | memory-template.md |
Core Rules
1. Working Code First
Every response includes runnable code. No pseudocode, no "implement this yourself".
# Always include imports
from scipy import optimize
import numpy as np
# Complete, working example
result = optimize.minimize(lambda x: x**2, x0=1.0)
print(f"Minimum at x={result.x[0]:.4f}")
2. Module Selection Guide
| Problem | Module | Key Function |
|---|---|---|
| Find minimum/maximum | scipy.optimize | minimize, minimize_scalar |
| Curve fitting | scipy.optimize | curve_fit |
| Root finding | scipy.optimize | root, brentq, fsolve |
| Statistical tests | scipy.stats | ttest_ind, chi2_contingency |
| Distributions | scipy.stats | norm, poisson, expon |
| Filter signals | scipy.signal | butter, filtfilt, savgol_filter |
| FFT | scipy.fft | fft, ifft, fftfreq |
| Interpolation | scipy.interpolate | interp1d, UnivariateSpline |
| Integration | scipy.integrate | quad, solve_ivp |
| Linear algebra | scipy.linalg | solve, eig, svd |
| Sparse matrices | scipy.sparse | csr_matrix, linalg.spsolve |
| Spatial data | scipy.spatial | KDTree, distance |
| Image processing | scipy.ndimage | gaussian_filter, label |
3. Explain Key Parameters
When code uses non-obvious parameters, explain why:
# method='L-BFGS-B' for bounded optimization
# bounds prevent physically impossible values
result = optimize.minimize(
objective, x0,
method='L-BFGS-B',
bounds=[(0, None), (0, 100)] # x1 >= 0, 0 <= x2 <= 100
)
4. Validate Results
Always include sanity checks:
result = optimize.minimize(func, x0)
if not result.success:
print(f"⚠️ Optimization failed: {result.message}")
else:
print(f"✓ Converged in {result.nit} iterations")
5. NumPy Integration
SciPy builds on NumPy. Use vectorized operations:
# ✓ Vectorized (fast)
x = np.linspace(0, 10, 1000)
y = np.sin(x)
# ✗ Loop (slow)
y = [np.sin(xi) for xi in x]
Optimization Patterns
Minimize a Function
from scipy.optimize import minimize
import numpy as np
# Rosenbrock function (classic test)
def rosenbrock(x):
return sum(100*(x[1:]-x[:-1]**2)**2 + (1-x[:-1])**2)
x0 = np.array([0, 0])
result = minimize(rosenbrock, x0, method='BFGS')
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-ivangdavila-scipy": {
"enabled": true,
"auto_update": true
}
}
}Related Skills
Animations
Create performant web animations with proper accessibility and timing.
Arduino
Develop Arduino projects avoiding common wiring, power, and code pitfalls.
Bulgarian
Write Bulgarian that sounds human. Not formal, not robotic, not AI-generated.
Arabic
Write Arabic that sounds human. Not formal, not robotic, not AI-generated.
Assistant
Manage tasks, communications, and scheduling with proactive and organized support.