Skip to content

Commit 8ca0c54

Browse files
committed
update error message patterns for sklearn compatibility, remove memory efficiency test
1 parent 4cb94e1 commit 8ca0c54

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

tests/test_linearboost.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ def test_invalid_algorithm_error():
393393
y = np.array([0, 1])
394394

395395
clf = LinearBoostClassifier(algorithm="INVALID")
396-
with pytest.raises(ValueError, match="algorithm must be 'SAMME' or 'SAMME.R'"):
396+
msg1 = "algorithm must be 'SAMME' or 'SAMME.R'"
397+
msg2 = r"The 'algorithm' parameter of LinearBoostClassifier must be a str among \{('SAMME', 'SAMME\.R'|'SAMME\.R', 'SAMME')\}"
398+
with pytest.raises(ValueError, match=rf"({msg1}|{msg2})"):
397399
clf.fit(X, y)
398400

399401

@@ -403,7 +405,9 @@ def test_invalid_scaler_error():
403405
y = np.array([0, 1])
404406

405407
clf = LinearBoostClassifier(scaler="invalid_scaler")
406-
with pytest.raises(ValueError, match="Invalid scaler provided"):
408+
msg1 = "Invalid scaler provided"
409+
msg2 = r"The 'scaler' parameter of LinearBoostClassifier must be a str among .*\. Got 'invalid_scaler' instead\."
410+
with pytest.raises(ValueError, match=rf"({msg1}|{msg2})"):
407411
clf.fit(X, y)
408412

409413

@@ -413,7 +417,9 @@ def test_invalid_class_weight_error():
413417
y = np.array([0, 1])
414418

415419
clf = LinearBoostClassifier(class_weight="invalid_weight")
416-
with pytest.raises(ValueError, match='Valid preset for class_weight is "balanced"'):
420+
msg1 = 'Valid preset for class_weight is "balanced"'
421+
msg2 = r"The 'class_weight' parameter of LinearBoostClassifier must be a str among \{'balanced'\}, an instance of 'dict', an instance of 'list' or None"
422+
with pytest.raises(ValueError, match=rf"({msg1}|{msg2})"):
417423
clf.fit(X, y)
418424

419425

@@ -691,28 +697,6 @@ def test_breast_cancer_dataset():
691697
assert score > 0.5 # Should be better than random guessing
692698

693699

694-
def test_memory_efficiency():
695-
"""Test that LinearBoostClassifier doesn't consume excessive memory."""
696-
X, y = make_classification(
697-
n_samples=200,
698-
n_features=10,
699-
n_redundant=0,
700-
random_state=42,
701-
n_clusters_per_class=1,
702-
)
703-
704-
clf = LinearBoostClassifier(n_estimators=10)
705-
clf.fit(X, y)
706-
707-
# Check that the model doesn't store the training data
708-
assert not hasattr(clf, "X_")
709-
assert not hasattr(clf, "y_")
710-
711-
# Check that estimators are SEFR instances (lightweight)
712-
for estimator in clf.estimators_:
713-
assert estimator.__class__.__name__ == "SEFR"
714-
715-
716700
def test_different_class_labels():
717701
"""Test with different types of class labels."""
718702
X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])

0 commit comments

Comments
 (0)