Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c3f647a

Browse filesBrowse files
authored
MNT Fix divide by zero error thrown by _random_choice_csc during a test run (#19383)
1 parent 86bc6c9 commit c3f647a
Copy full SHA for c3f647a

File tree

Expand file treeCollapse file tree

1 file changed

+7
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-7
lines changed

‎sklearn/utils/tests/test_random.py

Copy file name to clipboardExpand all lines: sklearn/utils/tests/test_random.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_random_choice_csc(n_samples=10000, random_state=24):
109109
class_probabilities = [np.array([0.5, 0.5]), np.array([0.6, 0.1, 0.3])]
110110

111111
got = _random_choice_csc(n_samples, classes, class_probabilities,
112-
random_state)
112+
random_state)
113113
assert sp.issparse(got)
114114

115115
for k in range(len(classes)):
@@ -121,8 +121,8 @@ def test_random_choice_csc(n_samples=10000, random_state=24):
121121
class_probabilities = [np.array([0.5, 0.5]), np.array([0, 1/2, 1/2])]
122122

123123
got = _random_choice_csc(n_samples=n_samples,
124-
classes=classes,
125-
random_state=random_state)
124+
classes=classes,
125+
random_state=random_state)
126126
assert sp.issparse(got)
127127

128128
for k in range(len(classes)):
@@ -131,10 +131,10 @@ def test_random_choice_csc(n_samples=10000, random_state=24):
131131

132132
# Edge case probabilities 1.0 and 0.0
133133
classes = [np.array([0, 1]), np.array([0, 1, 2])]
134-
class_probabilities = [np.array([1.0, 0.0]), np.array([0.0, 1.0, 0.0])]
134+
class_probabilities = [np.array([0.0, 1.0]), np.array([0.0, 1.0, 0.0])]
135135

136136
got = _random_choice_csc(n_samples, classes, class_probabilities,
137-
random_state)
137+
random_state)
138138
assert sp.issparse(got)
139139

140140
for k in range(len(classes)):
@@ -147,8 +147,8 @@ def test_random_choice_csc(n_samples=10000, random_state=24):
147147
class_probabilities = [np.array([0.0, 1.0]), np.array([1.0])]
148148

149149
got = _random_choice_csc(n_samples=n_samples,
150-
classes=classes,
151-
random_state=random_state)
150+
classes=classes,
151+
random_state=random_state)
152152
assert sp.issparse(got)
153153

154154
for k in range(len(classes)):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.