Skip to content

Commit b046caf

Browse files
author
Nathaniel Henry
committed
Break tutorial calls one argument per line past 90 characters.
1 parent 014aa63 commit b046caf

6 files changed

Lines changed: 183 additions & 58 deletions

File tree

docs/getting_started.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ A block summary, with the readable category names merged on and sorted by time:
114114

115115
```{code-cell} python
116116
walk_times = close.block_summary(geoid = "440070008001068", mode = "walk")
117-
walk_times = walk_times.merge(amenity_types[["dest_type_id", "name"]], on = "dest_type_id")
117+
walk_times = walk_times.merge(
118+
amenity_types[["dest_type_id", "name"]],
119+
on = "dest_type_id"
120+
)
118121
walk_times.sort_values("travel_time")[["name", "travel_time"]]
119122
```
120123

docs/token_use.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ when you want the etag:
3434
```python
3535
close.output = "raw"
3636
first = close.block_summary(geoid = "440070008001068", mode = "walk")
37-
again = close.block_summary(geoid = "440070008001068", mode = "walk",
38-
if_none_match = first.etag)
37+
again = close.block_summary(
38+
geoid = "440070008001068",
39+
mode = "walk",
40+
if_none_match = first.etag
41+
)
3942
again.not_modified # True, and nothing was charged
4043
```
4144

@@ -60,8 +63,12 @@ returns every reachable block with its minutes. A whole walkshed for 10 tokens,
6063
where a catchment or block query charges per block:
6164

6265
```python
63-
shed = close.isochrone(block = "440070008001068", minutes = 30, mode = "walk",
64-
format = "blocks")
66+
shed = close.isochrone(
67+
block = "440070008001068",
68+
minutes = 30,
69+
mode = "walk",
70+
format = "blocks"
71+
)
6572
```
6673

6774
## Watch what you spend
@@ -76,8 +83,12 @@ types = close.destination_types()
7683
supermarket_dest_type = types.loc[types["label"] == "grocery_stores",
7784
"dest_type_id"].iloc[0]
7885
79-
supermarkets = close.pois_search(lat = 41.823, lon = -71.412, radius_m = 1200,
80-
type = supermarket_dest_type)
86+
supermarkets = close.pois_search(
87+
lat = 41.823,
88+
lon = -71.412,
89+
radius_m = 1200,
90+
type = supermarket_dest_type
91+
)
8192
supermarkets.attrs["tokens_charged"], supermarkets.attrs["tokens_remaining"]
8293
```
8394

docs/tutorials/amenity_basket.md

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ same way (at a higher token cost).
6767

6868
```{code-cell} python
6969
blocks = close.blocks_query(
70-
center = {"lon": city["lon"], "lat": city["lat"]}, radius_m = 2500,
71-
mode = "walk", type = list(basket.values()), include_population = True)
70+
center = {"lon": city["lon"], "lat": city["lat"]},
71+
radius_m = 2500,
72+
mode = "walk",
73+
type = list(basket.values()),
74+
include_population = True
75+
)
7276
7377
one_per_block = blocks.drop_duplicates("geoid").reset_index(drop = True)
7478
total_pop = one_per_block["population"].sum()
@@ -94,8 +98,12 @@ highlighted, the city boundary behind.
9498
near_library = set(blocks.loc[(blocks.dest_type_id == basket["library"]) &
9599
(blocks.travel_time <= 15), "geoid"])
96100
one_per_block["has_library"] = one_per_block.geoid.isin(near_library)
97-
close_map(one_per_block, highlight = "has_library", color = "#058040",
98-
boundary = city_boundary)
101+
close_map(
102+
one_per_block,
103+
highlight = "has_library",
104+
color = "#058040",
105+
boundary = city_boundary
106+
)
99107
```
100108

101109
## The 15-minute-city score
@@ -127,8 +135,12 @@ basket_pop = one_per_block.loc[one_per_block.geoid.isin(covered_all),
127135
print(f"All six amenities: {100 * basket_pop / total_pop:.0f}% of residents")
128136
129137
one_per_block["full_basket"] = one_per_block.geoid.isin(covered_all)
130-
close_map(one_per_block, highlight = "full_basket", color = "#f36e21",
131-
boundary = city_boundary)
138+
close_map(
139+
one_per_block,
140+
highlight = "full_basket",
141+
color = "#f36e21",
142+
boundary = city_boundary
143+
)
132144
```
133145

134146
## Which amenity to add first
@@ -170,8 +182,10 @@ gap = np.array([" + ".join(n for n, m in zip(names, row) if m) for row in missin
170182
171183
almost = np.isin(n_missing, [1, 2])
172184
almost_pop = pops[almost].sum()
173-
print(f"{100 * almost_pop / total_pop:.0f}% of residents are one or two amenities "
174-
f"short of the full basket.\n")
185+
print(
186+
f"{100 * almost_pop / total_pop:.0f}% of residents are one or two amenities "
187+
f"short of the full basket.\n"
188+
)
175189
176190
by_gap = (pd.Series(pops[almost], index = gap[almost])
177191
.groupby(level = 0).sum().sort_values(ascending = False))
@@ -188,8 +202,14 @@ isochrone gives exactly the blocks that could reach the site on foot in 15 minut
188202

189203
```{code-cell} python
190204
site_lon, site_lat = -77.437, 37.548
191-
reachable = close.isochrone(lon = site_lon, lat = site_lat, mode = "walk",
192-
direction = "to", minutes = 15, format = "blocks")
205+
reachable = close.isochrone(
206+
lon = site_lon,
207+
lat = site_lat,
208+
mode = "walk",
209+
direction = "to",
210+
minutes = 15,
211+
format = "blocks"
212+
)
193213
194214
near_supermarket = set(blocks.loc[(blocks.dest_type_id == basket["supermarket"]) &
195215
(blocks.travel_time <= 15), "geoid"])
@@ -203,6 +223,10 @@ Map the whole city and highlight the blocks that would newly gain access.
203223

204224
```{code-cell} python
205225
one_per_block["newly_served"] = one_per_block.geoid.isin(newly_served)
206-
close_map(one_per_block, highlight = "newly_served", color = "#e8590c",
207-
boundary = city_boundary)
226+
close_map(
227+
one_per_block,
228+
highlight = "newly_served",
229+
color = "#e8590c",
230+
boundary = city_boundary
231+
)
208232
```

docs/tutorials/competitor_walksheds.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,25 @@ ours = cafes.iloc[0]
5959
print(ours["name"])
6060
cafes["is_ours"] = cafes["dest_id"] == ours["dest_id"]
6161
62-
our_shed = close.poi_catchment(dest_id = int(ours["dest_id"]), mode = "walk",
63-
max_minutes = 10)
62+
our_shed = close.poi_catchment(
63+
dest_id = int(ours["dest_id"]),
64+
mode = "walk",
65+
max_minutes = 10
66+
)
6467
walkshed = our_shed.dissolve()
6568
```
6669

6770
Draw the walkshed, with the cafes on top and our shop in orange.
6871

6972
```{code-cell} python
70-
close_map(cafes, color = ["#f36e21" if o else "#202a5b" for o in cafes["is_ours"]],
71-
label = "name", background = walkshed, background_color = "#74b9ff",
72-
boundary = city_boundary)
73+
close_map(
74+
cafes,
75+
color = ["#f36e21" if o else "#202a5b" for o in cafes["is_ours"]],
76+
label = "name",
77+
background = walkshed,
78+
background_color = "#74b9ff",
79+
boundary = city_boundary
80+
)
7381
```
7482

7583
## Who else those blocks can reach
@@ -88,8 +96,11 @@ nearest = others.nsmallest(min(15, len(others)), "dist")
8896
8997
shared = {}
9098
for _, cafe_row in nearest.iterrows():
91-
their_shed = close.poi_catchment(dest_id = int(cafe_row["dest_id"]), mode = "walk",
92-
max_minutes = 10)
99+
their_shed = close.poi_catchment(
100+
dest_id = int(cafe_row["dest_id"]),
101+
mode = "walk",
102+
max_minutes = 10
103+
)
93104
shared[cafe_row["dest_id"]] = len(our_geoids & set(their_shed["geoid"]))
94105
95106
for dest_id, n in sorted(shared.items(), key = lambda kv: -kv[1]):
@@ -114,8 +125,14 @@ def cafe_color(row):
114125
return "#f36e21"
115126
return "#e03131" if row["is_competitor"] else "#202a5b"
116127
117-
close_map(cafes, color = [cafe_color(r) for _, r in cafes.iterrows()], label = "name",
118-
background = walkshed, background_color = "#74b9ff", boundary = city_boundary)
128+
close_map(
129+
cafes,
130+
color = [cafe_color(r) for _, r in cafes.iterrows()],
131+
label = "name",
132+
background = walkshed,
133+
background_color = "#74b9ff",
134+
boundary = city_boundary
135+
)
119136
```
120137

121138
The same recipe scales up: raise the cafe count you check, or compare whole cities by

docs/tutorials/first_map.md

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ on top.
5656

5757
```{code-cell} python
5858
walk_times = close.point_summary(lat = start_lat, lon = start_lon, mode = "walk")
59-
walk_times = walk_times.merge(amenity_types[["dest_type_id", "name"]], on = "dest_type_id")
59+
walk_times = walk_times.merge(
60+
amenity_types[["dest_type_id", "name"]],
61+
on = "dest_type_id"
62+
)
6063
walk_times.sort_values("travel_time")[["name", "travel_time"]]
6164
```
6265

@@ -69,12 +72,21 @@ within `max_minutes`, each carrying its walk time — no isochrone to overlay.
6972
boundary behind it for context.
7073

7174
```{code-cell} python
72-
nearby_supermarkets = close.point_pois(lat = start_lat, lon = start_lon,
73-
mode = "walk", type = supermarket_type,
74-
max_minutes = 30)
75+
nearby_supermarkets = close.point_pois(
76+
lat = start_lat,
77+
lon = start_lon,
78+
mode = "walk",
79+
type = supermarket_type,
80+
max_minutes = 30
81+
)
7582
7683
city_boundary = close.place_boundary(geoid = providence_ri["geoid"])
77-
close_map(nearby_supermarkets, color = "#e8590c", boundary = city_boundary, label = "name")
84+
close_map(
85+
nearby_supermarkets,
86+
color = "#e8590c",
87+
boundary = city_boundary,
88+
label = "name"
89+
)
7890
```
7991

8092
## Draw how far you can walk
@@ -84,8 +96,14 @@ minutes. Shade it by the `contour` minutes; blue marks the nearest, most-reachab
8496
ring.
8597

8698
```{code-cell} python
87-
rings = close.isochrone(lon = start_lon, lat = start_lat, mode = "walk",
88-
direction = "from", contours = [10, 20, 30], format = "geojson")
99+
rings = close.isochrone(
100+
lon = start_lon,
101+
lat = start_lat,
102+
mode = "walk",
103+
direction = "from",
104+
contours = [10, 20, 30],
105+
format = "geojson"
106+
)
89107
close_map(rings, fill = "contour", reverse = True)
90108
```
91109

@@ -95,10 +113,22 @@ The same starting point and the same 30-minute budget, on foot and by bus — th
95113
clearest way to see what transit buys you.
96114

97115
```{code-cell} python
98-
walk = close.isochrone(lon = start_lon, lat = start_lat, mode = "walk",
99-
direction = "from", minutes = 30, format = "geojson")
100-
transit = close.isochrone(lon = start_lon, lat = start_lat, mode = "transit",
101-
direction = "from", minutes = 30, format = "geojson")
116+
walk = close.isochrone(
117+
lon = start_lon,
118+
lat = start_lat,
119+
mode = "walk",
120+
direction = "from",
121+
minutes = 30,
122+
format = "geojson"
123+
)
124+
transit = close.isochrone(
125+
lon = start_lon,
126+
lat = start_lat,
127+
mode = "transit",
128+
direction = "from",
129+
minutes = 30,
130+
format = "geojson"
131+
)
102132
103133
close_map(walk, color = "#058040")
104134
```

0 commit comments

Comments
 (0)