Claude/codebase review lbz bs#9
Merged
Merged
Conversation
Implement complete test coverage for LogisticBandit package: Test Coverage: - LogisticBandit class: 28 tests covering initialization, updates, input validation, win_prop, edge cases, and sequential updates - TSPar class: 19 tests covering initialization, updates, input validation, win_prop, edge cases, and accumulation - Utils module: 18 tests covering logistic function, positive semidefinite checks, and integration tests Testing Infrastructure: - pytest configuration with sensible defaults - Test fixtures in conftest.py for common test scenarios - Coverage configuration (.coveragerc) - GitHub Actions CI/CD workflow for automated testing - Tests run on Ubuntu, macOS, and Windows - Python 3.6-3.10 compatibility testing - Automated linting with flake8, black, and mypy All 65 tests pass successfully! Test Features: - Input validation tests ensure proper error messages - Edge case tests (100% success, 0% success, large samples) - Monte Carlo sampling verification - Probability distribution validation - Type safety checks with numpy arrays
Coverage Analysis (88.24% overall): - Run pytest-cov and generate comprehensive coverage report - logisticbandit.py: 92.97% coverage - ts.py: 100% coverage - utils.py: 100% coverage - Create COVERAGE.md documenting uncovered lines and recommendations Type Checking with mypy: - Run mypy on all source files - Document 18 type hints issues (mostly Optional handling) - Create TYPE_CHECK.md with detailed analysis - Add mypy.ini configuration for reasonable defaults - All issues are low severity, runtime behavior is correct Examples Reorganization: - Create examples/ directory for clean example code - Move example.py → examples/basic_usage.py - Add examples/comparison.py - Compare ORTS, Full-TS, and Beta-Bernoulli - Add examples/ab_testing.py - Realistic A/B testing simulation - Add examples/README.md with usage instructions Example Features: - basic_usage.py: Simple operations and parameter tuning - comparison.py: Side-by-side method comparison, time-varying effects - ab_testing.py: Realistic A/B test with dynamic allocation - All examples are runnable and well-documented Documentation: - COVERAGE.md: Complete coverage analysis with recommendations - TYPE_CHECK.md: Type safety analysis and improvement suggestions - examples/README.md: How to use examples, common patterns, tips All examples tested and working!
Added sys.path manipulation to comparison.py and ab_testing.py to ensure they can import logisticbandit and ts modules when run from the examples directory. This completes the examples reorganization task. All three examples now run successfully: - examples/basic_usage.py ✓ - examples/comparison.py ✓ - examples/ab_testing.py ✓
Implemented a new LinearBandit class for multi-armed bandit problems with continuous rewards, complementing the existing LogisticBandit for binary outcomes. New Features: - LinearBandit class with Gaussian Thompson Sampling - Bayesian updates using conjugate Gaussian priors - Support for continuous reward values (revenue, latency, ratings, etc.) - Comprehensive test suite with 35 unit tests (100% pass rate) - Detailed example demonstrating various use cases - Full documentation in README.md Implementation Details: - linearbandit.py: Core implementation with Gaussian posterior updates - tests/test_linearbandit.py: 35 comprehensive unit tests covering: * Initialization and configuration * Update mechanics and Bayesian inference * Input validation * Thompson sampling (win_prop) * Decay for non-stationary environments * Edge cases and boundary conditions - examples/linear_bandit.py: 5 detailed examples: * Basic usage with multiple variants * Sequential learning and convergence * Exploration vs exploitation trade-offs * Dynamic environments with decay * Clear winner scenarios API Highlights: - update(obs, decay=0.0): Update with continuous reward observations - win_prop(action_list, draw, aggressive): Thompson sampling probabilities - get_statistics(): Detailed posterior statistics (mu, sigma, count, mean) - Configurable observation noise and prior uncertainty Updated Documentation: - README.md comprehensively updated with: * LinearBandit quick start guide * Complete API reference * Mathematical background on Gaussian Thompson Sampling * Updated examples section * Version 0.2.0 changelog Test Results: - All 100 tests passing (65 existing + 35 new) - LinearBandit fully tested and validated - Examples verified to run correctly This implementation enables the library to handle both binary and continuous reward scenarios, making it more versatile for real-world applications.
Fixed GitHub Actions CI failures on macOS arm64 by updating Python version matrix: Changes: - Removed Python 3.6 and 3.7 (not available on macOS arm64) - Added Python 3.11 for better compatibility - Updated test matrix to use Python 3.8, 3.9, 3.10, 3.11 - Added linearbandit.py to linting and type checking - Updated README badge from Python 3.6+ to Python 3.8+ This resolves the CI error: "The version '3.7' with architecture 'arm64' was not found for macOS 15.7.2" The library still supports Python 3.8+ which covers the vast majority of use cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.