Skip to content

Commit 12abd86

Browse files
author
Ben Lawson
committed
clean up formatting of checking the results and change make random np.nan assignment without replacement
1 parent 7d233f8 commit 12abd86

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

sklearn/utils/estimator_checks.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ def check_estimators_pickle(name, estimator_orig):
11931193
if name in ALLOW_NAN:
11941194
# set random 10 elements to be np.nan
11951195
rng = np.random.RandomState(42)
1196-
mask = rng.choice(X.size, 10, replace=True)
1196+
mask = rng.choice(X.size, 10, replace=False)
11971197
X.reshape(-1)[mask] = np.nan
11981198
estimator.fit(X, y)
11991199

@@ -1209,12 +1209,11 @@ def check_estimators_pickle(name, estimator_orig):
12091209
for method in nan_result:
12101210
unpickled_nan_result = getattr(unpickled_estimator, method)(X)
12111211
if name == 'ChainedImputer':
1212-
assert_allclose_dense_sparse(nan_result[method],
1213-
unpickled_nan_result,
1214-
rtol=1e-5, atol=0.1)
1212+
tol = {'rtol': 1e-5, 'atol': 0.1}
12151213
else:
1214+
tol = {}
12161215
assert_allclose_dense_sparse(nan_result[method],
1217-
unpickled_nan_result)
1216+
unpickled_nan_result, **tol)
12181217

12191218

12201219
@ignore_warnings(category=(DeprecationWarning, FutureWarning))

0 commit comments

Comments
 (0)