Repository: modin-project/modin

Issue:
[ASV] don't use lambda functions in benchmark parameters
Do not use lambdas, since their string view contains an address that changes with different launches, thereby changing `results/benchmarks.json` files.


Discussion:

Resolving patch:
diff --git a/asv_bench/benchmarks/benchmarks.py b/asv_bench/benchmarks/benchmarks.py
--- a/asv_bench/benchmarks/benchmarks.py
+++ b/asv_bench/benchmarks/benchmarks.py
@@ -34,13 +34,13 @@
     GROUPBY_NGROUPS,
     IMPL,
     execute,
+    translator_groupby_ngroups,
 )
 
 
 class BaseTimeGroupBy:
     def setup(self, shape, ngroups=5, groupby_ncols=1):
-        if callable(ngroups):
-            ngroups = ngroups(shape[0])
+        ngroups = translator_groupby_ngroups(ngroups, shape)
         self.df, self.groupby_columns = generate_dataframe(
             ASV_USE_IMPL,
             "int",
@@ -407,6 +407,7 @@ def setup(self, shape, ngroups=5, subset="all"):
                 f"Invalid value for 'subset={subset}'. Allowed: {list(self.subset_params.keys())}"
             )
         ncols = subset(shape)
+        ngroups = translator_groupby_ngroups(ngroups, shape)
         self.df, _ = generate_dataframe(
             ASV_USE_IMPL,
             "int",
diff --git a/asv_bench/benchmarks/io/csv.py b/asv_bench/benchmarks/io/csv.py
--- a/asv_bench/benchmarks/io/csv.py
+++ b/asv_bench/benchmarks/io/csv.py
@@ -48,20 +48,30 @@ def setup(self, test_filenames, shape, *args, **kwargs):
 
 
 class TimeReadCsvSkiprows(BaseReadCsv):
+    skiprows_mapping = {
+        "lambda_even_rows": lambda x: x % 2,
+        "range_uniform": np.arange(1, UNARY_OP_DATA_SIZE[ASV_DATASET_SIZE][0][0] // 10),
+        "range_step2": np.arange(1, UNARY_OP_DATA_SIZE[ASV_DATASET_SIZE][0][0], 2),
+    }
+
     param_names = ["shape", "skiprows"]
     params = [
         UNARY_OP_DATA_SIZE[ASV_DATASET_SIZE],
         [
             None,
-            lambda x: x % 2,
-            np.arange(1, UNARY_OP_DATA_SIZE[ASV_DATASET_SIZE][0][0] // 10),
-            np.arange(1, UNARY_OP_DATA_SIZE[ASV_DATASET_SIZE][0][0], 2),
+            "lambda_even_rows",
+            "range_uniform",
+            "range_step2",
         ],
     ]
 
+    def setup(self, test_filenames, shape, skiprows):
+        super().setup(test_filenames, shape, skiprows)
+        self.skiprows = self.skiprows_mapping[skiprows] if skiprows else None
+
     def time_skiprows(self, test_filenames, shape, skiprows):
         execute(
             IMPL[ASV_USE_IMPL].read_csv(
-                test_filenames[self.shape_id], skiprows=skiprows
+                test_filenames[self.shape_id], skiprows=self.skiprows
             )
         )
diff --git a/asv_bench/benchmarks/utils.py b/asv_bench/benchmarks/utils.py
--- a/asv_bench/benchmarks/utils.py
+++ b/asv_bench/benchmarks/utils.py
@@ -72,7 +72,7 @@
 }
 
 GROUPBY_NGROUPS = {
-    "Big": [100, lambda nrows: min(nrows // 2, 5000)],
+    "Big": [100, "huge_amount_groups"],
     "Small": [5],
 }
 
@@ -82,6 +82,15 @@
 }
 
 
+def translator_groupby_ngroups(groupby_ngroups, shape):
+    if ASV_DATASET_SIZE == "Big":
+        if groupby_ngroups == "huge_amount_groups":
+            return min(shape[0] // 2, 5000)
+        return groupby_ngroups
+    else:
+        return groupby_ngroups
+
+
 class weakdict(dict):
     __slots__ = ("__weakref__",)
 


Test patch: