Thank you for your interest in contributing to CANNs! This document provides guidelines and instructions for contributing to the project.
- Python 3.11 or higher
- uv package manager
- Clone the repository:
git clone https://github.com/routhleck/canns.git
cd canns- Install development dependencies:
make install-devThis will install the package with CPU support and all development tools (pytest, ruff, codespell, etc.).
For GPU support (Linux only):
make install-cuda12 # For CUDA 12
make install-cuda13 # For CUDA 13
make install-tpu # For TPUBefore submitting a pull request, ensure your code passes all quality checks:
make lint # Run formatting and linting checks
make test # Run the test suiteThe make lint command runs:
- ruff: Code formatting and linting
- codespell: Spell checking
- basedpyright: Type checking
make testTests are located in the tests/ directory and use pytest.
make docs # Build documentation
make docs-autoapi # Rebuild with fresh API documentationDocumentation will be generated in docs/_build/html/.
- Check existing issues before creating a new one
- Use the appropriate issue template (bug report, feature request, or custom)
- Provide clear reproduction steps for bugs
- Include relevant code snippets, error messages, and environment details
- Open an issue or discussion if you plan significant changes
- Fork the repository and create a new branch for your changes
- Follow the existing code style - the project uses ruff for formatting
- Write tests for new functionality
- Update documentation if you're adding or changing features
- Ensure all checks pass by running
make lint && make test
- Create a pull request with a clear title and description
- Reference any related issues
- Ensure CI checks pass
- Wait for review from maintainers
- Address any feedback or requested changes
Follow conventional commit format when possible:
feat:for new featuresfix:for bug fixesdocs:for documentation changestest:for test additions or modificationsrefactor:for code refactoringchore:for maintenance tasks
Example:
feat: add support for hierarchical CANNs
fix: resolve memory leak in CANN2D training
docs: update quick start guide with new examples
- Follow PEP 8 conventions
- Line length: 100 characters (configured in pyproject.toml)
- Use type hints where appropriate
- Write clear, self-documenting code
The project uses ruff for automatic formatting. Run make lint to format your code.
- Classes:
PascalCase(e.g.,CANN1D,SmoothTracking1D) - Functions/methods:
snake_case(e.g.,get_data,run_simulation) - Constants:
UPPER_SNAKE_CASE(e.g.,DEFAULT_TIMESTEP) - Private members: prefix with
_(e.g.,_internal_state)
src/canns/ # Core library modules
├── models/ # Neural network models
│ ├── basic/ # Basic CANN models (1D, 2D, SFA, hierarchical)
│ └── brain_inspired/ # Brain-inspired models (Hopfield, etc.)
├── task/ # Task generators
├── analyzer/ # Analysis tools
├── trainer/ # Training utilities
├── pipeline/ # End-to-end pipelines
└── visualization/ # Plotting and visualization
docs/ # Sphinx documentation and notebooks
examples/ # Ready-to-run example scripts
tests/ # Test suite
devtools/ # Development utilities
scripts/ # Utility scripts
- Create your model class in
src/canns/models/basic/orsrc/canns/models/brain_inspired/ - Inherit from
BasicModelbase class - Implement required methods
- Add tests in
tests/ - Add examples in
examples/ - Update documentation
- Create your task class in
src/canns/task/ - Inherit from
Taskbase class - Implement task-specific data generation
- Add tests and examples
- Update documentation
- Add analysis functions to
src/canns/analyzer/ - Follow existing patterns for consistency
- Include visualization capabilities where appropriate
- Add tests and examples
- Write unit tests for new functionality
- Ensure tests are deterministic and reproducible
- Use fixtures for common test setup
- Test edge cases and error conditions
- Aim for good test coverage
- Update docstrings for new or modified functions/classes
- Follow NumPy docstring format
- Add examples to docstrings where helpful
- Update relevant notebooks in
docs/en/notebooks/ - Add new examples to
examples/directory
- Open a discussion for questions
- Check existing issues and documentation
- Reach out to maintainers if you need guidance
By contributing to CANNs, you agree that your contributions will be licensed under the Apache License 2.0.
Contributors will be acknowledged in the project. Significant contributions may be highlighted in release notes.
Thank you for contributing to CANNs!