Format and lint
This commit is contained in:
parent
42ee2d4c51
commit
04a78e7bfe
75 changed files with 1290 additions and 719 deletions
|
|
@ -4,7 +4,12 @@ from pathlib import Path
|
|||
from shapely.geometry import MultiPolygon, Polygon
|
||||
from tqdm import tqdm
|
||||
|
||||
from .inspire import cache_inspire, get_inspire_candidates, inspire_cache_exists, load_inspire
|
||||
from .inspire import (
|
||||
cache_inspire,
|
||||
get_inspire_candidates,
|
||||
inspire_cache_exists,
|
||||
load_inspire,
|
||||
)
|
||||
from .memory import release_memory
|
||||
from .oa_boundaries import load_oa_boundaries
|
||||
from .output import merge_fragments, write_district_geojson
|
||||
|
|
|
|||
|
|
@ -128,6 +128,10 @@ def _extract_polygonal(geom) -> Polygon | MultiPolygon | None:
|
|||
if len(polys) == 1:
|
||||
return polys[0]
|
||||
return MultiPolygon(
|
||||
[p for g in polys for p in (g.geoms if g.geom_type == "MultiPolygon" else [g])]
|
||||
[
|
||||
p
|
||||
for g in polys
|
||||
for p in (g.geoms if g.geom_type == "MultiPolygon" else [g])
|
||||
]
|
||||
)
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -167,9 +167,7 @@ class TestVoronoiDeduplication:
|
|||
|
||||
def test_int64_coords_jitter_works(self, square_boundary):
|
||||
"""Int64 coords (production dtype) must still jitter correctly."""
|
||||
points = np.array(
|
||||
[[500050, 180050], [500050, 180050]], dtype=np.int64
|
||||
)
|
||||
points = np.array([[500050, 180050], [500050, 180050]], dtype=np.int64)
|
||||
postcodes = ["A", "B"]
|
||||
result = compute_voronoi_regions(points, postcodes, square_boundary)
|
||||
assert "A" in result, "Postcode A missing with int64 coords"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ def compute_voronoi_regions(
|
|||
else:
|
||||
# Tiny jitter so Voronoi sees distinct points (0.01m per step)
|
||||
jittered = points[i].copy()
|
||||
angle = 2 * np.pi * jitter_idx / max(coord_counts[coord], jitter_idx + 1)
|
||||
angle = (
|
||||
2 * np.pi * jitter_idx / max(coord_counts[coord], jitter_idx + 1)
|
||||
)
|
||||
jittered[0] += 0.01 * np.cos(angle)
|
||||
jittered[1] += 0.01 * np.sin(angle)
|
||||
unique_pts.append(jittered)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue