Skip to content

Commit 64cfd58

Browse files
committed
Ensure clean flake8, pytest, and linter outputs.
1 parent 83746a8 commit 64cfd58

13 files changed

Lines changed: 37 additions & 26 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ disable = [
4949
"C0114", # missing-module-docstring
5050
"C0115", # missing-class-docstring
5151
"C0116", # missing-function-docstring
52+
"R0801", # duplicate-code: false positive on short idiomatic patterns
5253
"R0902", # too-many-instance-attributes: legitimate for model state classes
5354
"R0913", # too-many-arguments: common in data science APIs
5455
"R0914", # too-many-locals: acceptable in complex data processing functions

scripts/build_taxonomy.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ def build_rows(radii, osm, overture):
8989
.fillna("")
9090
)
9191
df = df.iloc[
92-
sorted(range(len(df)), key = lambda i: (df.index[i].startswith("Other "), df.index[i]))
92+
sorted(
93+
range(len(df)),
94+
key = lambda i: (df.index[i].startswith("Other "), df.index[i]),
95+
)
9396
]
9497
rows = []
9598
for label, row in df.iterrows():
@@ -302,7 +305,8 @@ def render(rows):
302305
</main>
303306
304307
<footer>
305-
OpenPOIs &mdash; by <a href="https://henryspatialanalysis.com/">Henry Spatial Analysis</a>
308+
OpenPOIs &mdash;
309+
by <a href="https://henryspatialanalysis.com/">Henry Spatial Analysis</a>
306310
&mdash; <a href="https://github.com/henryspatialanalysis/openpois">GitHub</a>
307311
&mdash; MIT License
308312
</footer>

scripts/check_taxonomy_sync.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ def parse_js_object_keys(text, name):
5555
)
5656
if not match:
5757
raise ValueError(f"Could not find `const {name}` in JS source")
58-
return set(re.findall(r"^\s*([A-Za-z_][A-Za-z0-9_]*)\s*:", match.group(1), flags = re.MULTILINE))
58+
return set(re.findall(
59+
r"^\s*([A-Za-z_][A-Za-z0-9_]*)\s*:",
60+
match.group(1),
61+
flags = re.MULTILINE,
62+
))
5963

6064

6165
def report_diff(name, csv_set, js_set):

scripts/conflation/conflate.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@
5555
find_spatial_candidates,
5656
select_best_matches,
5757
)
58-
59-
CHECKPOINT_SUBDIR = "chunk_matches"
60-
DEDUP_CHECKPOINT_SUBDIR = "chunk_selfdedup"
61-
DEDUP_DROPPED_FILE = "overture_dedup_dropped.parquet"
62-
DEDUP_POST_FILTER_FILE = "overture_post_dedup.parquet"
6358
from openpois.conflation.merge import (
6459
build_merge_parts,
6560
build_merge_parts_chunked,
@@ -76,6 +71,11 @@
7671
load_top_level_matches,
7772
)
7873

74+
CHECKPOINT_SUBDIR = "chunk_matches"
75+
DEDUP_CHECKPOINT_SUBDIR = "chunk_selfdedup"
76+
DEDUP_DROPPED_FILE = "overture_dedup_dropped.parquet"
77+
DEDUP_POST_FILTER_FILE = "overture_post_dedup.parquet"
78+
7979

8080
# -----------------------------------------------------------------
8181
# Memory instrumentation

scripts/exploratory/test_jax.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,16 @@ def log_posterior(params, data):
5252
lp = 0.0
5353
lp += jnp.sum(stats.norm.logpdf(params['alpha'], loc = 0.0, scale = 5.0))
5454
lp += jnp.sum(stats.norm.logpdf(params['beta'], loc = 0.0, scale = 2.5))
55-
lp += jnp.sum(stats.norm.logpdf(params['log_sigma'], loc = jnp.log(0.2), scale = 0.25))
55+
lp += jnp.sum(stats.norm.logpdf(
56+
params['log_sigma'], loc = jnp.log(0.2), scale = 0.25
57+
))
5658
mu = params['alpha'] + data['x'] @ params['beta']
57-
lp += jnp.sum(stats.norm.logpdf(data['y'], loc = mu, scale = jnp.exp(params['log_sigma'])))
59+
lp += jnp.sum(stats.norm.logpdf(
60+
data['y'], loc = mu, scale = jnp.exp(params['log_sigma'])
61+
))
5862
return lp
5963

64+
6065
def predict(key, params, data, add_sigma: bool = True):
6166
mu = params['alpha'] + data['x'] @ params['beta']
6267
if add_sigma:

scripts/osm_data/data_viz.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
directories.osm_data — directory containing input parquet and viz/ output
1616
osm_data.tag_key — tag key whose changes define observation
1717
events (used only in plot titles)
18-
osm_data.timestamp_cols — columns to parse as timestamps (rows with nulls dropped)
18+
osm_data.timestamp_cols — columns to parse as timestamps (rows with
19+
nulls dropped)
1920
osm_data.top_n_types — number of top shared labels in the multi-panel figure
2021
download.osm.end_date — right-censoring date for still-unchanged tags
2122
osm_data.apply_model.model_stub — stub for loading model predictions
@@ -101,6 +102,7 @@ def fig_save(
101102
**kwargs
102103
)
103104

105+
104106
def get_preds_dict(model_stub: str | None) -> dict[str, pd.DataFrame]:
105107
"""Load constant and shared-label model predictions."""
106108
if model_stub is None:

src/openpois/conflation/merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ def save_conflated_from_parts(
716716
p.unlink()
717717
part_paths[0].parent.rmdir()
718718

719-
print(f" Done.")
719+
print(" Done.")
720720
return n
721721

722722

src/openpois/models/jax_core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ def nuts_sample_multichain(
249249
verbose = verbose,
250250
)
251251
# Add a leading singleton chain axis so downstream code is shape-uniform.
252-
add_axis = lambda x: jnp.expand_dims(x, axis = 0)
252+
253+
def add_axis(x):
254+
return jnp.expand_dims(x, axis = 0)
255+
253256
return (
254257
jax.tree_util.tree_map(add_axis, draws),
255258
jax.tree_util.tree_map(add_axis, info),

tests/test_dedup_overture.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import geopandas as gpd
55
import numpy as np
66
import pandas as pd
7-
import pytest
87
from shapely.geometry import Point
98

109
from openpois.conflation.dedup_overture import (
@@ -141,7 +140,6 @@ def test_two_near_duplicates_make_one_pair(self):
141140
# Two POIs ~11 m apart with identical name + taxonomy →
142141
# strong match, emitted once.
143142
coords = [(-122.335, 47.608), (-122.335, 47.6081)]
144-
n = 2
145143
shared_labels = np.array(["bank", "bank"], dtype = object)
146144
l0_bits = np.array([1, 1], dtype = np.uint16)
147145
names = np.array(["US Bank", "US Bank"], dtype = object)
@@ -175,12 +173,10 @@ def test_two_near_duplicates_make_one_pair(self):
175173

176174
def test_far_points_no_pair(self):
177175
# Two POIs ~1 km apart → beyond 100 m max_radius.
178-
coords = [(-122.335, 47.608), (-122.335, 47.618)]
179176
centroids = np.array(
180177
[[-122.335, 47.608], [-122.335, 47.618]],
181178
dtype = np.float64,
182179
)
183-
n = 2
184180
pairs, _ = find_self_matches_chunked(
185181
centroids_lonlat = centroids,
186182
radii_m = np.array([100.0, 100.0], dtype = np.float32),

tests/test_format_observations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ def test_keep_key_stickiness(self, tmp_path):
208208
amenities = list(out["amenity"].fillna(""))
209209
lasts = list(out["amenity_last_value"].fillna(""))
210210
assert amenities == ["restaurant", "restaurant", "bar"]
211-
# v1: pre-change was None; v2: no change → last stays empty; v3: last = "restaurant".
211+
# v1: pre-change was None; v2: no change → last stays empty;
212+
# v3: last = "restaurant".
212213
assert lasts == ["", "", "restaurant"]
213214

214215
def test_left_join_null_inheritance(self, tmp_path):

0 commit comments

Comments
 (0)