|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Python Control Systems Library - implements basic operations for analysis and design of feedback control systems. Provides MATLAB-like functionality for linear and nonlinear systems. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Install dev dependencies |
| 13 | +pip install -e ".[test]" |
| 14 | + |
| 15 | +# Run all tests |
| 16 | +pytest -v |
| 17 | + |
| 18 | +# Run single test file |
| 19 | +pytest control/tests/statesp_test.py -v |
| 20 | + |
| 21 | +# Run single test |
| 22 | +pytest control/tests/statesp_test.py::test_function_name -v |
| 23 | + |
| 24 | +# Run tests excluding slow/optional |
| 25 | +pytest -m "not slow and not slycot and not cvxopt" |
| 26 | + |
| 27 | +# Lint |
| 28 | +ruff check control/ |
| 29 | + |
| 30 | +# Build docs |
| 31 | +cd doc && make html |
| 32 | +``` |
| 33 | + |
| 34 | +## Test Markers |
| 35 | + |
| 36 | +- `@pytest.mark.slycot` - requires slycot (FORTRAN wrapper) |
| 37 | +- `@pytest.mark.noslycot` - requires slycot absent |
| 38 | +- `@pytest.mark.cvxopt` - requires cvxopt |
| 39 | +- `@pytest.mark.pandas` - requires pandas |
| 40 | +- `@pytest.mark.slow` - slow tests (skip with `-m "not slow"`) |
| 41 | + |
| 42 | +## Architecture |
| 43 | + |
| 44 | +### Class Hierarchy |
| 45 | + |
| 46 | +``` |
| 47 | +InputOutputSystem (iosys.py) # Base: named signals, timebase |
| 48 | + └── LTI (lti.py) # Linear time-invariant base |
| 49 | + ├── StateSpace # State-space: dx/dt = Ax + Bu |
| 50 | + ├── TransferFunction # Transfer function: num/den polynomials |
| 51 | + └── FrequencyResponseData # FRD: frequency response data |
| 52 | + └── NonlinearIOSystem # Nonlinear: updfcn/outfcn callables |
| 53 | + └── InterconnectedSystem # Block diagram connections |
| 54 | +``` |
| 55 | + |
| 56 | +### Key Modules |
| 57 | + |
| 58 | +- `statesp.py` - StateSpace class, `ss()`, `rss()`, `drss()` |
| 59 | +- `xferfcn.py` - TransferFunction class, `tf()`, `zpk()` |
| 60 | +- `frdata.py` - FrequencyResponseData class, `frd()` |
| 61 | +- `nlsys.py` - NonlinearIOSystem, `interconnect()`, `linearize()` |
| 62 | +- `timeresp.py` - `step_response()`, `impulse_response()`, `input_output_response()` |
| 63 | +- `freqplot.py` - `bode_plot()`, `nyquist_plot()` |
| 64 | +- `statefbk.py` - `place()`, `lqr()`, `lqe()`, `acker()` |
| 65 | +- `optimal.py` - `optimal_trajectory()`, optimal control |
| 66 | +- `flatsys/` - differential flatness subpackage |
| 67 | + |
| 68 | +### Config System |
| 69 | + |
| 70 | +Global defaults in `control.config.defaults`. Use `config.set_defaults()` to modify. |
| 71 | + |
| 72 | +### Factory Functions |
| 73 | + |
| 74 | +Prefer factory functions over class constructors: |
| 75 | +- `ct.ss(A, B, C, D)` not `StateSpace(A, B, C, D)` |
| 76 | +- `ct.tf(num, den)` not `TransferFunction(num, den)` |
| 77 | + |
| 78 | +### Import Convention |
| 79 | + |
| 80 | +```python |
| 81 | +import numpy as np |
| 82 | +import control as ct |
| 83 | +``` |
0 commit comments