66from .base_metric import _PairsClassifierMixin , MahalanobisMixin
77from .constraints import Constraints , wrap_pairs
88from ._util import components_from_metric , _initialize_metric_mahalanobis
9+ import warnings
910
1011
1112class _BaseMMC (MahalanobisMixin ):
@@ -518,6 +519,8 @@ class MMC_Supervised(_BaseMMC, TransformerMixin):
518519 Mahalanobis matrix. In any case, `random_state` is also used to
519520 randomly sample constraints from labels.
520521
522+ num_constraints : Renamed to n_constraints. Will be deprecated in 0.7.0
523+
521524 Examples
522525 --------
523526 >>> from metric_learn import MMC_Supervised
@@ -541,13 +544,23 @@ class MMC_Supervised(_BaseMMC, TransformerMixin):
541544 def __init__ (self , max_iter = 100 , max_proj = 10000 , tol = 1e-6 ,
542545 n_constraints = None , init = 'identity' ,
543546 diagonal = False , diagonal_c = 1.0 , verbose = False ,
544- preprocessor = None , random_state = None ):
547+ preprocessor = None , random_state = None ,
548+ num_constraints = 'deprecated' ):
545549 _BaseMMC .__init__ (self , max_iter = max_iter , max_proj = max_proj ,
546550 tol = tol ,
547551 init = init , diagonal = diagonal ,
548552 diagonal_c = diagonal_c , verbose = verbose ,
549553 preprocessor = preprocessor , random_state = random_state )
550- self .n_constraints = n_constraints
554+ if num_constraints != 'deprecated' :
555+ warnings .warn ('"num_constraints" parameter has been renamed to'
556+ ' "n_constraints". It has been deprecated in'
557+ ' version 0.6.3 and will be removed in 0.7.0'
558+ '' , FutureWarning )
559+ self .n_constraints = num_constraints
560+ else :
561+ self .n_constraints = n_constraints
562+ # Avoid test get_params from failing (all params passed sholud be set)
563+ self .num_constraints = 'deprecated'
551564
552565 def fit (self , X , y ):
553566 """Create constraints from labels and learn the MMC model.
0 commit comments