Skip to content

Commit 355ec45

Browse files
committed
ruff lint
1 parent 31fe8ce commit 355ec45

File tree

18 files changed

+97
-97
lines changed

18 files changed

+97
-97
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ import geo_sampling as gs
8585

8686
# Quick sampling for research
8787
sample = gs.sample_roads_for_region(
88-
"Singapore", "Central",
89-
n=100,
88+
"Singapore", "Central",
89+
n=100,
9090
strategy="random"
9191
)
9292

docs/_includes/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ This will automatically run linting, formatting, and type checking before each c
3030

3131
```bash
3232
uv run pre-commit run --all-files
33-
```
33+
```

docs/_includes/quickstart.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ import geo_sampling as gs
4444

4545
# Quick sampling for research
4646
sample = gs.sample_roads_for_region(
47-
"Singapore", "Central",
48-
n=100,
47+
"Singapore", "Central",
48+
n=100,
4949
strategy="random",
5050
seed=42
5151
)
@@ -75,5 +75,5 @@ gs.plot_road_segments(sample, title="Delhi Road Sample")
7575
## What's Next?
7676

7777
- 📖 Check out [detailed examples](examples/index.md) for more complex use cases
78-
- 🔧 Learn about [advanced sampling strategies](examples/advanced.md)
79-
- 📚 Browse the [API reference](reference/index.md) for complete documentation
78+
- 🔧 Learn about [advanced sampling strategies](examples/advanced.md)
79+
- 📚 Browse the [API reference](reference/index.md) for complete documentation

docs/_includes/sampling-strategy.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This package implements a systematic approach to sampling street locations for d
77
Get all the streets in the region of interest from [OpenStreetMap](https://www.openstreetmap.org/). The package:
88

99
1. Downloads administrative boundary data from [GADM](http://www.gadm.org/) in ESRI format
10-
2. Identifies the geographic bounds of your region of interest
10+
2. Identifies the geographic bounds of your region of interest
1111
3. Extracts road data from [BBBike.org](http://extract.bbbike.org) for the bounded area
1212
4. Processes the road network into manageable segments
1313

@@ -23,7 +23,7 @@ Administrative levels are hierarchical - cities are nested in states, which are
2323

2424
### Road Type Classification
2525
The package preserves OpenStreetMap road classifications:
26-
- **trunk**: National highways and major arterials
26+
- **trunk**: National highways and major arterials
2727
- **primary**: Major roads connecting cities/towns
2828
- **secondary**: Important roads for regional traffic
2929
- **tertiary**: Roads connecting smaller settlements
@@ -33,7 +33,7 @@ The package preserves OpenStreetMap road classifications:
3333

3434
### Sampling Methods
3535
- **Random sampling**: Equal probability selection across all segments
36-
- **Stratified sampling**: Maintains proportional representation of road types
36+
- **Stratified sampling**: Maintains proportional representation of road types
3737
- **Filtered sampling**: Restricts sampling to specific road types
3838
- **Length-based sampling**: Target specific total coverage distances
3939

@@ -45,4 +45,4 @@ The output provides GPS coordinates and metadata for each sampled segment:
4545
- **Road metadata**: Type, name, and OpenStreetMap ID for context
4646
- **Segment ID**: Unique identifier for tracking and quality control
4747

48-
These coordinates define the geographic areas where field data collection should occur, ensuring systematic coverage of the road network.
48+
These coordinates define the geographic areas where field data collection should occur, ensuring systematic coverage of the road network.

docs/_static/custom.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ code.literal {
4848
img {
4949
max-width: 100%;
5050
height: auto;
51-
}
51+
}

docs/examples/advanced.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ for wave in range(n_waves):
7373
start_idx = wave * wave_size
7474
end_idx = start_idx + wave_size
7575
wave_indices = all_indices[start_idx:end_idx]
76-
76+
7777
# Sample from this wave's pool
78-
wave_sample = np.random.choice(wave_indices,
79-
size=samples_per_wave,
78+
wave_sample = np.random.choice(wave_indices,
79+
size=samples_per_wave,
8080
replace=False)
81-
81+
8282
wave_roads = roads.iloc[wave_sample]
8383
wave_roads.to_csv(f'wave_{wave+1}_sample.csv', index=False)
8484
```
@@ -159,14 +159,14 @@ neighborhoods = stage2_roads.groupby('district')['neighborhood'].unique()
159159
sampled_neighborhoods = []
160160
for district in sampled_districts:
161161
district_neighborhoods = neighborhoods[district]
162-
sampled = np.random.choice(district_neighborhoods,
163-
size=min(3, len(district_neighborhoods)),
162+
sampled = np.random.choice(district_neighborhoods,
163+
size=min(3, len(district_neighborhoods)),
164164
replace=False)
165165
sampled_neighborhoods.extend(sampled)
166166

167167
# Stage 3: Sample roads within neighborhoods
168168
final_roads = roads[roads['neighborhood'].isin(sampled_neighborhoods)]
169-
final_sample = final_roads.sample(n=min(500, len(final_roads)),
169+
final_sample = final_roads.sample(n=min(500, len(final_roads)),
170170
random_state=42)
171171
final_sample.to_csv('multi_stage_sample.csv', index=False)
172172
```
@@ -178,39 +178,39 @@ Always validate your samples:
178178
```python
179179
def validate_sample(sample_df, original_df):
180180
"""Validate sample representativeness"""
181-
181+
182182
print("Sample Validation Report")
183183
print("=" * 40)
184-
184+
185185
# Sample size
186186
print(f"Sample size: {len(sample_df)}")
187187
print(f"Original size: {len(original_df)}")
188188
print(f"Sampling rate: {len(sample_df)/len(original_df):.2%}")
189-
189+
190190
# Road type distribution
191191
print("\nRoad Type Distribution:")
192192
sample_dist = sample_df['road_type'].value_counts(normalize=True)
193193
original_dist = original_df['road_type'].value_counts(normalize=True)
194-
194+
195195
comparison = pd.DataFrame({
196196
'Sample': sample_dist,
197197
'Original': original_dist,
198198
'Difference': sample_dist - original_dist
199199
})
200200
print(comparison)
201-
201+
202202
# Geographic spread
203203
print("\nGeographic Coverage:")
204204
print(f"Latitude range - Sample: [{sample_df['latitude'].min():.4f}, "
205205
f"{sample_df['latitude'].max():.4f}]")
206206
print(f"Latitude range - Original: [{original_df['latitude'].min():.4f}, "
207207
f"{original_df['latitude'].max():.4f}]")
208-
208+
209209
print(f"Longitude range - Sample: [{sample_df['longitude'].min():.4f}, "
210210
f"{sample_df['longitude'].max():.4f}]")
211211
print(f"Longitude range - Original: [{original_df['longitude'].min():.4f}, "
212212
f"{original_df['longitude'].max():.4f}]")
213-
213+
214214
return comparison
215215

216216
# Run validation
@@ -225,4 +225,4 @@ validation_results = validate_sample(sample, roads)
225225
4. **Handle edge cases** - Account for missing data or small strata
226226
5. **Consider field logistics** - Account for accessibility and safety
227227
6. **Plan for non-response** - Sample extras for expected attrition
228-
7. **Archive sampling frames** - Save the full dataset used for sampling
228+
7. **Archive sampling frames** - Save the full dataset used for sampling

docs/examples/cli-usage.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ geo-sampling extract "Thailand" "Trang" \
221221

222222
geo-sampling extract "Thailand" "Phuket" \
223223
--road-types primary \
224-
--road-types secondary \
224+
--road-types secondary \
225225
--road-types tertiary \
226226
--output phuket_roads.csv
227227

@@ -264,7 +264,7 @@ Target sample size: 100
264264

265265
Sample summary:
266266
primary: 25 (25.0%)
267-
residential: 35 (35.0%)
267+
residential: 35 (35.0%)
268268
secondary: 20 (20.0%)
269269
tertiary: 15 (15.0%)
270270
unclassified: 5 (5.0%)
@@ -295,7 +295,7 @@ $(OUTPUT_DIR)/$(REGION)_roads.csv:
295295
geo-sampling extract "$(COUNTRY)" "$(REGION)" \
296296
--output $@
297297

298-
$(OUTPUT_DIR)/$(REGION)_sample.csv: $(OUTPUT_DIR)/$(REGION)_roads.csv
298+
$(OUTPUT_DIR)/$(REGION)_sample.csv: $(OUTPUT_DIR)/$(REGION)_roads.csv
299299
geo-sampling sample $< \
300300
--sample-size $(SAMPLE_SIZE) \
301301
--strategy stratified \
@@ -352,7 +352,7 @@ docker run -v $(PWD)/data:/workspace/data geo-sampling \
352352
# Main help
353353
geo-sampling --help
354354

355-
# Command-specific help
355+
# Command-specific help
356356
geo-sampling extract --help
357357
geo-sampling sample --help
358358
geo-sampling workflow --help
@@ -374,12 +374,12 @@ geo-sampling --version
374374
## Next Steps
375375

376376
- 🐍 See [Python API Examples](python-api.md) for programmatic usage
377-
- 🎯 Explore [Advanced Sampling](advanced.md) strategies
377+
- 🎯 Explore [Advanced Sampling](advanced.md) strategies
378378
- 📚 Check the [API Reference](../reference/index.md)
379379
- 📁 Download [example outputs](../../examples/outputs/)
380380

381381
## Source Code
382382

383383
Complete CLI examples are available:
384384
- [03_cli_usage.py](../../examples/03_cli_usage.py) - Demonstrates all CLI commands
385-
- [CLI output samples](../../examples/outputs/03_cli_usage/) - Real command outputs
385+
- [CLI output samples](../../examples/outputs/03_cli_usage/) - Real command outputs

docs/examples/index.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ This section provides complete, working examples that demonstrate geo-sampling c
1111
:link: python-api
1212
:link-type: doc
1313

14-
🐍 **Python API Examples**
14+
🐍 **Python API Examples**
1515
^^^
1616
Complete Python workflows with actual Delhi road data. Includes 1,220 road segments and 1,000-sample outputs.
1717

18-
**Features:** Basic extraction, sampling, visualization
19-
**Data:** Delhi, India road network
18+
**Features:** Basic extraction, sampling, visualization
19+
**Data:** Delhi, India road network
2020
**Output:** Sample plots and CSV files
2121
:::
2222

@@ -28,8 +28,8 @@ Complete Python workflows with actual Delhi road data. Includes 1,220 road segme
2828
^^^
2929
Master the geo-sampling CLI with working examples and real command outputs.
3030

31-
**Features:** All CLI commands with examples
32-
**Data:** Multiple regions and countries
31+
**Features:** All CLI commands with examples
32+
**Data:** Multiple regions and countries
3333
**Output:** Command logs and sample files
3434
:::
3535

@@ -41,8 +41,8 @@ Master the geo-sampling CLI with working examples and real command outputs.
4141
^^^
4242
Sophisticated sampling strategies with Singapore road network examples.
4343

44-
**Features:** Random, stratified, filtered sampling
45-
**Data:** Singapore Central region (470 segments)
44+
**Features:** Random, stratified, filtered sampling
45+
**Data:** Singapore Central region (470 segments)
4646
**Output:** Comparison plots and multiple samples
4747
:::
4848

@@ -55,8 +55,8 @@ Sophisticated sampling strategies with Singapore road network examples.
5555
^^^
5656
All example outputs are available for download. Browse CSV files, plots, and sample data.
5757

58-
**Includes:** Sample datasets, visualizations, CLI logs
59-
**Format:** CSV, PNG, TXT files
58+
**Includes:** Sample datasets, visualizations, CLI logs
59+
**Format:** CSV, PNG, TXT files
6060
**Size:** Ready-to-use examples
6161
:::
6262
::::
@@ -70,7 +70,7 @@ All examples use **real OpenStreetMap data** and generate **actual outputs** tha
7070
- **Output**: 1,220 total road segments → 1,000 random sample
7171
- **Files**: [`delhi_all_roads.csv`](../examples/outputs/01_basic_workflow/delhi_all_roads.csv), [`delhi_sampled_roads.csv`](../examples/outputs/01_basic_workflow/delhi_sampled_roads.csv)
7272

73-
### Singapore Advanced Sampling
73+
### Singapore Advanced Sampling
7474
- **Input**: Singapore Central region
7575
- **Output**: Multiple sampling strategies (random, stratified, filtered)
7676
- **Files**: [`singapore_*.csv`](../examples/outputs/02_advanced_sampling/) with comparison plots
@@ -85,7 +85,7 @@ All examples use **real OpenStreetMap data** and generate **actual outputs** tha
8585
Each example provides:
8686

8787
1. **🔧 Working code** - Copy-paste ready scripts
88-
2. **📈 Real outputs** - Actual CSV files and plots you can examine
88+
2. **📈 Real outputs** - Actual CSV files and plots you can examine
8989
3. **⚡ Both interfaces** - Python API and CLI equivalents
9090
4. **📋 Documentation** - Step-by-step explanations
9191

@@ -124,24 +124,24 @@ pip install -e .
124124
# Run the basic workflow example
125125
python examples/01_basic_workflow.py
126126

127-
# Try CLI examples
127+
# Try CLI examples
128128
python examples/03_cli_usage.py
129129
```
130130

131131
### Adapting for Your Research
132132

133133
1. **Change the region**: Replace country/region names with your study area
134-
2. **Adjust sample size**: Modify `sample_size` parameters for your needs
134+
2. **Adjust sample size**: Modify `sample_size` parameters for your needs
135135
3. **Filter road types**: Use `road_types` parameter to focus on specific infrastructure
136136
4. **Set random seed**: Use `seed` parameter for reproducible research
137137

138138
### Understanding Output Files
139139

140140
- **`*_all_roads.csv`**: Complete road network for the region
141-
- **`*_sample.csv`**: Random/stratified sample of road segments
141+
- **`*_sample.csv`**: Random/stratified sample of road segments
142142
- **`*_plot.png`**: Visualization of sampled road segments
143143
- **Metadata**: Each example includes sampling methodology details
144144

145145
---
146146

147-
*Ready to dive in? Start with [Python API Examples](python-api.md) or jump to [CLI Usage](cli-usage.md)!*
147+
*Ready to dive in? Start with [Python API Examples](python-api.md) or jump to [CLI Usage](cli-usage.md)!*

0 commit comments

Comments
 (0)