mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Review feedback (#1481): the address batcher and the Modelling Run batcher implemented the same greedy packing; the core moves to utilities/grouped_batching.py and both become thin wrappers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
17 lines
536 B
Python
17 lines
536 B
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Iterable, Iterator
|
|
|
|
from domain.addresses.unstandardised_address import AddressList, UnstandardisedAddress
|
|
from utilities.grouped_batching import iter_grouped_batches
|
|
|
|
|
|
def iter_postcode_grouped_batches(
|
|
addresses: Iterable[UnstandardisedAddress],
|
|
*,
|
|
max_batch_size: int = 500,
|
|
) -> Iterator[AddressList]:
|
|
for batch in iter_grouped_batches(
|
|
addresses, key=lambda a: a.postcode, max_batch_size=max_batch_size
|
|
):
|
|
yield AddressList(batch)
|