We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
BENCH: cleanup errors around benchmarks
we are showing some errors in the benchmark suite: https://github.com/ibis-project/ibis/pull/2451/checks?check_run_id=1220781799

would be nice to have these run fully w/o errors.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `benchmarks/benchmarks.py`
Content:
```
1 import numpy as np
2 import pandas as pd
3 
4 import ibis
5 import ibis.expr.datatypes as dt
6 from ibis.backends.pandas.udf import udf
7 
8 
9 def make_t(name='t'):
10     return ibis.table(
11         (
12             ('_timestamp', 'int32'),
13             ('dim1', 'int32'),
14             ('dim2', 'int32'),
15             ('valid_seconds', 'int32'),
16             ('meas1', 'int32'),
17             ('meas2', 'int32'),
18             ('year', 'int32'),
19             ('month', 'int32'),
20             ('day', 'int32'),
21             ('hour', 'int32'),
22             ('minute', 'int32'),
23         ),
24         name=name,
25     )
26 
27 
28 def make_base(t):
29     return (
30         (t.year > 2016)
31         | ((t.year == 2016) & (t.month > 6))
32         | ((t.year == 2016) & (t.month == 6) & (t.day > 6))
33         | ((t.year == 2016) & (t.month == 6) & (t.day == 6) & (t.hour > 6))
34         | (
35             (t.year == 2016)
36             & (t.month == 6)
37             & (t.day == 6)
38             & (t.hour == 6)
39             & (t.minute >= 5)
40         )
41     ) & (
42         (t.year < 2016)
43         | ((t.year == 2016) & (t.month < 6))
44         | ((t.year == 2016) & (t.month == 6) & (t.day < 6))
45         | ((t.year == 2016) & (t.month == 6) & (t.day == 6) & (t.hour < 6))
46         | (
47             (t.year == 2016)
48             & (t.month == 6)
49             & (t.day == 6)
50             & (t.hour == 6)
51             & (t.minute <= 5)
52         )
53     )
54 
55 
56 def make_large_expr(t, base):
57     src_table = t[base]
58     src_table = src_table.mutate(
59         _timestamp=(src_table['_timestamp'] - src_table['_timestamp'] % 3600)
60         .cast('int32')
61         .name('_timestamp'),
62         valid_seconds=300,
63     )
64 
65     aggs = []
66     for meas in ['meas1', 'meas2']:
67         aggs.append(src_table[meas].sum().cast('float').name(meas))
68     src_table = src_table.aggregate(
69         aggs, by=['_timestamp', 'dim1', 'dim2', 'valid_seconds']
70     )
71 
72     part_keys = ['year', 'month', 'day', 'hour', 'minute']
73     ts_col = src_table['_timestamp'].cast('timestamp')
74     new_cols = {}
75     for part_key in part_keys:
76         part_col = getattr(ts_col, part_key)()
77         new_cols[part_key] = part_col
78     src_table = src_table.mutate(**new_cols)
79     return src_table[
80         [
81             '_timestamp',
82             'dim1',
83             'dim2',
84             'meas1',
85             'meas2',
86             'year',
87             'month',
88             'day',
89             'hour',
90             'minute',
91         ]
92     ]
93 
94 
95 class Suite:
96     def setup(self):
97         self.t = t = make_t()
98         self.base = make_base(t)
99         self.expr = self.large_expr
100 
101     @property
102     def large_expr(self):
103         t = make_t()
104         return make_large_expr(t, make_base(t))
105 
106 
107 class Construction(Suite):
108     def time_large_expr_construction(self):
109         self.large_expr
110 
111 
112 class Hashing(Suite):
113     def time_hash_small_expr(self):
114         hash(make_t())
115 
116     def time_hash_medium_expr(self):
117         hash(make_base(make_t()))
118 
119     def time_hash_large_expr(self):
120         hash(self.large_expr)
121 
122 
123 class Formatting(Suite):
124     def time_base_expr_formatting(self):
125         str(self.base)
126 
127     def time_large_expr_formatting(self):
128         str(self.expr)
129 
130 
131 class Compilation(Suite):
132     def time_impala_base_compile(self):
133         ibis.impala.compile(self.base)
134 
135     def time_impala_large_expr_compile(self):
136         ibis.impala.compile(self.expr)
137 
138 
139 class PandasBackend:
140     def setup(self):
141         n = 30 * int(2e5)
142         self.data = pd.DataFrame(
143             {
144                 'key': np.random.choice(16000, size=n),
145                 'low_card_key': np.random.choice(30, size=n),
146                 'value': np.random.rand(n),
147                 'timestamps': pd.date_range(
148                     start='now', periods=n, freq='s'
149                 ).values,
150                 'timestamp_strings': pd.date_range(
151                     start='now', periods=n, freq='s'
152                 ).values.astype(str),
153                 'repeated_timestamps': pd.date_range(
154                     start='2018-09-01', periods=30
155                 ).repeat(int(n / 30)),
156             }
157         )
158 
159         t = ibis.pandas.connect({'df': self.data}).table('df')
160 
161         self.high_card_group_by = t.groupby(t.key).aggregate(
162             avg_value=t.value.mean()
163         )
164 
165         self.cast_to_dates = t.timestamps.cast(dt.date)
166         self.cast_to_dates_from_strings = t.timestamp_strings.cast(dt.date)
167 
168         self.multikey_group_by_with_mutate = (
169             t.mutate(dates=t.timestamps.cast('date'))
170             .groupby(['low_card_key', 'dates'])
171             .aggregate(avg_value=lambda t: t.value.mean())
172         )
173 
174         self.simple_sort = t.sort_by([t.key])
175 
176         self.simple_sort_projection = t[['key', 'value']].sort_by(['key'])
177 
178         self.multikey_sort = t.sort_by(['low_card_key', 'key'])
179 
180         self.multikey_sort_projection = t[
181             ['low_card_key', 'key', 'value']
182         ].sort_by(['low_card_key', 'key'])
183 
184         low_card_rolling_window = ibis.trailing_range_window(
185             ibis.interval(days=2),
186             order_by=t.repeated_timestamps,
187             group_by=t.low_card_key,
188         )
189         self.low_card_grouped_rolling = t.value.mean().over(
190             low_card_rolling_window
191         )
192 
193         high_card_rolling_window = ibis.trailing_range_window(
194             ibis.interval(days=2),
195             order_by=t.repeated_timestamps,
196             group_by=t.key,
197         )
198         self.high_card_grouped_rolling = t.value.mean().over(
199             high_card_rolling_window
200         )
201 
202         @udf.reduction(['double'], 'double')
203         def my_mean(series):
204             return series.mean()
205 
206         self.low_card_grouped_rolling_udf_mean = my_mean(t.value).over(
207             low_card_rolling_window
208         )
209         self.high_card_grouped_rolling_udf_mean = my_mean(t.value).over(
210             high_card_rolling_window
211         )
212 
213         @udf.analytic(['double'], 'double')
214         def my_zscore(series):
215             return (series - series.mean()) / series.std()
216 
217         low_card_window = ibis.window(group_by=t.low_card_key)
218 
219         high_card_window = ibis.window(group_by=t.key)
220 
221         self.low_card_window_analytics_udf = my_zscore(t.value).over(
222             low_card_window
223         )
224         self.high_card_window_analytics_udf = my_zscore(t.value).over(
225             high_card_window
226         )
227 
228         @udf.reduction(['double', 'double'], 'double')
229         def my_wm(v, w):
230             return np.average(v, weights=w)
231 
232         self.low_card_grouped_rolling_udf_wm = my_wm(t.value, t.value).over(
233             low_card_rolling_window
234         )
235 
236         self.high_card_grouped_rolling_udf_wm = my_wm(t.value, t.value).over(
237             low_card_rolling_window
238         )
239 
240     def time_high_cardinality_group_by(self):
241         self.high_card_group_by.execute()
242 
243     def time_cast_to_date(self):
244         self.cast_to_dates.execute()
245 
246     def time_cast_to_date_from_string(self):
247         self.cast_to_dates_from_strings.execute()
248 
249     def time_multikey_group_by_with_mutate(self):
250         self.multikey_group_by_with_mutate.execute()
251 
252     def time_simple_sort(self):
253         self.simple_sort.execute()
254 
255     def time_multikey_sort(self):
256         self.multikey_sort.execute()
257 
258     def time_simple_sort_projection(self):
259         self.simple_sort_projection.execute()
260 
261     def time_multikey_sort_projection(self):
262         self.multikey_sort_projection.execute()
263 
264     def time_low_card_grouped_rolling(self):
265         self.low_card_grouped_rolling.execute()
266 
267     def time_high_card_grouped_rolling(self):
268         self.high_card_grouped_rolling.execute()
269 
270     def time_low_card_grouped_rolling_udf(self):
271         self.low_card_grouped_rolling_udf.execute()
272 
273     def time_high_card_grouped_rolling_udf(self):
274         self.high_card_grouped_rolling_udf.execute()
275 
276     def time_low_card_window_analytics_udf(self):
277         self.low_card_window_analytics_udf.execute()
278 
279     def time_high_card_grouped_rolling_udf_wm(self):
280         self.high_card_grouped_rolling_udf_wm.execute()
281 
282     def time_low_card_grouped_rolling_udf_wm(self):
283         self.low_card_grouped_rolling_udf_wm.execute()
284
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/benchmarks/benchmarks.py b/benchmarks/benchmarks.py
--- a/benchmarks/benchmarks.py
+++ b/benchmarks/benchmarks.py
@@ -138,7 +138,7 @@
 
 class PandasBackend:
     def setup(self):
-        n = 30 * int(2e5)
+        n = 30 * int(2e4)
         self.data = pd.DataFrame(
             {
                 'key': np.random.choice(16000, size=n),
@@ -268,10 +268,10 @@
         self.high_card_grouped_rolling.execute()
 
     def time_low_card_grouped_rolling_udf(self):
-        self.low_card_grouped_rolling_udf.execute()
+        self.low_card_grouped_rolling_udf_mean.execute()
 
     def time_high_card_grouped_rolling_udf(self):
-        self.high_card_grouped_rolling_udf.execute()
+        self.high_card_grouped_rolling_udf_mean.execute()
 
     def time_low_card_window_analytics_udf(self):
         self.low_card_window_analytics_udf.execute()

{"golden_diff": "diff --git a/benchmarks/benchmarks.py b/benchmarks/benchmarks.py\n--- a/benchmarks/benchmarks.py\n+++ b/benchmarks/benchmarks.py\n@@ -138,7 +138,7 @@\n \n class PandasBackend:\n     def setup(self):\n-        n = 30 * int(2e5)\n+        n = 30 * int(2e4)\n         self.data = pd.DataFrame(\n             {\n                 'key': np.random.choice(16000, size=n),\n@@ -268,10 +268,10 @@\n         self.high_card_grouped_rolling.execute()\n \n     def time_low_card_grouped_rolling_udf(self):\n-        self.low_card_grouped_rolling_udf.execute()\n+        self.low_card_grouped_rolling_udf_mean.execute()\n \n     def time_high_card_grouped_rolling_udf(self):\n-        self.high_card_grouped_rolling_udf.execute()\n+        self.high_card_grouped_rolling_udf_mean.execute()\n \n     def time_low_card_window_analytics_udf(self):\n         self.low_card_window_analytics_udf.execute()\n", "issue": "BENCH: cleanup errors around benchmarks\nwe are showing some errors in the benchmark suite: https://github.com/ibis-project/ibis/pull/2451/checks?check_run_id=1220781799\r\n\r\nwould be nice to have these run fully w/o errors.\n", "before_files": [{"content": "import numpy as np\nimport pandas as pd\n\nimport ibis\nimport ibis.expr.datatypes as dt\nfrom ibis.backends.pandas.udf import udf\n\n\ndef make_t(name='t'):\n    return ibis.table(\n        (\n            ('_timestamp', 'int32'),\n            ('dim1', 'int32'),\n            ('dim2', 'int32'),\n            ('valid_seconds', 'int32'),\n            ('meas1', 'int32'),\n            ('meas2', 'int32'),\n            ('year', 'int32'),\n            ('month', 'int32'),\n            ('day', 'int32'),\n            ('hour', 'int32'),\n            ('minute', 'int32'),\n        ),\n        name=name,\n    )\n\n\ndef make_base(t):\n    return (\n        (t.year > 2016)\n        | ((t.year == 2016) & (t.month > 6))\n        | ((t.year == 2016) & (t.month == 6) & (t.day > 6))\n        | ((t.year == 2016) & (t.month == 6) & (t.day == 6) & (t.hour > 6))\n        | (\n            (t.year == 2016)\n            & (t.month == 6)\n            & (t.day == 6)\n            & (t.hour == 6)\n            & (t.minute >= 5)\n        )\n    ) & (\n        (t.year < 2016)\n        | ((t.year == 2016) & (t.month < 6))\n        | ((t.year == 2016) & (t.month == 6) & (t.day < 6))\n        | ((t.year == 2016) & (t.month == 6) & (t.day == 6) & (t.hour < 6))\n        | (\n            (t.year == 2016)\n            & (t.month == 6)\n            & (t.day == 6)\n            & (t.hour == 6)\n            & (t.minute <= 5)\n        )\n    )\n\n\ndef make_large_expr(t, base):\n    src_table = t[base]\n    src_table = src_table.mutate(\n        _timestamp=(src_table['_timestamp'] - src_table['_timestamp'] % 3600)\n        .cast('int32')\n        .name('_timestamp'),\n        valid_seconds=300,\n    )\n\n    aggs = []\n    for meas in ['meas1', 'meas2']:\n        aggs.append(src_table[meas].sum().cast('float').name(meas))\n    src_table = src_table.aggregate(\n        aggs, by=['_timestamp', 'dim1', 'dim2', 'valid_seconds']\n    )\n\n    part_keys = ['year', 'month', 'day', 'hour', 'minute']\n    ts_col = src_table['_timestamp'].cast('timestamp')\n    new_cols = {}\n    for part_key in part_keys:\n        part_col = getattr(ts_col, part_key)()\n        new_cols[part_key] = part_col\n    src_table = src_table.mutate(**new_cols)\n    return src_table[\n        [\n            '_timestamp',\n            'dim1',\n            'dim2',\n            'meas1',\n            'meas2',\n            'year',\n            'month',\n            'day',\n            'hour',\n            'minute',\n        ]\n    ]\n\n\nclass Suite:\n    def setup(self):\n        self.t = t = make_t()\n        self.base = make_base(t)\n        self.expr = self.large_expr\n\n    @property\n    def large_expr(self):\n        t = make_t()\n        return make_large_expr(t, make_base(t))\n\n\nclass Construction(Suite):\n    def time_large_expr_construction(self):\n        self.large_expr\n\n\nclass Hashing(Suite):\n    def time_hash_small_expr(self):\n        hash(make_t())\n\n    def time_hash_medium_expr(self):\n        hash(make_base(make_t()))\n\n    def time_hash_large_expr(self):\n        hash(self.large_expr)\n\n\nclass Formatting(Suite):\n    def time_base_expr_formatting(self):\n        str(self.base)\n\n    def time_large_expr_formatting(self):\n        str(self.expr)\n\n\nclass Compilation(Suite):\n    def time_impala_base_compile(self):\n        ibis.impala.compile(self.base)\n\n    def time_impala_large_expr_compile(self):\n        ibis.impala.compile(self.expr)\n\n\nclass PandasBackend:\n    def setup(self):\n        n = 30 * int(2e5)\n        self.data = pd.DataFrame(\n            {\n                'key': np.random.choice(16000, size=n),\n                'low_card_key': np.random.choice(30, size=n),\n                'value': np.random.rand(n),\n                'timestamps': pd.date_range(\n                    start='now', periods=n, freq='s'\n                ).values,\n                'timestamp_strings': pd.date_range(\n                    start='now', periods=n, freq='s'\n                ).values.astype(str),\n                'repeated_timestamps': pd.date_range(\n                    start='2018-09-01', periods=30\n                ).repeat(int(n / 30)),\n            }\n        )\n\n        t = ibis.pandas.connect({'df': self.data}).table('df')\n\n        self.high_card_group_by = t.groupby(t.key).aggregate(\n            avg_value=t.value.mean()\n        )\n\n        self.cast_to_dates = t.timestamps.cast(dt.date)\n        self.cast_to_dates_from_strings = t.timestamp_strings.cast(dt.date)\n\n        self.multikey_group_by_with_mutate = (\n            t.mutate(dates=t.timestamps.cast('date'))\n            .groupby(['low_card_key', 'dates'])\n            .aggregate(avg_value=lambda t: t.value.mean())\n        )\n\n        self.simple_sort = t.sort_by([t.key])\n\n        self.simple_sort_projection = t[['key', 'value']].sort_by(['key'])\n\n        self.multikey_sort = t.sort_by(['low_card_key', 'key'])\n\n        self.multikey_sort_projection = t[\n            ['low_card_key', 'key', 'value']\n        ].sort_by(['low_card_key', 'key'])\n\n        low_card_rolling_window = ibis.trailing_range_window(\n            ibis.interval(days=2),\n            order_by=t.repeated_timestamps,\n            group_by=t.low_card_key,\n        )\n        self.low_card_grouped_rolling = t.value.mean().over(\n            low_card_rolling_window\n        )\n\n        high_card_rolling_window = ibis.trailing_range_window(\n            ibis.interval(days=2),\n            order_by=t.repeated_timestamps,\n            group_by=t.key,\n        )\n        self.high_card_grouped_rolling = t.value.mean().over(\n            high_card_rolling_window\n        )\n\n        @udf.reduction(['double'], 'double')\n        def my_mean(series):\n            return series.mean()\n\n        self.low_card_grouped_rolling_udf_mean = my_mean(t.value).over(\n            low_card_rolling_window\n        )\n        self.high_card_grouped_rolling_udf_mean = my_mean(t.value).over(\n            high_card_rolling_window\n        )\n\n        @udf.analytic(['double'], 'double')\n        def my_zscore(series):\n            return (series - series.mean()) / series.std()\n\n        low_card_window = ibis.window(group_by=t.low_card_key)\n\n        high_card_window = ibis.window(group_by=t.key)\n\n        self.low_card_window_analytics_udf = my_zscore(t.value).over(\n            low_card_window\n        )\n        self.high_card_window_analytics_udf = my_zscore(t.value).over(\n            high_card_window\n        )\n\n        @udf.reduction(['double', 'double'], 'double')\n        def my_wm(v, w):\n            return np.average(v, weights=w)\n\n        self.low_card_grouped_rolling_udf_wm = my_wm(t.value, t.value).over(\n            low_card_rolling_window\n        )\n\n        self.high_card_grouped_rolling_udf_wm = my_wm(t.value, t.value).over(\n            low_card_rolling_window\n        )\n\n    def time_high_cardinality_group_by(self):\n        self.high_card_group_by.execute()\n\n    def time_cast_to_date(self):\n        self.cast_to_dates.execute()\n\n    def time_cast_to_date_from_string(self):\n        self.cast_to_dates_from_strings.execute()\n\n    def time_multikey_group_by_with_mutate(self):\n        self.multikey_group_by_with_mutate.execute()\n\n    def time_simple_sort(self):\n        self.simple_sort.execute()\n\n    def time_multikey_sort(self):\n        self.multikey_sort.execute()\n\n    def time_simple_sort_projection(self):\n        self.simple_sort_projection.execute()\n\n    def time_multikey_sort_projection(self):\n        self.multikey_sort_projection.execute()\n\n    def time_low_card_grouped_rolling(self):\n        self.low_card_grouped_rolling.execute()\n\n    def time_high_card_grouped_rolling(self):\n        self.high_card_grouped_rolling.execute()\n\n    def time_low_card_grouped_rolling_udf(self):\n        self.low_card_grouped_rolling_udf.execute()\n\n    def time_high_card_grouped_rolling_udf(self):\n        self.high_card_grouped_rolling_udf.execute()\n\n    def time_low_card_window_analytics_udf(self):\n        self.low_card_window_analytics_udf.execute()\n\n    def time_high_card_grouped_rolling_udf_wm(self):\n        self.high_card_grouped_rolling_udf_wm.execute()\n\n    def time_low_card_grouped_rolling_udf_wm(self):\n        self.low_card_grouped_rolling_udf_wm.execute()\n", "path": "benchmarks/benchmarks.py"}], "after_files": [{"content": "import numpy as np\nimport pandas as pd\n\nimport ibis\nimport ibis.expr.datatypes as dt\nfrom ibis.pandas.udf import udf\n\n\ndef make_t(name='t'):\n    return ibis.table(\n        (\n            ('_timestamp', 'int32'),\n            ('dim1', 'int32'),\n            ('dim2', 'int32'),\n            ('valid_seconds', 'int32'),\n            ('meas1', 'int32'),\n            ('meas2', 'int32'),\n            ('year', 'int32'),\n            ('month', 'int32'),\n            ('day', 'int32'),\n            ('hour', 'int32'),\n            ('minute', 'int32'),\n        ),\n        name=name,\n    )\n\n\ndef make_base(t):\n    return (\n        (t.year > 2016)\n        | ((t.year == 2016) & (t.month > 6))\n        | ((t.year == 2016) & (t.month == 6) & (t.day > 6))\n        | ((t.year == 2016) & (t.month == 6) & (t.day == 6) & (t.hour > 6))\n        | (\n            (t.year == 2016)\n            & (t.month == 6)\n            & (t.day == 6)\n            & (t.hour == 6)\n            & (t.minute >= 5)\n        )\n    ) & (\n        (t.year < 2016)\n        | ((t.year == 2016) & (t.month < 6))\n        | ((t.year == 2016) & (t.month == 6) & (t.day < 6))\n        | ((t.year == 2016) & (t.month == 6) & (t.day == 6) & (t.hour < 6))\n        | (\n            (t.year == 2016)\n            & (t.month == 6)\n            & (t.day == 6)\n            & (t.hour == 6)\n            & (t.minute <= 5)\n        )\n    )\n\n\ndef make_large_expr(t, base):\n    src_table = t[base]\n    src_table = src_table.mutate(\n        _timestamp=(src_table['_timestamp'] - src_table['_timestamp'] % 3600)\n        .cast('int32')\n        .name('_timestamp'),\n        valid_seconds=300,\n    )\n\n    aggs = []\n    for meas in ['meas1', 'meas2']:\n        aggs.append(src_table[meas].sum().cast('float').name(meas))\n    src_table = src_table.aggregate(\n        aggs, by=['_timestamp', 'dim1', 'dim2', 'valid_seconds']\n    )\n\n    part_keys = ['year', 'month', 'day', 'hour', 'minute']\n    ts_col = src_table['_timestamp'].cast('timestamp')\n    new_cols = {}\n    for part_key in part_keys:\n        part_col = getattr(ts_col, part_key)()\n        new_cols[part_key] = part_col\n    src_table = src_table.mutate(**new_cols)\n    return src_table[\n        [\n            '_timestamp',\n            'dim1',\n            'dim2',\n            'meas1',\n            'meas2',\n            'year',\n            'month',\n            'day',\n            'hour',\n            'minute',\n        ]\n    ]\n\n\nclass Suite:\n    def setup(self):\n        self.t = t = make_t()\n        self.base = make_base(t)\n        self.expr = self.large_expr\n\n    @property\n    def large_expr(self):\n        t = make_t()\n        return make_large_expr(t, make_base(t))\n\n\nclass Construction(Suite):\n    def time_large_expr_construction(self):\n        self.large_expr\n\n\nclass Hashing(Suite):\n    def time_hash_small_expr(self):\n        hash(make_t())\n\n    def time_hash_medium_expr(self):\n        hash(make_base(make_t()))\n\n    def time_hash_large_expr(self):\n        hash(self.large_expr)\n\n\nclass Formatting(Suite):\n    def time_base_expr_formatting(self):\n        str(self.base)\n\n    def time_large_expr_formatting(self):\n        str(self.expr)\n\n\nclass Compilation(Suite):\n    def time_impala_base_compile(self):\n        ibis.impala.compile(self.base)\n\n    def time_impala_large_expr_compile(self):\n        ibis.impala.compile(self.expr)\n\n\nclass PandasBackend:\n    def setup(self):\n        n = 30 * int(2e4)\n        self.data = pd.DataFrame(\n            {\n                'key': np.random.choice(16000, size=n),\n                'low_card_key': np.random.choice(30, size=n),\n                'value': np.random.rand(n),\n                'timestamps': pd.date_range(\n                    start='now', periods=n, freq='s'\n                ).values,\n                'timestamp_strings': pd.date_range(\n                    start='now', periods=n, freq='s'\n                ).values.astype(str),\n                'repeated_timestamps': pd.date_range(\n                    start='2018-09-01', periods=30\n                ).repeat(int(n / 30)),\n            }\n        )\n\n        t = ibis.pandas.connect({'df': self.data}).table('df')\n\n        self.high_card_group_by = t.groupby(t.key).aggregate(\n            avg_value=t.value.mean()\n        )\n\n        self.cast_to_dates = t.timestamps.cast(dt.date)\n        self.cast_to_dates_from_strings = t.timestamp_strings.cast(dt.date)\n\n        self.multikey_group_by_with_mutate = (\n            t.mutate(dates=t.timestamps.cast('date'))\n            .groupby(['low_card_key', 'dates'])\n            .aggregate(avg_value=lambda t: t.value.mean())\n        )\n\n        self.simple_sort = t.sort_by([t.key])\n\n        self.simple_sort_projection = t[['key', 'value']].sort_by(['key'])\n\n        self.multikey_sort = t.sort_by(['low_card_key', 'key'])\n\n        self.multikey_sort_projection = t[\n            ['low_card_key', 'key', 'value']\n        ].sort_by(['low_card_key', 'key'])\n\n        low_card_rolling_window = ibis.trailing_range_window(\n            ibis.interval(days=2),\n            order_by=t.repeated_timestamps,\n            group_by=t.low_card_key,\n        )\n        self.low_card_grouped_rolling = t.value.mean().over(\n            low_card_rolling_window\n        )\n\n        high_card_rolling_window = ibis.trailing_range_window(\n            ibis.interval(days=2),\n            order_by=t.repeated_timestamps,\n            group_by=t.key,\n        )\n        self.high_card_grouped_rolling = t.value.mean().over(\n            high_card_rolling_window\n        )\n\n        @udf.reduction(['double'], 'double')\n        def my_mean(series):\n            return series.mean()\n\n        self.low_card_grouped_rolling_udf_mean = my_mean(t.value).over(\n            low_card_rolling_window\n        )\n        self.high_card_grouped_rolling_udf_mean = my_mean(t.value).over(\n            high_card_rolling_window\n        )\n\n        @udf.analytic(['double'], 'double')\n        def my_zscore(series):\n            return (series - series.mean()) / series.std()\n\n        low_card_window = ibis.window(group_by=t.low_card_key)\n\n        high_card_window = ibis.window(group_by=t.key)\n\n        self.low_card_window_analytics_udf = my_zscore(t.value).over(\n            low_card_window\n        )\n        self.high_card_window_analytics_udf = my_zscore(t.value).over(\n            high_card_window\n        )\n\n        @udf.reduction(['double', 'double'], 'double')\n        def my_wm(v, w):\n            return np.average(v, weights=w)\n\n        self.low_card_grouped_rolling_udf_wm = my_wm(t.value, t.value).over(\n            low_card_rolling_window\n        )\n\n        self.high_card_grouped_rolling_udf_wm = my_wm(t.value, t.value).over(\n            low_card_rolling_window\n        )\n\n    def time_high_cardinality_group_by(self):\n        self.high_card_group_by.execute()\n\n    def time_cast_to_date(self):\n        self.cast_to_dates.execute()\n\n    def time_cast_to_date_from_string(self):\n        self.cast_to_dates_from_strings.execute()\n\n    def time_multikey_group_by_with_mutate(self):\n        self.multikey_group_by_with_mutate.execute()\n\n    def time_simple_sort(self):\n        self.simple_sort.execute()\n\n    def time_multikey_sort(self):\n        self.multikey_sort.execute()\n\n    def time_simple_sort_projection(self):\n        self.simple_sort_projection.execute()\n\n    def time_multikey_sort_projection(self):\n        self.multikey_sort_projection.execute()\n\n    def time_low_card_grouped_rolling(self):\n        self.low_card_grouped_rolling.execute()\n\n    def time_high_card_grouped_rolling(self):\n        self.high_card_grouped_rolling.execute()\n\n    def time_low_card_grouped_rolling_udf(self):\n        self.low_card_grouped_rolling_udf_mean.execute()\n\n    def time_high_card_grouped_rolling_udf(self):\n        self.high_card_grouped_rolling_udf_mean.execute()\n\n    def time_low_card_window_analytics_udf(self):\n        self.low_card_window_analytics_udf.execute()\n\n    def time_high_card_grouped_rolling_udf_wm(self):\n        self.high_card_grouped_rolling_udf_wm.execute()\n\n    def time_low_card_grouped_rolling_udf_wm(self):\n        self.low_card_grouped_rolling_udf_wm.execute()\n", "path": "benchmarks/benchmarks.py"}]}