Skip to content

Commit

Permalink
UPD: update tests control risks
Browse files Browse the repository at this point in the history
  • Loading branch information
SZiane committed Jul 12, 2023
1 parent b3a232e commit 8a1d21d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
7 changes: 2 additions & 5 deletions mapie/tests/test_control_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@

random_state = 42
prng = np.random.RandomState(random_state)
y_1 = prng.random(51)
y_2 = prng.random((51, 5))
y_3 = prng.randint(0, 2, 51)


def test_compute_recall_equal() -> None:
Expand All @@ -86,14 +83,14 @@ def test_compute_precision() -> None:
def test_recall_with_zero_sum_is_equal_nan() -> None:
"""Test compute_recall with nan values"""
y_toy = np.zeros((4, 3))
y_preds_proba = np.random.rand(4, 3, 1)
y_preds_proba = prng.rand(4, 3, 1)
recall = compute_risk_recall(lambdas, y_preds_proba, y_toy)
np.testing.assert_array_equal(recall, np.empty_like(recall))


def test_precision_with_zero_sum_is_equal_ones() -> None:
"""Test compute_precision with nan values"""
y_toy = np.random.rand(4, 3)
y_toy = prng.rand(4, 3)
y_preds_proba = np.zeros((4, 3, 1))
precision = compute_risk_precision(lambdas, y_preds_proba, y_toy)
np.testing.assert_array_equal(precision, np.ones_like(precision))
Expand Down
6 changes: 1 addition & 5 deletions mapie/tests/test_multi_label_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ def test_array_output_model(strategy: str, alpha: Any, delta: Any, bound: Any):
metric_control=args["metric_control"],
random_state=random_state
)

mapie_clf.fit(X_toy, y_toy)
mapie_clf.predict(
X_toy,
Expand Down Expand Up @@ -705,8 +704,6 @@ def test_error_no_fit() -> None:
def test_error_estimator_none_partial() -> None:
"""Test error estimator none partial"""
mapie_clf = MapieMultiLabelClassifier(random_state=random_state)


with pytest.raises(
ValueError,
match=r".*Invalid estimator with partial_fit*"
Expand Down Expand Up @@ -739,8 +736,7 @@ def test_toy_dataset_predictions(strategy: str) -> None:
clf,
method=args["method"],
metric_control=args["metric_control"],
random_state=random_state

random_state=random_state
)
mapie_clf.fit(X_toy, y_toy)
_, y_ps = mapie_clf.predict(
Expand Down

0 comments on commit 8a1d21d

Please sign in to comment.