Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better code formatting #17190

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Submitting a Pull Request

Before opening a Pull Request, have a look at the
full Contributing page to make sure your code complies
with our guidelines: https://scikit-learn.org/stable/developers/index.html
with our guidelines: https://scikit-learn.org/stable/developers/index.html.


Project History
Expand Down Expand Up @@ -168,4 +168,4 @@ Communication
Citation
~~~~~~~~

If you use scikit-learn in a scientific publication, we would appreciate citations: https://scikit-learn.org/stable/about.html#citing-scikit-learn
If you use scikit-learn in a scientific publication, we would appreciate citations: https://scikit-learn.org/stable/about.html#citing-scikit-learn.
24 changes: 13 additions & 11 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
PYTEST_MIN_VERSION = '3.3.0'

if LooseVersion(pytest.__version__) < PYTEST_MIN_VERSION:
raise ImportError('Your version of pytest is too old, you should have '
'at least pytest >= {} installed.'
.format(PYTEST_MIN_VERSION))
raise ImportError(
'Your version of pytest is too old, you should have '
'at least pytest >= {} installed.'.format(PYTEST_MIN_VERSION))


def pytest_addoption(parser):
parser.addoption("--skip-network", action="store_true", default=False,
parser.addoption("--skip-network",
action="store_true",
default=False,
help="skip network tests")


Expand All @@ -38,8 +40,8 @@ def pytest_collection_modifyitems(config, items):
skip_marker = pytest.mark.skip(
reason='FeatureHasher is not compatible with PyPy')
for item in items:
if item.name.endswith(('_hash.FeatureHasher',
'text.HashingVectorizer')):
if item.name.endswith(
('_hash.FeatureHasher', 'text.HashingVectorizer')):
item.add_marker(skip_marker)

# Skip tests which require internet if the flag is provided
Expand Down Expand Up @@ -80,7 +82,8 @@ def pytest_collection_modifyitems(config, items):
for item in items:
if item.name in [
"sklearn.feature_extraction.image.PatchExtractor",
"sklearn.feature_extraction.image.extract_patches_2d"]:
"sklearn.feature_extraction.image.extract_patches_2d"
]:
item.add_marker(skip_marker)


Expand All @@ -89,9 +92,7 @@ def pytest_configure(config):
sys._is_pytest_session = True
# declare our custom markers to avoid PytestUnknownMarkWarning
config.addinivalue_line(
"markers",
"network: mark a test for execution if network available."
)
"markers", "network: mark a test for execution if network available.")


def pytest_unconfigure(config):
Expand All @@ -103,4 +104,5 @@ def pytest_unconfigure(config):
# Configures pytest to ignore deprecated modules.
collect_ignore_glob = [
os.path.join(*deprecated_path.split(".")) + ".py"
for _, deprecated_path, _, _ in _DEPRECATED_MODULES]
for _, deprecated_path, _, _ in _DEPRECATED_MODULES
]
126 changes: 63 additions & 63 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# Python import machinery.
builtins.__SKLEARN_SETUP__ = True


DISTNAME = 'scikit-learn'
DESCRIPTION = 'A set of python modules for machine learning and data mining'
with open('README.rst') as f:
Expand Down Expand Up @@ -63,9 +62,17 @@
# as it monkey-patches the 'setup' function
# For some commands, use setuptools
SETUPTOOLS_COMMANDS = {
'develop', 'release', 'bdist_egg', 'bdist_rpm',
'bdist_wininst', 'install_egg_info', 'build_sphinx',
'egg_info', 'easy_install', 'upload', 'bdist_wheel',
'develop',
'release',
'bdist_egg',
'bdist_rpm',
'bdist_wininst',
'install_egg_info',
'build_sphinx',
'egg_info',
'easy_install',
'upload',
'bdist_wheel',
'--single-version-externally-managed',
}
if SETUPTOOLS_COMMANDS.intersection(sys.argv):
Expand All @@ -84,9 +91,9 @@
else:
extra_setuptools_args = dict()


# Custom clean command to remove build artifacts


class CleanCommand(Clean):
description = "Remove build artifacts from the source tree"

Expand All @@ -101,8 +108,9 @@ def run(self):
shutil.rmtree('build')
for dirpath, dirnames, filenames in os.walk('sklearn'):
for filename in filenames:
if any(filename.endswith(suffix) for suffix in
(".so", ".pyd", ".dll", ".pyc")):
if any(
filename.endswith(suffix)
for suffix in (".so", ".pyd", ".dll", ".pyc")):
os.unlink(os.path.join(dirpath, filename))
continue
extension = os.path.splitext(filename)[1]
Expand Down Expand Up @@ -143,7 +151,6 @@ def build_extensions(self):
# that python 3.6 is required.
pass


# Optional wheelhouse-uploader features
# To automate release of binary packages for scikit-learn we need a tool
# to download the packages generated by travis and appveyor workers (with
Expand Down Expand Up @@ -203,8 +210,7 @@ def check_package_status(package, min_version):
package_status['up_to_date'] = False
package_status['version'] = ""

req_str = "scikit-learn requires {} >= {}.\n".format(
package, min_version)
req_str = "scikit-learn requires {} >= {}.\n".format(package, min_version)

instructions = ("Installation instructions are available on the "
"scikit-learn website: "
Expand All @@ -213,64 +219,58 @@ def check_package_status(package, min_version):
if package_status['up_to_date'] is False:
if package_status['version']:
raise ImportError("Your installation of {} "
"{} is out-of-date.\n{}{}"
.format(package, package_status['version'],
req_str, instructions))
"{} is out-of-date.\n{}{}".format(
package, package_status['version'], req_str,
instructions))
else:
raise ImportError("{} is not "
"installed.\n{}{}"
.format(package, req_str, instructions))
"installed.\n{}{}".format(
package, req_str, instructions))


def setup_package():
metadata = dict(name=DISTNAME,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
license=LICENSE,
url=URL,
download_url=DOWNLOAD_URL,
project_urls=PROJECT_URLS,
version=VERSION,
long_description=LONG_DESCRIPTION,
classifiers=['Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'License :: OSI Approved',
'Programming Language :: C',
'Programming Language :: Python',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
('Programming Language :: Python :: '
'Implementation :: CPython'),
('Programming Language :: Python :: '
'Implementation :: PyPy')
],
cmdclass=cmdclass,
python_requires=">=3.6",
install_requires=[
'numpy>={}'.format(NUMPY_MIN_VERSION),
'scipy>={}'.format(SCIPY_MIN_VERSION),
'joblib>={}'.format(JOBLIB_MIN_VERSION),
'threadpoolctl>={}'.format(THREADPOOLCTL_MIN_VERSION)
],
package_data={'': ['*.pxd']},
**extra_setuptools_args)
metadata = dict(
name=DISTNAME,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
license=LICENSE,
url=URL,
download_url=DOWNLOAD_URL,
project_urls=PROJECT_URLS,
version=VERSION,
long_description=LONG_DESCRIPTION,
classifiers=[
'Intended Audience :: Science/Research',
'Intended Audience :: Developers', 'License :: OSI Approved',
'Programming Language :: C', 'Programming Language :: Python',
'Topic :: Software Development', 'Topic :: Scientific/Engineering',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX', 'Operating System :: Unix',
'Operating System :: MacOS', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
('Programming Language :: Python :: '
'Implementation :: CPython'),
('Programming Language :: Python :: '
'Implementation :: PyPy')
],
cmdclass=cmdclass,
python_requires=">=3.6",
install_requires=[
'numpy>={}'.format(NUMPY_MIN_VERSION),
'scipy>={}'.format(SCIPY_MIN_VERSION),
'joblib>={}'.format(JOBLIB_MIN_VERSION),
'threadpoolctl>={}'.format(THREADPOOLCTL_MIN_VERSION)
],
package_data={'': ['*.pxd']},
**extra_setuptools_args)

if len(sys.argv) == 1 or (
len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
sys.argv[1] in ('--help-commands',
'egg_info',
'dist_info',
'--version',
'clean'))):
len(sys.argv) >= 2 and
('--help' in sys.argv[1:] or sys.argv[1] in
('--help-commands', 'egg_info', 'dist_info', '--version', 'clean'))):
# For these actions, NumPy is not required
#
# They are required to succeed without Numpy for example when
Expand All @@ -286,8 +286,8 @@ def setup_package():
if sys.version_info < (3, 6):
raise RuntimeError(
"Scikit-learn requires Python 3.6 or later. The current"
" Python version is %s installed in %s."
% (platform.python_version(), sys.executable))
" Python version is %s installed in %s." %
(platform.python_version(), sys.executable))

check_package_status('numpy', NUMPY_MIN_VERSION)

Expand Down
1 change: 1 addition & 0 deletions sklearn/__check_build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def raise_build_error(e):
`make` in the source directory.
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))


try:
from ._check_build import check_build # noqa
except ImportError as e:
Expand Down
1 change: 1 addition & 0 deletions sklearn/__check_build/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def configuration(parent_package='', top_path=None):

return config


if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
60 changes: 45 additions & 15 deletions sklearn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

logger = logging.getLogger(__name__)


# PEP0440 compatible formatted version, see:
# https://www.python.org/dev/peps/pep-0440/
#
Expand All @@ -39,7 +38,6 @@
#
__version__ = '0.24.dev0'


# On OSX, we can get a runtime error due to multiple OpenMP libraries loaded
# simultaneously. This can happen for instance when calling BLAS inside a
# prange. Setting the following environment variable allows multiple OpenMP
Expand Down Expand Up @@ -80,19 +78,51 @@
from .base import clone
from .utils._show_versions import show_versions

__all__ = ['calibration', 'cluster', 'covariance', 'cross_decomposition',
'datasets', 'decomposition', 'dummy', 'ensemble', 'exceptions',
'experimental', 'externals', 'feature_extraction',
'feature_selection', 'gaussian_process', 'inspection',
'isotonic', 'kernel_approximation', 'kernel_ridge',
'linear_model', 'manifold', 'metrics', 'mixture',
'model_selection', 'multiclass', 'multioutput',
'naive_bayes', 'neighbors', 'neural_network', 'pipeline',
'preprocessing', 'random_projection', 'semi_supervised',
'svm', 'tree', 'discriminant_analysis', 'impute', 'compose',
# Non-modules:
'clone', 'get_config', 'set_config', 'config_context',
'show_versions']
__all__ = [
'calibration',
'cluster',
'covariance',
'cross_decomposition',
'datasets',
'decomposition',
'dummy',
'ensemble',
'exceptions',
'experimental',
'externals',
'feature_extraction',
'feature_selection',
'gaussian_process',
'inspection',
'isotonic',
'kernel_approximation',
'kernel_ridge',
'linear_model',
'manifold',
'metrics',
'mixture',
'model_selection',
'multiclass',
'multioutput',
'naive_bayes',
'neighbors',
'neural_network',
'pipeline',
'preprocessing',
'random_projection',
'semi_supervised',
'svm',
'tree',
'discriminant_analysis',
'impute',
'compose',
# Non-modules:
'clone',
'get_config',
'set_config',
'config_context',
'show_versions'
]


def setup_module(module):
Expand Down