|
9 | 9 | "unicode": tm.makeUnicodeIndex(100),
|
10 | 10 | "string": tm.makeStringIndex(100),
|
11 | 11 | "datetime": tm.makeDateIndex(100),
|
| 12 | + "localized-datetime": tm.makeDateIndex(100, tz="US/Eastern"), |
12 | 13 | "period": tm.makePeriodIndex(100),
|
13 | 14 | "timedelta": tm.makeTimedeltaIndex(100),
|
14 | 15 | "int": tm.makeIntIndex(100),
|
15 | 16 | "uint": tm.makeUIntIndex(100),
|
16 | 17 | "range": tm.makeRangeIndex(100),
|
17 | 18 | "float": tm.makeFloatIndex(100),
|
18 |
| - "bool": Index([True, False]), |
| 19 | + "bool": tm.makeBoolIndex(2), |
19 | 20 | "categorical": tm.makeCategoricalIndex(100),
|
20 | 21 | "interval": tm.makeIntervalIndex(100),
|
21 | 22 | "empty": Index([]),
|
@@ -50,3 +51,48 @@ def zero(request):
|
50 | 51 | # For testing division by (or of) zero for Index with length 5, this
|
51 | 52 | # gives several scalar-zeros and length-5 vector-zeros
|
52 | 53 | return request.param
|
| 54 | + |
| 55 | + |
| 56 | +_series = { |
| 57 | + f"series-with-{i_id}-index": pd.Series( |
| 58 | + np.random.randn(len(i)), index=i, name=i.name |
| 59 | + ) |
| 60 | + for i_id, i in indices_dict.items() |
| 61 | +} |
| 62 | + |
| 63 | + |
| 64 | +def _create_narrow_series(data_dtype): |
| 65 | + """ Helper for the _narrow_series dict """ |
| 66 | + index = indices_dict["int"].copy() |
| 67 | + size = len(index) |
| 68 | + if np.issubdtype(data_dtype, np.float): |
| 69 | + data = np.random.choice(size, size=size, replace=False) |
| 70 | + elif np.issubdtype(data_dtype, np.integer): |
| 71 | + data = np.random.randn(size) |
| 72 | + else: |
| 73 | + raise ValueError(f"Received an unexpected data_dtype: {data_dtype}") |
| 74 | + |
| 75 | + return pd.Series(data.astype(data_dtype), index=index, name="a") |
| 76 | + |
| 77 | + |
| 78 | +_narrow_series = { |
| 79 | + "float32-series": _create_narrow_series(np.float32), |
| 80 | + "int8-series": _create_narrow_series(np.int8), |
| 81 | + "int16-series": _create_narrow_series(np.int16), |
| 82 | + "int32-series": _create_narrow_series(np.int32), |
| 83 | + "uint8-series": _create_narrow_series(np.uint8), |
| 84 | + "uint16-series": _create_narrow_series(np.uint16), |
| 85 | + "uint32-series": _create_narrow_series(np.uint32), |
| 86 | +} |
| 87 | + |
| 88 | +_all_objs = {**indices_dict, **_series, **_narrow_series} |
| 89 | + |
| 90 | + |
| 91 | +@pytest.fixture(params=_all_objs.keys()) |
| 92 | +def index_or_series_obj(request): |
| 93 | + """ |
| 94 | + Fixture for tests on indexes, series and series with a narrow dtype |
| 95 | +
|
| 96 | + copy to avoid mutation, e.g. setting .name |
| 97 | + """ |
| 98 | + return _all_objs[request.param].copy(deep=True) |
0 commit comments