diff --git a/sklearn/__init__.py b/sklearn/__init__.py index 9e6a5682005f0f53f2610f9bf7d3a30aff6e1b47..0a52ff6959570c041bb1254178702224775fc188 100644 --- a/sklearn/__init__.py +++ b/sklearn/__init__.py @@ -36,6 +36,7 @@ if __SKLEARN_SETUP__: else: from . import __check_build from .base import clone + __check_build # avoid flakes unused variable error def test(*args, **kwargs): import warnings @@ -60,14 +61,17 @@ the tests and will be removed in release 0.16. # "test" as a test function test.__test__ = False - __all__ = ['cross_validation', 'cluster', 'covariance', - 'datasets', 'decomposition', 'feature_extraction', - 'feature_selection', 'semi_supervised', - 'gaussian_process', 'grid_search', 'hmm', 'lda', 'linear_model', - 'metrics', 'mixture', 'naive_bayes', 'neighbors', 'pipeline', - 'preprocessing', 'qda', 'svm', 'clone', - 'cross_decomposition', - 'isotonic', 'pls'] + __all__ = ['cluster', 'covariance', 'cross_decomposition', + 'cross_validation', 'datasets', 'decomposition', 'dummy', + 'ensemble', 'externals', 'feature_extraction', + 'feature_selection', 'gaussian_process', 'grid_search', 'hmm', + 'isotonic', 'kernel_approximation', 'lda', 'learning_curve', + 'linear_model', 'manifold', 'metrics', 'mixture', 'multiclass', + 'naive_bayes', 'neighbors', 'neural_network', 'pipeline', 'pls', + 'preprocessing', 'qda', 'random_projection', 'semi_supervised', + 'svm', 'tree', + # Non-modules: + 'clone'] def setup_module(module): diff --git a/sklearn/tests/test_common.py b/sklearn/tests/test_common.py index ec3da95840d01526e9cbdc96acedbcb564e209ae..fc21ff9ee032cb55b009057d06fe8159c66ae563 100644 --- a/sklearn/tests/test_common.py +++ b/sklearn/tests/test_common.py @@ -31,8 +31,10 @@ from sklearn.utils.testing import all_estimators from sklearn.utils.testing import meta_estimators from sklearn.utils.testing import set_random_state from sklearn.utils.testing import assert_greater +from sklearn.utils.testing import assert_in from sklearn.utils.testing import SkipTest from sklearn.utils.testing import check_skip_travis +from sklearn.utils.testing import ignore_warnings import sklearn from sklearn.base import (clone, ClassifierMixin, RegressorMixin, @@ -1143,12 +1145,14 @@ def check_cluster_overwrite_params(name, Clustering, X, y): % (name, k, v, new_params[k])) +@ignore_warnings def test_import_all_consistency(): # Smoke test to check that any name in a __all__ list is actually defined # in the namespace of the module or package. pkgs = pkgutil.walk_packages(path=sklearn.__path__, prefix='sklearn.', onerror=lambda _: None) - for importer, modname, ispkg in pkgs: + submods = [modname for _, modname, _ in pkgs] + for modname in submods + ['sklearn']: if ".tests." in modname: continue package = __import__(modname, fromlist="dummy") @@ -1159,6 +1163,15 @@ def test_import_all_consistency(): modname, name)) +def test_root_import_all_completeness(): + EXCEPTIONS = ('utils', 'tests', 'base', 'setup') + for _, modname, _ in pkgutil.walk_packages(path=sklearn.__path__, + onerror=lambda _: None): + if '.' in modname or modname.startswith('_') or modname in EXCEPTIONS: + continue + assert_in(modname, sklearn.__all__) + + def test_sparsify_estimators(): """Test if predict with sparsified estimators works.