10000 [MRG] Fixes Cython cimport errors by thomasjpfan · Pull Request #13754 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG] Fixes Cython cimport errors #13754

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 3 commits into from
May 1, 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
4 changes: 2 additions & 2 deletions sklearn/linear_model/cd_fast.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ from ..utils._cython_blas cimport (_axpy, _dot, _asum, _ger, _gemv, _nrm2,
from ..utils._cython_blas cimport RowMajor, ColMajor, Trans, NoTrans


from ..utils cimport _random
from ..utils._random cimport our_rand_r

ctypedef np.float64_t DOUBLE
ctypedef np.uint32_t UINT32_t
Expand All @@ -42,7 +42,7 @@ cdef enum:

cdef inline UINT32_t rand_int(UINT32_t end, UINT32_t* random_state) nogil:
"""Generate a random integer in [0; end)."""
return _random.our_rand_r(random_state) % end
return our_rand_r(random_state) % end


cdef inline floating fmax(floating x, floating y) nogil:
Expand Down
6 changes: 3 additions & 3 deletions sklearn/tree/_utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import numpy as np
cimport numpy as np
np.import_array()

from ..utils cimport _random
from ..utils._random cimport our_rand_r

# =============================================================================
# Helper functions
Expand Down Expand Up @@ -64,13 +64,13 @@ cdef inline np.ndarray sizet_ptr_to_ndarray(SIZE_t* data, SIZE_t size):
cdef inline SIZE_t rand_int(SIZE_t low, SIZE_t high,
UINT32_t* random_state) nogil:
"""Generate a random integer in [low; end)."""
return low + _random.our_rand_r(random_state) % (high - low)
return low + our_rand_r(random_state) % (high - low)


cdef inline double rand_uniform(double low, double high,
UINT32_t* random_state) nogil:
"""Generate a random double in [low; high)."""
return ((high - low) * <double> _random.our_rand_r(random_state) /
return ((high - low) * <double> our_rand_r(random_state) /
<double> RAND_R_MAX) + low


Expand Down
6 changes: 3 additions & 3 deletions sklearn/utils/seq_dataset.pyx.tp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import numpy as np

np.import_array()

from . cimport _random
from ._random cimport our_rand_r

cdef class SequentialDataset{{name}}:
"""Base class for datasets with sequential data access.
Expand Down Expand Up @@ -155,7 +155,7 @@ cdef class SequentialDataset{{name}}:
cdef int n = self.n_samples
cdef unsigned i, j
for i in range(n - 1):
j = i + _random.our_rand_r(&seed) % (n - i)
j = i + our_rand_r(&seed) % (n - i)
ind[i], ind[j] = ind[j], ind[i]

cdef int _get_next_index(self) nogil:
Expand All @@ -169,7 +169,7 @@ cdef class SequentialDataset{{name}}:

cdef int _get_random_index(self) nogil:
cdef int n = self.n_samples
cdef int current_index = _random.our_rand_r(&self.seed) % n
cdef int current_index = our_rand_r(&self.seed) % n
self.current_index = current_index
return current_index

Expand Down
0