Skip to content

Commit 5a7d2b5

Browse files
jbrockmendeljreback
authored andcommitted
Implement arithmetic.test_numeric and arithmetic.test_object (#22254)
1 parent 3bcc2bb commit 5a7d2b5

File tree

10 files changed

+1269
-1180
lines changed

10 files changed

+1269
-1180
lines changed

pandas/tests/arithmetic/conftest.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,49 @@
44
import numpy as np
55
import pandas as pd
66

7+
from pandas.compat import long
8+
79

810
@pytest.fixture(params=[1, np.array(1, dtype=np.int64)])
911
def one(request):
1012
# zero-dim integer array behaves like an integer
1113
return request.param
1214

1315

16+
zeros = [box_cls([0] * 5, dtype=dtype)
17+
for box_cls in [pd.Index, np.array]
18+
for dtype in [np.int64, np.uint64, np.float64]]
19+
zeros.extend([np.array(0, dtype=dtype)
20+
for dtype in [np.int64, np.uint64, np.float64]])
21+
zeros.extend([0, 0.0, long(0)])
22+
23+
24+
@pytest.fixture(params=zeros)
25+
def zero(request):
26+
# For testing division by (or of) zero for Index with length 5, this
27+
# gives several scalar-zeros and length-5 vector-zeros
28+
return request.param
29+
30+
31+
@pytest.fixture(params=[pd.Float64Index(np.arange(5, dtype='float64')),
32+
pd.Int64Index(np.arange(5, dtype='int64')),
33+
pd.UInt64Index(np.arange(5, dtype='uint64'))],
34+
ids=lambda x: type(x).__name__)
35+
def idx(request):
36+
return request.param
37+
38+
39+
@pytest.fixture(params=[pd.Timedelta('5m4s').to_pytimedelta(),
40+
pd.Timedelta('5m4s'),
41+
pd.Timedelta('5m4s').to_timedelta64()],
42+
ids=lambda x: type(x).__name__)
43+
def scalar_td(request):
44+
"""
45+
Several variants of Timedelta scalars representing 5 minutes and 4 seconds
46+
"""
47+
return request.param
48+
49+
1450
# ------------------------------------------------------------------
1551

1652
@pytest.fixture(params=[pd.Index, pd.Series, pd.DataFrame],

0 commit comments

Comments
 (0)