Skip to content

Commit 2fda4a8

Browse files
committed
docs: add refactoring plan for consolidating bootstrap logic (#183)
1 parent c7601f3 commit 2fda4a8

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

refactoring-plan-183.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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

0 commit comments

Comments
 (0)