Skip to content

Commit b4e41cb

Browse files
jnothmanlarsmans
authored andcommitted
FIX update sklearn.__all__ to include all end-user submodules
1 parent 020e0af commit b4e41cb

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

sklearn/__init__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@
3636
else:
3737
from . import __check_build
3838
from .base import clone
39+
__check_build # avoid flakes unused variable error
3940

40-
__all__ = ['cross_validation', 'cluster', 'covariance',
41-
'datasets', 'decomposition', 'feature_extraction',
42-
'feature_selection', 'semi_supervised',
43-
'gaussian_process', 'grid_search', 'hmm', 'lda', 'linear_model',
44-
'metrics', 'mixture', 'naive_bayes', 'neighbors', 'pipeline',
45-
'preprocessing', 'qda', 'svm', 'clone',
46-
'cross_decomposition', 'isotonic']
41+
__all__ = ['cluster', 'covariance', 'cross_decomposition',
42+
'cross_validation', 'datasets', 'decomposition', 'dummy',
43+
'ensemble', 'externals', 'feature_extraction',
44+
'feature_selection', 'gaussian_process', 'grid_search', 'hmm',
45+
'isotonic', 'kernel_approximation', 'lda', 'learning_curve',
46+
'linear_model', 'manifold', 'metrics', 'mixture', 'multiclass',
47+
'naive_bayes', 'neighbors', 'neural_network', 'pipeline',
48+
'preprocessing', 'qda', 'random_projection', 'semi_supervised',
49+
'svm', 'tree',
50+
# Non-modules:
51+
'clone']
4752

4853

4954
def setup_module(module):

sklearn/tests/test_common.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
from sklearn.utils.testing import assert_false
1818
from sklearn.utils.testing import all_estimators
1919
from sklearn.utils.testing import assert_greater
20+
from sklearn.utils.testing import assert_in
2021
from sklearn.utils.testing import SkipTest
22+
from sklearn.utils.testing import ignore_warnings
2123

2224
import sklearn
2325
from sklearn.base import (ClassifierMixin, RegressorMixin,
@@ -286,12 +288,14 @@ def test_estimators_overwrite_params():
286288
yield check_estimators_overwrite_params, name, Estimator
287289

288290

291+
@ignore_warnings
289292
def test_import_all_consistency():
290293
# Smoke test to check that any name in a __all__ list is actually defined
291294
# in the namespace of the module or package.
292295
pkgs = pkgutil.walk_packages(path=sklearn.__path__, prefix='sklearn.',
293296
onerror=lambda _: None)
294-
for importer, modname, ispkg in pkgs:
297+
submods = [modname for _, modname, _ in pkgs]
298+
for modname in submods + ['sklearn']:
295299
if ".tests." in modname:
296300
continue
297301
package = __import__(modname, fromlist="dummy")
@@ -302,6 +306,15 @@ def test_import_all_consistency():
302306
modname, name))
303307

304308

309+
def test_root_import_all_completeness():
310+
EXCEPTIONS = ('utils', 'tests', 'base', 'setup')
311+
for _, modname, _ in pkgutil.walk_packages(path=sklearn.__path__,
312+
onerror=lambda _: None):
313+
if '.' in modname or modname.startswith('_') or modname in EXCEPTIONS:
314+
continue
315+
assert_in(modname, sklearn.__all__)
316+
317+
305318
def test_sparsify_estimators():
306319
#Test if predict with sparsified estimators works.
307320
#Tests regression, binary classification, and multi-class classification.

0 commit comments

Comments
 (0)