Coding Quality

This page describes the coding quality standards and practices used in the thompson package.

Quality Assurance

We value software quality as it leads to: - Fewer defects and bugs - Better security - Improved performance - Happier users - More effective development

According to McConnell (2004), different testing methods find different percentages of defects: - Unit testing: ~25% of defects - Function testing: ~35% of defects - Integration testing: ~45% of defects - Code review: ~55-60% of defects

This demonstrates that a combination of these methods is essential for high-quality software development.

Development Practices

The thompson package is developed using several quality assurance techniques:

  1. Code Style - PEP-8 compliance - Consistent formatting - Clear naming conventions - Comprehensive docstrings

  2. Code Complexity - Low technical debt - Modular design - Clear function boundaries - Maintainable structure

  3. Documentation - Detailed docstrings - API documentation - Usage examples - Tutorials and guides

  4. Testing - Unit tests - Integration tests - Code coverage - Continuous integration

  5. Code Review - Peer review process - Automated checks - Style enforcement - Quality metrics

Project Structure

The package follows a standard Python project structure:

thompson/
├── .editorconfig          # Editor configuration
├── .gitignore            # Git ignore rules
├── .pre-commit-config.yml # Pre-commit hooks
├── .prospector.yml       # Code quality checks
├── CHANGELOG.rst         # Version history
├── docs/                 # Documentation   ├── conf.py          # Sphinx configuration   ├── index.rst        # Main documentation   └── ...              # Other docs
├── LICENSE              # License file
├── MANIFEST.in          # Package files
├── NOTICE              # Legal notices
├── thompson/           # Source code   ├── __init__.py    # Package initialization   ├── __version__.py # Version information   └── thompson.py    # Main implementation
├── README.md          # Project overview
├── requirements.txt   # Dependencies
├── setup.cfg         # Package configuration
├── setup.py          # Installation script
└── tests/            # Test suite
    ├── __init__.py  # Test initialization
    └── test_thompson.py # Unit tests

Code Style

The package follows PEP-8 standards for Python code style: - Maximum line length: 79 characters - Indentation: 4 spaces - Naming conventions

Each public function includes a comprehensive docstring following numpy standards: - Description - Parameters - Returns - Examples - Notes

Complexity Management

We maintain low technical debt through: - Modular code organization - Clear function responsibilities - Comprehensive documentation - Regular code reviews - Automated quality checks

Benefits of this approach: - Higher code quality - Easier maintenance - Fewer bugs - Better security - Faster development

Unit Testing

The package includes comprehensive unit tests that verify: - Input validation - Output correctness - Parameter handling - Edge cases - Performance characteristics

Tests are implemented using Python’s unittest framework and cover: - Thompson Sampling algorithm - UCB algorithm - Randomized sampling - Plotting functionality - Data loading and processing

Continuous Integration

The package uses continuous integration to ensure quality: - Automated testing - Code coverage reporting - Style checking - Documentation building - Dependency management

This helps maintain consistent quality across all development.