|
1 | 1 | import numpy as np
|
2 | 2 | from pandas import DataFrame, Series, date_range
|
| 3 | +from pandas.core.algorithms import checked_add_with_arr |
3 | 4 | try:
|
4 | 5 | import pandas.core.computation.expressions as expr
|
5 | 6 | except ImportError:
|
@@ -108,3 +109,46 @@ def time_timestamp_ops_diff(self, tz):
|
108 | 109 |
|
109 | 110 | def time_timestamp_ops_diff_with_shift(self, tz):
|
110 | 111 | self.s - self.s.shift()
|
| 112 | + |
| 113 | + |
| 114 | +class AddOverflowScalar(object): |
| 115 | + |
| 116 | + goal_time = 0.2 |
| 117 | + |
| 118 | + params = [1, -1, 0] |
| 119 | + param_names = ['scalar'] |
| 120 | + |
| 121 | + def setup(self, scalar): |
| 122 | + N = 10**6 |
| 123 | + self.arr = np.arange(N) |
| 124 | + |
| 125 | + def time_add_overflow_scalar(self, scalar): |
| 126 | + checked_add_with_arr(self.arr, scalar) |
| 127 | + |
| 128 | + |
| 129 | +class AddOverflowArray(object): |
| 130 | + |
| 131 | + goal_time = 0.2 |
| 132 | + |
| 133 | + def setup(self): |
| 134 | + np.random.seed(1234) |
| 135 | + N = 10**6 |
| 136 | + self.arr = np.arange(N) |
| 137 | + self.arr_rev = np.arange(-N, 0) |
| 138 | + self.arr_mixed = np.array([1, -1]).repeat(N / 2) |
| 139 | + self.arr_nan_1 = np.random.choice([True, False], size=N) |
| 140 | + self.arr_nan_2 = np.random.choice([True, False], size=N) |
| 141 | + |
| 142 | + def time_add_overflow_arr_rev(self): |
| 143 | + checked_add_with_arr(self.arr, self.arr_rev) |
| 144 | + |
| 145 | + def time_add_overflow_arr_mask_nan(self): |
| 146 | + checked_add_with_arr(self.arr, self.arr_mixed, arr_mask=self.arr_nan_1) |
| 147 | + |
| 148 | + def time_add_overflow_b_mask_nan(self): |
| 149 | + checked_add_with_arr(self.arr, self.arr_mixed, |
| 150 | + b_mask=self.arr_nan_1) |
| 151 | + |
| 152 | + def time_add_overflow_both_arg_nan(self): |
| 153 | + checked_add_with_arr(self.arr, self.arr_mixed, arr_mask=self.arr_nan_1, |
| 154 | + b_mask=self.arr_nan_2) |
0 commit comments