Skip to content

Commit fa74609

Browse files
author
mvargas33
committed
Warnings for n_constrains
1 parent b9c0974 commit fa74609

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

metric_learn/constraints.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import warnings
77
from sklearn.utils import check_random_state
88
from sklearn.neighbors import NearestNeighbors
9+
import warnings
910

1011
__all__ = ['Constraints']
1112

@@ -32,7 +33,7 @@ def __init__(self, partial_labels):
3233
self.partial_labels = partial_labels
3334

3435
def positive_negative_pairs(self, n_constraints, same_length=False,
35-
random_state=None):
36+
random_state=None, num_constraints='deprecated'):
3637
"""
3738
Generates positive pairs and negative pairs from labeled data.
3839
@@ -55,6 +56,8 @@ def positive_negative_pairs(self, n_constraints, same_length=False,
5556
random_state : int or numpy.RandomState or None, optional (default=None)
5657
A pseudo random number generator object or a seed for it if int.
5758
59+
num_constraints : Renamed to n_constrains. Will be deprecated 0.7.0
60+
5861
Returns
5962
-------
6063
a : array-like, shape=(n_constraints,)
@@ -69,6 +72,12 @@ def positive_negative_pairs(self, n_constraints, same_length=False,
6972
d : array-like, shape=(n_constraints,)
7073
1D array of indicators for the right elements of negative pairs.
7174
"""
75+
if self.num_constraints != 'deprecated':
76+
warnings.warn('"num_constraints" parameter has been renamed to '
77+
'"n_constraints". It has been deprecated in'
78+
' version 0.6.3 and will be removed in 0.7.0'
79+
'', FutureWarning)
80+
self.n_constraints = num_constraints
7281
random_state = check_random_state(random_state)
7382
a, b = self._pairs(n_constraints, same_label=True,
7483
random_state=random_state)

0 commit comments

Comments
 (0)