Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 19, 2024
1 parent 2bc4d81 commit a83d6e4
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pycrostates/cluster/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from numpy.typing import NDArray

from .._typing import CHData, Picks, RANDomState
from ..utils import _correlation, _gev
from ..utils import _gev
from ..utils._checks import _check_n_jobs, _check_random_state, _check_type
from ..utils._docs import copy_doc, fill_doc
from ..utils._logs import logger
Expand Down Expand Up @@ -185,7 +185,12 @@ def fit(
count_converged = 0
for init in inits:
gev, maps, segmentation, converged = ModKMeans._kmeans(
data, self._n_clusters, self._ignore_polarity, self._max_iter, init, self._tol
data,
self._n_clusters,
self._ignore_polarity,
self._max_iter,
init,
self._tol,
)
if not converged:
continue
Expand All @@ -201,7 +206,14 @@ def fit(
ModKMeans._kmeans, n_jobs, total=self._n_init
)
runs = parallel(
p_fun(data, self._n_clusters, self._ignore_polarity, self._max_iter, init, self._tol)
p_fun(
data,
self._n_clusters,
self._ignore_polarity,
self._max_iter,
init,
self._tol,
)
for init in inits
)
try:
Expand Down Expand Up @@ -264,10 +276,9 @@ def _kmeans(
max_iter: int,
random_state: Union[RandomState, Generator],
tol: Union[int, float],

) -> tuple[float, NDArray[float], NDArray[int], bool]:
"""Run the k-means algorithm."""
maps, segmentation, converged = ModKMeans._compute_maps(
maps, segmentation, converged = ModKMeans._compute_maps(
data, n_clusters, ignore_polarity, max_iter, random_state, tol
)
gev = _gev(data, maps, segmentation)
Expand Down Expand Up @@ -343,7 +354,6 @@ def _compute_maps(

return maps, segmentation, converged


# --------------------------------------------------------------------
@property
def n_init(self) -> int: # noqa: D401
Expand Down

0 comments on commit a83d6e4

Please sign in to comment.