diff --git a/asv_bench/benchmarks/algos/isin.py b/asv_bench/benchmarks/algos/isin.py index 4b58981694014..296101c9f9800 100644 --- a/asv_bench/benchmarks/algos/isin.py +++ b/asv_bench/benchmarks/algos/isin.py @@ -50,8 +50,6 @@ def setup(self, dtype): elif dtype in ["category[object]", "category[int]"]: # Note: sizes are different in this case than others - np.random.seed(1234) - n = 5 * 10 ** 5 sample_size = 100 @@ -99,7 +97,6 @@ class IsinAlmostFullWithRandomInt: def setup(self, dtype, exponent, title): M = 3 * 2 ** (exponent - 2) # 0.77-the maximal share of occupied buckets - np.random.seed(42) self.series = Series(np.random.randint(0, M, M)).astype(dtype) values = np.random.randint(0, M, M).astype(dtype) @@ -132,7 +129,6 @@ class IsinWithRandomFloat: param_names = ["dtype", "size", "title"] def setup(self, dtype, size, title): - np.random.seed(42) self.values = np.random.rand(size) self.series = Series(self.values).astype(dtype) np.random.shuffle(self.values) @@ -179,7 +175,6 @@ class IsinWithArange: def setup(self, dtype, M, offset_factor): offset = int(M * offset_factor) - np.random.seed(42) tmp = Series(np.random.randint(offset, M + offset, 10 ** 6)) self.series = tmp.astype(dtype) self.values = np.arange(M).astype(dtype) @@ -290,10 +285,8 @@ def setup(self, dtype, MaxNumber, series_type): raise NotImplementedError if series_type == "random_hits": - np.random.seed(42) array = np.random.randint(0, MaxNumber, N) if series_type == "random_misses": - np.random.seed(42) array = np.random.randint(0, MaxNumber, N) + MaxNumber if series_type == "monotone_hits": array = np.repeat(np.arange(MaxNumber), N // MaxNumber) @@ -322,7 +315,6 @@ def setup(self, dtype, series_type): raise NotImplementedError if series_type == "random": - np.random.seed(42) vals = np.random.randint(0, 10 * N, N) if series_type == "monotone": vals = np.arange(N) diff --git a/asv_bench/benchmarks/frame_ctor.py b/asv_bench/benchmarks/frame_ctor.py index 3367898101528..7fbe249788a98 100644 --- a/asv_bench/benchmarks/frame_ctor.py +++ b/asv_bench/benchmarks/frame_ctor.py @@ -67,7 +67,6 @@ class FromDictwithTimestamp: def setup(self, offset): N = 10 ** 3 - np.random.seed(1234) idx = date_range(Timestamp("1/1/1900"), freq=offset, periods=N) df = DataFrame(np.random.randn(N, 10), index=idx) self.d = df.to_dict() diff --git a/asv_bench/benchmarks/hash_functions.py b/asv_bench/benchmarks/hash_functions.py index 394433f7c8f99..6703cc791493a 100644 --- a/asv_bench/benchmarks/hash_functions.py +++ b/asv_bench/benchmarks/hash_functions.py @@ -67,7 +67,6 @@ class NumericSeriesIndexingShuffled: def setup(self, index, N): vals = np.array(list(range(55)) + [54] + list(range(55, N - 1))) - np.random.seed(42) np.random.shuffle(vals) indices = index(vals) self.data = pd.Series(np.arange(N), index=indices) diff --git a/asv_bench/benchmarks/indexing.py b/asv_bench/benchmarks/indexing.py index 86790063c5056..10fb926ee4d03 100644 --- a/asv_bench/benchmarks/indexing.py +++ b/asv_bench/benchmarks/indexing.py @@ -368,17 +368,14 @@ def setup(self): self.df = DataFrame(index=range(self.N)) def time_insert(self): - np.random.seed(1234) for i in range(100): self.df.insert(0, i, np.random.randn(self.N), allow_duplicates=True) def time_assign_with_setitem(self): - np.random.seed(1234) for i in range(100): self.df[i] = np.random.randn(self.N) def time_assign_list_like_with_setitem(self): - np.random.seed(1234) self.df[list(range(100))] = np.random.randn(self.N, 100) def time_assign_list_of_columns_concat(self): diff --git a/asv_bench/benchmarks/series_methods.py b/asv_bench/benchmarks/series_methods.py index d05a28e0873d0..7592ce54e3712 100644 --- a/asv_bench/benchmarks/series_methods.py +++ b/asv_bench/benchmarks/series_methods.py @@ -145,7 +145,6 @@ class Mode: param_names = ["N", "dtype"] def setup(self, N, dtype): - np.random.seed(42) self.s = Series(np.random.randint(0, N, size=10 * N)).astype(dtype) def time_mode(self, N, dtype): diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 7cc171330e01a..1844cb863c183 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -77,6 +77,10 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then invgrep -R --include="*.rst" -E "[a-zA-Z0-9]\`\`?[a-zA-Z0-9]" doc/source/ RET=$(($RET + $?)) ; echo $MSG "DONE" + MSG='Check for unnecessary random seeds in asv benchmarks' ; echo $MSG + invgrep -R --exclude pandas_vb_common.py -E 'np.random.seed' asv_bench/benchmarks/ + RET=$(($RET + $?)) ; echo $MSG "DONE" + fi ### CODE ###