8000 BLD Fixes Cython cimport errors (#13754) · scikit-learn/scikit-learn@5f0263f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f0263f

Browse files
thomasjpfanjnothman
authored andcommitted
BLD Fixes Cython cimport errors (#13754)
1 parent cc0179a commit 5f0263f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

sklearn/linear_model/cd_fast.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ from ..utils._cython_blas cimport (_axpy, _dot, _asum, _ger, _gemv, _nrm2,
2424
from ..utils._cython_blas cimport RowMajor, ColMajor, Trans, NoTrans
2525

2626

27-
from ..utils cimport _random
27+
from ..utils._random cimport our_rand_r
2828

2929
ctypedef np.float64_t DOUBLE
3030
ctypedef np.uint32_t UINT32_t
@@ -42,7 +42,7 @@ cdef enum:
4242

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

4747

4848
cdef inline floating fmax(floating x, floating y) nogil:

sklearn/tree/_utils.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import numpy as np
2020
cimport numpy as np
2121
np.import_array()
2222

23-
from ..utils cimport _random
23+
from ..utils._random cimport our_rand_r
2424

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

6969

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

7676

sklearn/utils/seq_dataset.pyx.tp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import numpy as np
4545

4646
np.import_array()
4747

48-
from . cimport _random
48+
from ._random cimport our_rand_r
4949

5050
cdef class SequentialDataset{{name}}:
5151
"""Base class for datasets with sequential data access.
@@ -155,7 +155,7 @@ cdef class SequentialDataset{{name}}:
155155
cdef int n = self.n_samples
156156
cdef unsigned i, j
157157
for i in range(n - 1):
158-
j = i + _random.our_rand_r(&seed) % (n - i)
158+
j = i + our_rand_r(&seed) % (n - i)
159159
ind[i], ind[j] = ind[j], ind[i]
160160

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

170170
cdef int _get_random_index(self) nogil:
171171
cdef int n = self.n_samples
172-
cdef int current_index = _random.our_rand_r(&self.seed) % n
172+
cdef int current_index = our_rand_r(&self.seed) % n
173173
self.current_index = current_index
174174
return current_index
175175

0 commit comments

Comments
 (0)
0