From c5eae2c37ccc4917a07fb33c1d8bf1ade88d87e9 Mon Sep 17 00:00:00 2001 From: Serge Rey Date: Fri, 4 Feb 2022 14:06:19 -0800 Subject: [PATCH 1/3] docs: instance has attributes not returns --- spopt/region/maxp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spopt/region/maxp.py b/spopt/region/maxp.py index 7e9d7432..f2ce9574 100644 --- a/spopt/region/maxp.py +++ b/spopt/region/maxp.py @@ -727,8 +727,8 @@ class MaxPHeuristic(BaseSpOptHeuristicSolver): Set to ``True`` for reporting solution progress/debugging. Default is ``False``. - Returns - ------- + Attributes + ---------- max_p : int The number of regions. From 3dc23ec58014f45ababa8d723719bb12e18c3503 Mon Sep 17 00:00:00 2001 From: Serge Rey Date: Fri, 4 Feb 2022 14:19:04 -0800 Subject: [PATCH 2/3] docs: add author info and update k-means --- spopt/region/maxp.py | 3 +++ spopt/region/region_k_means.py | 30 +++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/spopt/region/maxp.py b/spopt/region/maxp.py index f2ce9574..ffb66b8f 100644 --- a/spopt/region/maxp.py +++ b/spopt/region/maxp.py @@ -6,6 +6,9 @@ Journal of Geographical Information Science. Accepted 2020-04-12. """ +__author__ = ["Ran Wei", "Serge Rey", "Elijah Knaap"] +__email__ = "sjsrey@gmail.com" + from ..BaseClass import BaseSpOptHeuristicSolver from .base import ( w_to_g, diff --git a/spopt/region/region_k_means.py b/spopt/region/region_k_means.py index 6d8c0db5..973c4bc6 100644 --- a/spopt/region/region_k_means.py +++ b/spopt/region/region_k_means.py @@ -1,3 +1,14 @@ +""" +Region k-means + + +K-means with the constraint that all clusters form a spatially connected component. +""" + +__author__ = "Serge Rey" +__email__ = "sjsrey@gmail.com" + + from collections import defaultdict import numpy from ..BaseClass import BaseSpOptHeuristicSolver @@ -14,7 +25,7 @@ def region_k_means(X, n_clusters, w): - """Solve the region-K-means problem, the K-means with the constraint + """Solve the region-K-means problem with the constraint that each cluster forms a spatially connected component. Parameters @@ -119,7 +130,7 @@ def region_k_means(X, n_clusters, w): class RegionKMeansHeuristic(BaseSpOptHeuristicSolver): - """Solve the region-K-means problem, the K-means with the constraint + """Solve the region-K-means problem with the constraint that each cluster forms a spatially connected component. @@ -138,14 +149,15 @@ class RegionKMeansHeuristic(BaseSpOptHeuristicSolver): Attributes ---------- - labels_ : - ... - - centroids_ : - ... + labels_ : numpy.array + Region IDs for observations - iters_ : - ... + centroids_ : numpy.ndarray + Floating point array of centroids in the shape of ``(k, n_features)`` + found at the last iteration of ``region_k_means``. + + iters : int + The number of iterations for the reassignment phase. """ From 0b289ba1e8465f6b0fdfac984973a951128547b8 Mon Sep 17 00:00:00 2001 From: Serge Rey Date: Fri, 4 Feb 2022 14:28:57 -0800 Subject: [PATCH 3/3] docs: localize azp docstrings --- spopt/region/azp_util.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spopt/region/azp_util.py b/spopt/region/azp_util.py index 4213058c..05ab7df2 100755 --- a/spopt/region/azp_util.py +++ b/spopt/region/azp_util.py @@ -153,11 +153,9 @@ def __init__(self, spatially_extensive_attr, threshold, decorated_strategy): Parameters ---------- spatially_extensive_attr : numpy.ndarray - See corresponding argument in - ``region.max_p_regions.heuristics.MaxPRegionsHeu.fit_from_scipy_sparse_matrix``. + Values that will serve as domain for the threshold constraint threshold : numbers.Real or numpy.ndarray - See corresponding argument in - ``region.max_p_regions.heuristics.MaxPRegionsHeu.fit_from_scipy_sparse_matrix`` + Value for the threshold constraint decorated_strategy : AllowMoveStrategy The ``AllowMoveStrategy`` related to the algorithms local search. """