Skip to content

Commit 94c0473

Browse files
author
Florian Gardin
committed
add test on value error for new argument
1 parent 683101d commit 94c0473

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

skrules/skope_rules.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ def fit(self, X, y, sample_weight=None):
205205
" in the data, but the data contains only one"
206206
" class: %r" % self.classes_[0])
207207

208+
if not isinstance(self.max_depth_duplication, int) and self.max_depth_duplication is not None:
209+
raise ValueError("max_depth_duplication should be an integer"
210+
)
208211
if not set(self.classes_) == set([0, 1]):
209212
warn("Found labels %s. This method assumes target class to be"
210213
" labeled as 1 and normal data to be labeled as 0. Any label"

skrules/tests/test_skope_rules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_skope_rules_error():
9393
assert_no_warnings(SkopeRules(max_samples=np.int64(2)).fit, X, y)
9494
assert_raises(ValueError, SkopeRules(max_samples='foobar').fit, X, y)
9595
assert_raises(ValueError, SkopeRules(max_samples=1.5).fit, X, y)
96+
assert_raises(ValueError, SkopeRules(max_depth_duplication=1.5).fit, X, y)
9697
assert_raises(ValueError, SkopeRules().fit(X, y).predict, X[:, 1:])
9798
assert_raises(ValueError, SkopeRules().fit(X, y).decision_function,
9899
X[:, 1:])

0 commit comments

Comments
 (0)