Skip to content

Commit bfb0f8f

Browse files
author
William de Vazelhes
committed
TST: give an example for sdml_supervised with skggm where it indeed fails
1 parent 169dccf commit bfb0f8f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/metric_learn_test.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,17 @@ def test_sdml_supervised_raises_warning_msg_installed_skggm(self):
230230
# TODO: remove if we don't need skggm anymore
231231
# case on which we know that skggm's graphical lasso fails
232232
# because it will return non finite values
233-
X, y = load_iris(return_X_y=True)
234-
sdml_supervised = SDML_Supervised(balance_param=0.5, use_cov=True,
233+
rng = np.random.RandomState(42)
234+
# This example will create a diagonal em_cov with a negative coeff (
235+
# pathological case)
236+
X = np.array([[-10., 0.], [10., 0.], [5., 0.], [3., 0.]])
237+
y = [0, 0, 1, 1]
238+
sdml_supervised = SDML_Supervised(balance_param=0.5, use_cov=False,
235239
sparsity_param=0.01)
236240
msg = ("There was a problem in SDML when using skggm's graphical "
237241
"lasso solver.")
238242
with pytest.raises(RuntimeError) as raised_error:
239-
sdml_supervised.fit(X, y)
243+
sdml_supervised.fit(X, y, random_state=rng)
240244
assert msg == str(raised_error.value)
241245

242246
@pytest.mark.skipif(not HAS_SKGGM,

0 commit comments

Comments
 (0)