Skip to content

Commit

Permalink
Use int instead of float in random.randint (#5864)
Browse files Browse the repository at this point in the history
Split from #5799

Non-integer arguments are deprecated to this method

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: #5864
  • Loading branch information
mroeschke authored Apr 25, 2024
1 parent 302bb08 commit bcade6e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions python/cuml/datasets/arima.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020-2023, NVIDIA CORPORATION.
# Copyright (c) 2020-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -135,7 +135,7 @@ def make_arima(batch_size=1000, n_obs=100, order=(1, 1, 1),
cdef uintptr_t out_ptr = <uintptr_t> out.ptr

if random_state is None:
random_state = randint(0, 1e18)
random_state = randint(0, 10**18)

if dtype == np.float32:
cpp_make_arima(handle_[0], <float*> out_ptr, <int> batch_size,
Expand Down
4 changes: 2 additions & 2 deletions python/cuml/datasets/regression.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
# Copyright (c) 2019-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -206,7 +206,7 @@ def make_regression(
coef_ptr = coefs.ptr

if random_state is None:
random_state = randint(0, 1e18)
random_state = randint(0, 10**18)

if dtype == np.float32:
cpp_make_regression(handle_[0], <float*> out_ptr,
Expand Down
4 changes: 2 additions & 2 deletions python/cuml/explainer/kernel_shap.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020-2023, NVIDIA CORPORATION.
# Copyright (c) 2020-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -340,7 +340,7 @@ class KernelExplainer(SHAPBase):
x_ptr = get_cai_ptr(self._mask)

if self.random_state is None:
self.random_state = randint(0, 1e18)
self.random_state = randint(0, 10**18)

# we default to float32 unless self.dtype is specifically np.float64
if self.dtype == np.float64:
Expand Down
4 changes: 2 additions & 2 deletions python/cuml/tests/test_kmeans.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
# Copyright (c) 2019-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,7 +61,7 @@ def get_data_consistency_test():

@pytest.fixture
def random_state():
random_state = random.randint(0, 1e6)
random_state = random.randint(0, 10**6)
with logger.set_level(logger.level_debug):
logger.debug("Random seed: {}".format(random_state))
return random_state
Expand Down
4 changes: 2 additions & 2 deletions python/cuml/tests/test_metrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021-2023, NVIDIA CORPORATION.
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -108,7 +108,7 @@

@pytest.fixture(scope="module")
def random_state():
random_state = random.randint(0, 1e6)
random_state = random.randint(0, 10**6)
with logger.set_level(logger.level_debug):
logger.debug("Random seed: {}".format(random_state))
return random_state
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/tests/test_random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def test_rf_classification_seed(small_clf, datatype):
)

for i in range(8):
seed = random.randint(100, 1e5)
seed = random.randint(100, 10**5)
# Initialize, fit and predict using cuML's
# random forest classification model
cu_class = curfc(random_state=seed, n_streams=1)
Expand Down

0 comments on commit bcade6e

Please sign in to comment.