diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f5234f58efe..43f55de8a2b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -86,12 +86,8 @@ repos: types: [python] - id: no-unseeded-default-rng name: no-unseeded-default-rng - description: 'Enforce that no non-seeded default_rng is used and default_rng is used instead of np.random.seed' - entry: | - # Check for usage of default_rng without seeding - default_rng\(\)| - # Check for usage of np.random.seed - np.random.seed\( + description: 'Enforce that np.random.default_rng is seeded' + entry: default_rng\(\) language: pygrep types: [python] - id: cmake-format diff --git a/python/cudf/cudf/tests/test_parquet.py b/python/cudf/cudf/tests/test_parquet.py index c9ce24d2a5b..e659d2b2f13 100644 --- a/python/cudf/cudf/tests/test_parquet.py +++ b/python/cudf/cudf/tests/test_parquet.py @@ -193,11 +193,6 @@ def parquet_file(request, tmp_path_factory, pdf): return fname -@pytest.fixture(scope="module") -def rdg_seed(): - return int(os.environ.get("TEST_CUDF_RDG_SEED", "42")) - - def make_pdf(nrows, ncolumns=1, nvalids=0, dtype=np.int64): test_pdf = pd.DataFrame( [list(range(ncolumns * i, ncolumns * (i + 1))) for i in range(nrows)], @@ -431,7 +426,7 @@ def num_row_groups(rows, group_size): assert a == b -def test_parquet_read_filtered(tmpdir, rdg_seed): +def test_parquet_read_filtered(tmpdir): # Generate data fname = tmpdir.join("filtered.parquet") dg.generate( @@ -455,13 +450,13 @@ def test_parquet_read_filtered(tmpdir, rdg_seed): dg.ColumnParameters( 40, 0.2, - lambda: np.random.default_rng(seed=None).integers( + lambda: np.random.default_rng(seed=0).integers( 0, 100, size=40 ), True, ), ], - seed=rdg_seed, + seed=42, ), format={"name": "parquet", "row_group_size": 64}, ) diff --git a/python/dask_cudf/dask_cudf/tests/test_reductions.py b/python/dask_cudf/dask_cudf/tests/test_reductions.py index 4351b672151..f11a5252080 100644 --- a/python/dask_cudf/dask_cudf/tests/test_reductions.py +++ b/python/dask_cudf/dask_cudf/tests/test_reductions.py @@ -1,7 +1,5 @@ # Copyright (c) 2021-2024, NVIDIA CORPORATION. -import numpy as np -import pandas as pd import pytest import dask @@ -10,20 +8,7 @@ import cudf import dask_cudf - - -def _make_random_frame(nelem, npartitions=2): - rng = np.random.default_rng(seed=0) - df = pd.DataFrame( - { - "x": rng.integers(0, 5, size=nelem), - "y": rng.normal(loc=1.0, scale=1.0, size=nelem), - } - ) - gdf = cudf.DataFrame.from_pandas(df) - dgf = dask_cudf.from_cudf(gdf, npartitions=npartitions) - return df, dgf - +from dask_cudf.tests.utils import _make_random_frame _reducers = ["sum", "count", "mean", "var", "std", "min", "max"] diff --git a/python/dask_cudf/dask_cudf/tests/utils.py b/python/dask_cudf/dask_cudf/tests/utils.py index a9f61f75762..b44b3f939e7 100644 --- a/python/dask_cudf/dask_cudf/tests/utils.py +++ b/python/dask_cudf/dask_cudf/tests/utils.py @@ -19,7 +19,7 @@ def _make_random_frame(nelem, npartitions=2, include_na=False): - rng = np.random.default_rng(seed=None) + rng = np.random.default_rng(seed=0) df = pd.DataFrame( {"x": rng.random(size=nelem), "y": rng.random(size=nelem)} )