HPFracc Development Guide๏
๐ Getting Started with Development๏
Prerequisites๏
Python 3.8+
Git
CUDA toolkit (for GPU development)
Development tools (make, cmake)
Development Setup๏
# Clone the repository
git clone https://github.com/dave2k77/fractional_calculus_library.git
cd fractional_calculus_library
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e .[dev,ml,gpu]
# Install pre-commit hooks
pre-commit install
๐๏ธ Project Structure๏
hpfracc/
โโโ core/ # Core fractional calculus definitions
โโโ algorithms/ # Numerical algorithms and methods (see ALGORITHMS_ARCHITECTURE.md)
โโโ ml/ # Machine learning integration
โโโ analytics/ # Performance monitoring and analytics
โโโ solvers/ # Fractional ODE/PDE/SDE solvers (see SOLVERS_ARCHITECTURE.md)
โโโ special/ # Special functions (see SPECIAL_ARCHITECTURE.md)
โโโ utils/ # Utility functions (see UTILS_ARCHITECTURE.md)
โโโ validation/ # Validation and testing utilities (see VALIDATION_ARCHITECTURE.md)
tests/ # Comprehensive test suite
examples/ # Example scripts and tutorials
docs/ # Documentation
scripts/ # Utility scripts
๐งช Testing๏
Run All Tests๏
python -m pytest tests/
Run Specific Test Categories๏
# Core functionality tests
python -m pytest tests/test_core/
# Machine learning tests
python -m pytest tests/test_ml/
# GPU tests (requires CUDA)
python -m pytest tests/test_gpu/ -m gpu
# Performance tests
python -m pytest tests/test_performance/
Test Coverage๏
python -m pytest --cov=hpfracc --cov-report=html
Algorithms test tree + coverage (measure hpfracc and read algorithms/ rowsโsee architecture note on --cov=hpfracc.algorithms vs JAX):
python -m pytest tests/test_algorithms/ --cov=hpfracc --cov-report=term-missing:skip-covered -q
See ALGORITHMS_ARCHITECTURE.md for a dependency diagram, risk notes, and a sample coverage table. For ฮ / binomial / MittagโLeffler layout and import conventions, see SPECIAL_ARCHITECTURE.md. For fractional ODE/PDE/SDE modules, aliases, and JAX/Diffrax integration, see SOLVERS_ARCHITECTURE.md.
๐ง Code Quality๏
Code Formatting๏
# Format code with black
black hpfracc/ tests/
# Check code style
flake8 hpfracc/ tests/
Type Checking๏
# Run mypy type checking
mypy hpfracc/
Pre-commit Hooks๏
The project uses pre-commit hooks to ensure code quality:
Black formatting
Flake8 linting
MyPy type checking
Import sorting
๐ฆ Building and Distribution๏
Build Package๏
python -m build
Install from Source๏
# Minimal (library runtime dependencies only)
pip install -e .
# Contributors: tests, coverage, formatters (matches CI)
pip install -e ".[dev]"
PyPI Publishing๏
# Build and upload to PyPI
python -m build
twine upload dist/*
๐ Performance Optimization๏
GPU Development๏
Use
hpfracc.ml.gpu_optimizationfor GPU-specific optimizationsTest with different CUDA versions
Profile memory usage with
memory_usage_decorator
Parallel Computing๏
Use NUMBA for JIT compilation
Implement parallel processing with
joblibMonitor performance with
PerformanceMonitor
Memory Management๏
Use chunked operations for large datasets
Implement memory-efficient algorithms
Monitor memory usage with analytics
๐ Analytics and Monitoring๏
Performance Monitoring๏
from hpfracc.analytics import PerformanceMonitor
monitor = PerformanceMonitor()
# Your code here
monitor.report()
Error Analysis๏
from hpfracc.analytics import ErrorAnalyzer
analyzer = ErrorAnalyzer()
# Your code here
analyzer.analyze_errors()
๐ฌ Research and Development๏
Adding New Methods๏
Create new method in appropriate module
Add comprehensive tests
Update documentation
Add performance benchmarks
Update API reference
Machine Learning Integration๏
Follow the backend management system
Implement unified tensor operations
Add fractional autograd support
Test across all backends (PyTorch, JAX, NUMBA)
Fractional Autograd Framework๏
Implement spectral, stochastic, or probabilistic methods
Add variance-aware training support
Test gradient flow and backpropagation
Benchmark performance
๐ Documentation๏
API Documentation๏
Update
docs/API_REFERENCE_v2.mdfor new featuresUse docstrings following NumPy style
Include examples in docstrings
User Guides๏
Update
docs/user_guide.rstfor new featuresAdd tutorials for complex features
Include performance benchmarks
Examples๏
Add examples in
examples/directoryOrganize by category (ml_examples, physics_examples, etc.)
Include comprehensive README files
๐ Debugging๏
Common Issues๏
Import Errors: Check module structure and
__init__.pyfilesGPU Issues: Verify CUDA installation and compatibility
Memory Issues: Use memory profiling tools
Performance Issues: Use performance monitoring
Debug Tools๏
# ``timing_decorator`` / ``memory_usage_decorator`` resolve via lazy import on ``hpfracc.core``
from hpfracc.core import timing_decorator, memory_usage_decorator
@timing_decorator
@memory_usage_decorator
def your_function():
pass
๐ค Contributing๏
Pull Request Process๏
Fork the repository
Create a feature branch
Make your changes
Add tests for new functionality
Update documentation
Run all tests and checks
Submit a pull request
Code Review Guidelines๏
Ensure all tests pass
Check code quality and style
Verify documentation is updated
Test performance impact
Review for security issues
๐ Release Process๏
Version Bumping๏
Update version in
pyproject.tomlUpdate version in
hpfracc/__init__.pyUpdate changelog
Tag release
Build and upload to PyPI
Release Checklist๏
All tests pass
Documentation updated
Performance benchmarks updated
Version numbers updated
Changelog updated
Release notes prepared
PyPI package built and tested
๐ Troubleshooting๏
Development Environment Issues๏
Check Python version compatibility
Verify all dependencies are installed
Check CUDA installation for GPU features
Ensure proper virtual environment setup
Build Issues๏
Check setuptools and wheel versions
Verify all dependencies are available
Check for circular imports
Validate package structure
Test Issues๏
Check test data availability
Verify GPU availability for GPU tests
Check memory requirements
Validate test environment setup
๐ Support๏
For development questions and issues:
Create an issue on GitHub
Check existing documentation
Review test cases for examples
Contact: d.r.chin@pgr.reading.ac.uk