Skip to content

[MRG] MNT Use a common language_level cython directive #13630

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

Merged
merged 1 commit into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions sklearn/__check_build/_check_build.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# cython: language_level=3

def check_build():
return
4 changes: 3 additions & 1 deletion sklearn/_build_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ def maybe_cythonize_extensions(top_path, config):
exc.args += (message,)
raise

config.ext_modules = cythonize(config.ext_modules)
config.ext_modules = cythonize(
config.ext_modules,
compiler_directives={'language_level': 3})
2 changes: 1 addition & 1 deletion sklearn/_isotonic.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# enhancement of searching for the longest decreasing subsequence to
# pool at each step.
#
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
# cython: boundscheck=False, wraparound=False, cdivision=True

import numpy as np
cimport numpy as np
Expand Down
2 changes: 1 addition & 1 deletion sklearn/cluster/_dbscan_inner.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Author: Lars Buitinck
# License: 3-clause BSD
#
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: boundscheck=False, wraparound=False

cimport cython
from libcpp.vector cimport vector
Expand Down
2 changes: 0 additions & 2 deletions sklearn/cluster/_hierarchical.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Author: Gael Varoquaux <gael.varoquaux@normalesup.org>
#
# cython: language_level=3

import numpy as np
cimport numpy as np
Expand Down
2 changes: 1 addition & 1 deletion sklearn/cluster/_k_means.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# License: BSD 3 clause
#
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
# cython: boundscheck=False, wraparound=False, cdivision=True

from libc.math cimport sqrt
import numpy as np
Expand Down
1 change: 0 additions & 1 deletion sklearn/cluster/_k_means_elkan.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3
#
# Author: Andreas Mueller
#
Expand Down
4 changes: 2 additions & 2 deletions sklearn/datasets/_svmlight_format.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Olivier Grisel <olivier.grisel@ensta.org>
# License: BSD 3 clause
#
# cython: language_level=2, boundscheck=False, wraparound=False
# cython: boundscheck=False, wraparound=False

import array
from cpython cimport array
Expand Down Expand Up @@ -61,7 +61,7 @@ def _load_svmlight_file(f, dtype, bint multilabel, bint zero_based,
for line in f:
# skip comments
line_cstr = line
hash_ptr = strchr(line_cstr, '#')
hash_ptr = strchr(line_cstr, 35) # ASCII value of '#' is 35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This was the part missing in #12873 that prevented me to use a global option.

if hash_ptr != NULL:
line = line[:hash_ptr - line_cstr]

Expand Down
2 changes: 1 addition & 1 deletion sklearn/decomposition/_online_lda.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: boundscheck=False, wraparound=False

cimport cython
cimport numpy as np
Expand Down
1 change: 0 additions & 1 deletion sklearn/decomposition/cdnmf_fast.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3

# Author: Mathieu Blondel, Tom Dupre la Tour
# License: BSD 3 clause
Expand Down
1 change: 0 additions & 1 deletion sklearn/ensemble/_gradient_boosting.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3
#
# Author: Peter Prettenhofer
#
Expand Down
2 changes: 1 addition & 1 deletion sklearn/feature_extraction/_hashing.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Author: Lars Buitinck
# License: BSD 3 clause
#
# cython: language_level=3, boundscheck=False, cdivision=True
# cython: boundscheck=False, cdivision=True

import sys
import array
Expand Down
2 changes: 1 addition & 1 deletion sklearn/linear_model/cd_fast.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# License: BSD 3 clause
#
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
# cython: boundscheck=False, wraparound=False, cdivision=True

from libc.math cimport fabs
cimport numpy as np
Expand Down
1 change: 0 additions & 1 deletion sklearn/linear_model/sag_fast.pyx.tp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def get_dispatch(dtypes):
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3
#
# Authors: Danny Sullivan <dbsullivan23@gmail.com>
# Tom Dupre la Tour <tom.dupre-la-tour@m4x.org>
Expand Down
2 changes: 0 additions & 2 deletions sklearn/linear_model/sgd_fast.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# License: BSD 3 clause
#
# cython: language_level=3
"""Helper to load LossFunction from sgd_fast.pyx to sag_fast.pyx"""

cdef class LossFunction:
Expand Down
1 change: 0 additions & 1 deletion sklearn/linear_model/sgd_fast.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3
#
# Author: Peter Prettenhofer <peter.prettenhofer@gmail.com>
# Mathieu Blondel (partial_fit support)
Expand Down
1 change: 0 additions & 1 deletion sklearn/manifold/_barnes_hut_tsne.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: boundscheck=False
# cython: wraparound=False
# cython: cdivision=True
# cython: language_level=3
#
# Author: Christopher Moody <chrisemoody@gmail.com>
# Author: Nick Travers <nickt@squareup.com>
Expand Down
2 changes: 1 addition & 1 deletion sklearn/manifold/_utils.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cython: language_level=3, boundscheck=False
# cython: boundscheck=False

from libc cimport math
cimport cython
Expand Down
1 change: 0 additions & 1 deletion sklearn/metrics/cluster/expected_mutual_info_fast.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3
#
# Authors: Robert Layton <robertlayton@gmail.com>
# Corey Lynch <coreylynch9@gmail.com>
Expand Down
1 change: 0 additions & 1 deletion sklearn/metrics/pairwise_fast.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#cython: boundscheck=False
#cython: cdivision=True
#cython: wraparound=False
# cython: language_level=3
#
# Author: Andreas Mueller <amueller@ais.uni-bonn.de>
# Lars Buitinck
Expand Down
1 change: 0 additions & 1 deletion sklearn/neighbors/ball_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#cython: boundscheck=False
#cython: wraparound=False
#cython: cdivision=True
# cython: language_level=3

# Author: Jake Vanderplas <vanderplas@astro.washington.edu>
# License: BSD 3 clause
Expand Down
1 change: 0 additions & 1 deletion sklearn/neighbors/binary_tree.pxi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!python
# cython: language_level=3


# KD Tree and Ball Tree
Expand Down
1 change: 0 additions & 1 deletion sklearn/neighbors/dist_metrics.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#cython: boundscheck=False
#cython: wraparound=False
#cython: cdivision=True
# cython: language_level=3

cimport cython
cimport numpy as np
Expand Down
1 change: 0 additions & 1 deletion sklearn/neighbors/dist_metrics.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#cython: boundscheck=False
#cython: wraparound=False
#cython: cdivision=True
# cython: language_level=3

# By Jake Vanderplas (2013) <jakevdp@cs.washington.edu>
# written for the scikit-learn project
Expand Down
1 change: 0 additions & 1 deletion sklearn/neighbors/kd_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#cython: boundscheck=False
#cython: wraparound=False
#cython: cdivision=True
# cython: language_level=3

# By Jake Vanderplas (2013) <jakevdp@cs.washington.edu>
# written for the scikit-learn project
Expand Down
1 change: 0 additions & 1 deletion sklearn/neighbors/quad_tree.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: boundscheck=False
# cython: wraparound=False
# cython: cdivision=True
# cython: language_level=3
#
# Author: Thomas Moreau <thomas.moreau.2010@gmail.com>
# Author: Olivier Grisel <olivier.grisel@ensta.fr>
Expand Down
1 change: 0 additions & 1 deletion sklearn/neighbors/quad_tree.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: boundscheck=False
# cython: wraparound=False
# cython: cdivision=True
# cython: language_level=3
#
# Author: Thomas Moreau <thomas.moreau.2010@gmail.com>
# Author: Olivier Grisel <olivier.grisel@ensta.fr>
Expand Down
1 change: 0 additions & 1 deletion sklearn/neighbors/typedefs.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!python
# cython: language_level=3
cimport numpy as np

# Floating point/data type
Expand Down
2 changes: 0 additions & 2 deletions sklearn/neighbors/typedefs.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!python
#
# cython: language_level=3

import numpy as np
cimport numpy as np
Expand Down
1 change: 0 additions & 1 deletion sklearn/preprocessing/_csr_polynomial_expansion.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3

# Author: Andrew nystrom <awnystrom@gmail.com>

Expand Down
2 changes: 0 additions & 2 deletions sklearn/svm/liblinear.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# cython: language_level=3

cimport numpy as np


Expand Down
1 change: 0 additions & 1 deletion sklearn/svm/liblinear.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# cython: language_level=3
"""
Wrapper for liblinear

Expand Down
2 changes: 0 additions & 2 deletions sklearn/svm/libsvm.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# cython: language_level=3

cimport numpy as np

################################################################################
Expand Down
1 change: 0 additions & 1 deletion sklearn/svm/libsvm.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# cython: language_level=3
"""
Binding for libsvm_skl
----------------------
Expand Down
2 changes: 0 additions & 2 deletions sklearn/svm/libsvm_sparse.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# cython: language_level=3

import warnings
import numpy as np
cimport numpy as np
Expand Down
1 change: 0 additions & 1 deletion sklearn/tree/_criterion.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# cython: language_level=3
# Authors: Gilles Louppe <g.louppe@gmail.com>
# Peter Prettenhofer <peter.prettenhofer@gmail.com>
# Brian Holt <bdholt1@gmail.com>
Expand Down
1 change: 0 additions & 1 deletion sklearn/tree/_criterion.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3

# Authors: Gilles Louppe <g.louppe@gmail.com>
# Peter Prettenhofer <peter.prettenhofer@gmail.com>
Expand Down
1 change: 0 additions & 1 deletion sklearn/tree/_splitter.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# cython: language_level=3
# Authors: Gilles Louppe <g.louppe@gmail.com>
# Peter Prettenhofer <peter.prettenhofer@gmail.com>
# Brian Holt <bdholt1@gmail.com>
Expand Down
1 change: 0 additions & 1 deletion sklearn/tree/_splitter.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3

# Authors: Gilles Louppe <g.louppe@gmail.com>
# Peter Prettenhofer <peter.prettenhofer@gmail.com>
Expand Down
2 changes: 0 additions & 2 deletions sklearn/tree/_tree.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# Nelson Liu <nelson@nelsonliu.me>
#
# License: BSD 3 clause
#
# cython: language_level=3

# See _tree.pyx for details.

Expand Down
1 change: 0 additions & 1 deletion sklearn/tree/_tree.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3

# Authors: Gilles Louppe <g.louppe@gmail.com>
# Peter Prettenhofer <peter.prettenhofer@gmail.com>
Expand Down
4 changes: 0 additions & 4 deletions sklearn/tree/_utils.pxd
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# cython: language_level=3

# Authors: Gilles Louppe <g.louppe@gmail.com>
# Peter Prettenhofer <peter.prettenhofer@gmail.com>
# Arnaud Joly <arnaud.v.joly@gmail.com>
# Jacob Schreiber <jmschreiber91@gmail.com>
# Nelson Liu <nelson@nelsonliu.me>
#
# License: BSD 3 clause
#
# cython: language_level=3

# See _utils.pyx for details.

Expand Down
1 change: 0 additions & 1 deletion sklearn/tree/_utils.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3

# Authors: Gilles Louppe <g.louppe@gmail.com>
# Peter Prettenhofer <peter.prettenhofer@gmail.com>
Expand Down
2 changes: 0 additions & 2 deletions sklearn/utils/_cython_blas.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# cython: language_level=3

from cython cimport floating


Expand Down
1 change: 0 additions & 1 deletion sklearn/utils/_logistic_sigmoid.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#cython: boundscheck=False
#cython: cdivision=True
#cython: wraparound=False
#cython: language_level=3

from libc.math cimport log, exp

Expand Down
2 changes: 0 additions & 2 deletions sklearn/utils/_random.pxd
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Authors: Arnaud Joly
#
# License: BSD 3 clause
#
# cython: language_level=3


import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions sklearn/utils/_random.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# cython: language_level=3
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3
#
# Author: Arnaud Joly
#
Expand Down
1 change: 0 additions & 1 deletion sklearn/utils/arrayfuncs.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# cython: language_level=3
"""
Small collection of auxiliary functions that operate on arrays

Expand Down
2 changes: 0 additions & 2 deletions sklearn/utils/fast_dict.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Author: Gael Varoquaux
# License: BSD
#
# cython: language_level=3
"""
Uses C++ map containers for fast dict-like behavior with keys being
integers, and values float.
Expand Down
2 changes: 0 additions & 2 deletions sklearn/utils/fast_dict.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ integers, and values float.
"""
# Author: Gael Varoquaux
# License: BSD
#
# cython: language_level=3

cimport cython

Expand Down
2 changes: 0 additions & 2 deletions sklearn/utils/graph_shortest_path.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Author: Jake Vanderplas -- <vanderplas@astro.washington.edu>
# License: BSD 3 clause, (C) 2011
#
# cython: language_level=3

"""
Routines for performing shortest-path graph searches
Expand Down
Loading