|
| 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 | +HyperTools is a Python library for visualizing and manipulating high-dimensional data. It provides a unified interface for dimensionality reduction, data alignment, clustering, and visualization, built on top of matplotlib, scikit-learn, and seaborn. |
| 8 | + |
| 9 | +## Key Commands |
| 10 | + |
| 11 | +### Testing |
| 12 | +- `pytest` - Run all tests from the hypertools/ directory |
| 13 | +- `pytest tests/test_<module>.py` - Run tests for a specific module |
| 14 | +- `pytest tests/test_<module>.py::test_<function>` - Run a specific test function |
| 15 | + |
| 16 | +### Development Setup |
| 17 | +- `pip install -e .` - Install in development mode |
| 18 | +- `pip install -r requirements.txt` - Install dependencies |
| 19 | +- `pip install -r docs/doc_requirements.txt` - Install documentation dependencies |
| 20 | + |
| 21 | +### Documentation |
| 22 | +- `cd docs && make html` - Build HTML documentation |
| 23 | +- `cd docs && make clean` - Clean documentation build files |
| 24 | + |
| 25 | +## Code Architecture |
| 26 | + |
| 27 | +### Core Components |
| 28 | + |
| 29 | +**DataGeometry Class** (`hypertools/datageometry.py`) |
| 30 | +- Central data container that holds raw data, transformed data, and transformation parameters |
| 31 | +- Stores matplotlib figure/axes handles and animation objects |
| 32 | +- Contains normalization, reduction, and alignment model parameters |
| 33 | + |
| 34 | +**Main API Functions** (`hypertools/__init__.py`) |
| 35 | +- `plot()` - Primary visualization function |
| 36 | +- `analyze()` - Data analysis and dimensionality reduction |
| 37 | +- `reduce()` - Dimensionality reduction utilities |
| 38 | +- `align()` - Data alignment across datasets |
| 39 | +- `normalize()` - Data normalization |
| 40 | +- `describe()` - Data description and summary |
| 41 | +- `cluster()` - Clustering functionality |
| 42 | +- `load()` - Data loading utilities |
| 43 | + |
| 44 | +**Tools Module** (`hypertools/tools/`) |
| 45 | +- `align.py` - Hyperalignment and Procrustes alignment |
| 46 | +- `reduce.py` - Dimensionality reduction (PCA, t-SNE, UMAP, etc.) |
| 47 | +- `normalize.py` - Data normalization methods |
| 48 | +- `cluster.py` - K-means and other clustering algorithms |
| 49 | +- `format_data.py` - Data preprocessing and formatting |
| 50 | +- `text2mat.py` - Text-to-matrix conversion |
| 51 | +- `df2mat.py` - DataFrame-to-matrix conversion |
| 52 | +- `load.py` - Data loading from various sources |
| 53 | +- `missing_inds.py` - Missing data handling |
| 54 | +- `procrustes.py` - Procrustes analysis |
| 55 | + |
| 56 | +**Plot Module** (`hypertools/plot/`) |
| 57 | +- `plot.py` - Main plotting interface and logic |
| 58 | +- `backend.py` - matplotlib backend configuration |
| 59 | +- `draw.py` - Low-level drawing functions |
| 60 | + |
| 61 | +**External Dependencies** (`hypertools/_externals/`) |
| 62 | +- `ppca.py` - Probabilistic Principal Component Analysis |
| 63 | +- `srm.py` - Shared Response Model |
| 64 | + |
| 65 | +### Data Flow |
| 66 | + |
| 67 | +1. **Input Processing**: Data is formatted and validated through `format_data()` |
| 68 | +2. **Normalization**: Optional data normalization via `normalize()` |
| 69 | +3. **Alignment**: Optional cross-dataset alignment via `align()` |
| 70 | +4. **Dimensionality Reduction**: Data is reduced via `reduce()` |
| 71 | +5. **Clustering**: Optional clustering via `cluster()` |
| 72 | +6. **Visualization**: Final plotting through `plot()` |
| 73 | + |
| 74 | +### Key Design Patterns |
| 75 | + |
| 76 | +- **Modular Architecture**: Each major operation (align, reduce, normalize, etc.) is in its own module |
| 77 | +- **Unified Interface**: All functions accept similar input formats (lists of arrays, DataFrames, etc.) |
| 78 | +- **Flexible Data Types**: Supports numpy arrays, pandas DataFrames, text data, and mixed inputs |
| 79 | +- **Matplotlib Integration**: Deep integration with matplotlib for customizable visualizations |
| 80 | +- **Animation Support**: Built-in support for animated visualizations |
| 81 | + |
| 82 | +## Development Notes |
| 83 | + |
| 84 | +- The package follows a functional programming style with separate modules for each operation |
| 85 | +- All major functions are designed to work with multiple input formats |
| 86 | +- The DataGeometry class serves as the central data container and state manager |
| 87 | +- Tests are located in `tests/` directory and follow pytest conventions |
| 88 | +- Documentation is built with Sphinx and uses example galleries |
| 89 | +- The codebase maintains compatibility with Python 3.9+ |
| 90 | + |
| 91 | +## Testing Strategy |
| 92 | + |
| 93 | +- Unit tests for individual tools and functions |
| 94 | +- Integration tests for end-to-end workflows |
| 95 | +- Example-based testing through documentation |
| 96 | +- Visual regression testing for plot outputs |
0 commit comments