@@ -888,9 +888,11 @@ def _check_params_vs_input(self, X, default_n_init=None):
888888 self ._n_init = self .n_init
889889 if self ._n_init == "warn" :
890890 warnings .warn (
891- "The default value of `n_init` will change from "
892- f"{ default_n_init } to 'auto' in 1.4. Set the value of `n_init`"
893- " explicitly to suppress the warning" ,
891+ (
892+ "The default value of `n_init` will change from "
893+ f"{ default_n_init } to 'auto' in 1.4. Set the value of `n_init`"
894+ " explicitly to suppress the warning"
895+ ),
894896 FutureWarning ,
895897 )
896898 self ._n_init = default_n_init
@@ -902,9 +904,11 @@ def _check_params_vs_input(self, X, default_n_init=None):
902904
903905 if _is_arraylike_not_scalar (self .init ) and self ._n_init != 1 :
904906 warnings .warn (
905- "Explicit initial center position passed: performing only"
906- f" one init in { self .__class__ .__name__ } instead of "
907- f"n_init={ self ._n_init } ." ,
907+ (
908+ "Explicit initial center position passed: performing only"
909+ f" one init in { self .__class__ .__name__ } instead of "
910+ f"n_init={ self ._n_init } ."
911+ ),
908912 RuntimeWarning ,
909913 stacklevel = 2 ,
910914 )
@@ -1101,8 +1105,10 @@ def predict(self, X, sample_weight="deprecated"):
11011105 X = self ._check_test_data (X )
11021106 if not (isinstance (sample_weight , str ) and sample_weight == "deprecated" ):
11031107 warnings .warn (
1104- "'sample_weight' was deprecated in version 1.3 and "
1105- "will be removed in 1.5." ,
1108+ (
1109+ "'sample_weight' was deprecated in version 1.3 and "
1110+ "will be removed in 1.5."
1111+ ),
11061112 FutureWarning ,
11071113 )
11081114 sample_weight = _check_sample_weight (sample_weight , X , dtype = X .dtype )
@@ -1415,15 +1421,19 @@ def _check_params_vs_input(self, X):
14151421 self ._algorithm = self .algorithm
14161422 if self ._algorithm in ("auto" , "full" ):
14171423 warnings .warn (
1418- f"algorithm='{ self ._algorithm } ' is deprecated, it will be "
1419- "removed in 1.3. Using 'lloyd' instead." ,
1424+ (
1425+ f"algorithm='{ self ._algorithm } ' is deprecated, it will be "
1426+ "removed in 1.3. Using 'lloyd' instead."
1427+ ),
14201428 FutureWarning ,
14211429 )
14221430 self ._algorithm = "lloyd"
14231431 if self ._algorithm == "elkan" and self .n_clusters == 1 :
14241432 warnings .warn (
1425- "algorithm='elkan' doesn't make sense for a single "
1426- "cluster. Using 'lloyd' instead." ,
1433+ (
1434+ "algorithm='elkan' doesn't make sense for a single "
1435+ "cluster. Using 'lloyd' instead."
1436+ ),
14271437 RuntimeWarning ,
14281438 )
14291439 self ._algorithm = "lloyd"
@@ -1907,7 +1917,6 @@ def __init__(
19071917 n_init = "warn" ,
19081918 reassignment_ratio = 0.01 ,
19091919 ):
1910-
19111920 super ().__init__ (
19121921 n_clusters = n_clusters ,
19131922 init = init ,
@@ -1937,9 +1946,11 @@ def _check_params_vs_input(self, X):
19371946 self ._init_size = 3 * self .n_clusters
19381947 elif self ._init_size < self .n_clusters :
19391948 warnings .warn (
1940- f"init_size={ self ._init_size } should be larger than "
1941- f"n_clusters={ self .n_clusters } . Setting it to "
1942- "min(3*n_clusters, n_samples)" ,
1949+ (
1950+ f"init_size={ self ._init_size } should be larger than "
1951+ f"n_clusters={ self .n_clusters } . Setting it to "
1952+ "min(3*n_clusters, n_samples)"
1953+ ),
19431954 RuntimeWarning ,
19441955 stacklevel = 2 ,
19451956 )
0 commit comments