File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Refactoring Plan for Issue #183 : Consolidate Bootstrap Generation Logic
2+
3+ ## Overview
4+ This PR addresses the code duplication in bootstrap generation by consolidating 15+ implementations of ` _generate_samples_single_bootstrap ` .
5+
6+ ## Proposed Solution: Template Method Pattern
7+
8+ ### Base Implementation:
9+ ``` python
10+ # In BaseTimeSeriesBootstrap
11+ def _generate_samples_single_bootstrap (self , X , y = None ):
12+ """ Template method for bootstrap generation"""
13+ # Step 1: Validate inputs
14+ self ._validate_bootstrap_inputs(X, y)
15+
16+ # Step 2: Prepare data
17+ prepared_data = self ._prepare_bootstrap_data(X, y)
18+
19+ # Step 3: Generate bootstrap samples (customizable)
20+ samples = self ._generate_bootstrap_samples(prepared_data)
21+
22+ # Step 4: Post-process samples
23+ return self ._post_process_samples(samples)
24+ ```
25+
26+ ## Files affected:
27+ - All bootstrap implementation files in ` src/tsbootstrap/ `
28+ - Base class: ` base.py `
29+
30+ ## Migration strategy:
31+ 1 . Implement template method in base class
32+ 2 . Migrate each bootstrap type incrementally
33+ 3 . Remove duplicated code
34+ 4 . Ensure backward compatibility
35+
36+ ## Testing plan:
37+ - Regression tests for each bootstrap type
38+ - Verify identical output before/after refactoring
39+ - Performance benchmarks
You can’t perform that action at this time.
0 commit comments