Skip to content

Commit 112e334

Browse files
committed
refactor the api and tests
1 parent 464284c commit 112e334

37 files changed

Lines changed: 3281 additions & 1579 deletions

allocator/__init__.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
11
"""
22
Allocator package for clustering and routing optimization.
3+
4+
Modern Pythonic API for geographic task allocation, clustering, and routing.
35
"""
46

57
import logging
68
import sys
79

10+
# Import modern API
11+
from .api import (
12+
cluster, kmeans, kahip,
13+
shortest_path, tsp_christofides, tsp_ortools, tsp_osrm, tsp_google,
14+
sort_by_distance, assign_to_closest,
15+
ClusterResult, RouteResult, SortResult, ComparisonResult
16+
)
17+
18+
# Version
19+
__version__ = "1.0.0"
20+
21+
# Export public API
22+
__all__ = [
23+
# Main functions
24+
'cluster',
25+
'shortest_path',
26+
'sort_by_distance',
27+
'assign_to_closest',
28+
29+
# Specific methods
30+
'kmeans',
31+
'kahip',
32+
'tsp_christofides',
33+
'tsp_ortools',
34+
'tsp_osrm',
35+
'tsp_google',
36+
37+
# Result types
38+
'ClusterResult',
39+
'RouteResult',
40+
'SortResult',
41+
'ComparisonResult',
42+
43+
# Utilities
44+
'setup_logging',
45+
'get_logger',
46+
]
47+
848

949
def setup_logging(level=logging.INFO):
1050
"""

allocator/algorithms.py

Lines changed: 0 additions & 194 deletions
This file was deleted.

allocator/api/__init__.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
Public API for allocator package.
3+
4+
This module provides a modern, Pythonic interface to the allocator package.
5+
"""
6+
from .cluster import cluster, kmeans, kahip
7+
from .route import shortest_path, tsp_christofides, tsp_ortools, tsp_osrm, tsp_google
8+
from .distance import sort_by_distance, assign_to_closest, distance_assignment
9+
from .types import ClusterResult, RouteResult, SortResult, ComparisonResult
10+
11+
__all__ = [
12+
# Main high-level functions
13+
'cluster',
14+
'shortest_path',
15+
'sort_by_distance',
16+
17+
# Specific clustering methods
18+
'kmeans',
19+
'kahip',
20+
21+
# Specific routing methods
22+
'tsp_christofides',
23+
'tsp_ortools',
24+
'tsp_osrm',
25+
'tsp_google',
26+
27+
# Distance assignment methods
28+
'assign_to_closest',
29+
'distance_assignment',
30+
31+
# Result types
32+
'ClusterResult',
33+
'RouteResult',
34+
'SortResult',
35+
'ComparisonResult',
36+
]

0 commit comments

Comments
 (0)