Skip to content

Commit bffe468

Browse files
author
Laurent Mutricy
committed
updating tests
1 parent f162a38 commit bffe468

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

pandas/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,21 @@ def complex_dtype(request):
14481448
return request.param
14491449

14501450

1451+
@pytest.fixture(params=tm.COMPLEX_DTYPES + tm.FLOAT_NUMPY_DTYPES)
1452+
def complex_or_float_dtype(request):
1453+
"""
1454+
Parameterized fixture for complex and numpy float dtypes.
1455+
1456+
* complex
1457+
* 'complex64'
1458+
* 'complex128'
1459+
* float
1460+
* 'float32'
1461+
* 'float64'
1462+
"""
1463+
return request.param
1464+
1465+
14511466
@pytest.fixture(params=tm.SIGNED_INT_NUMPY_DTYPES)
14521467
def any_signed_int_numpy_dtype(request):
14531468
"""

pandas/core/computation/ops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from pandas.core.dtypes.common import (
2020
is_list_like,
21-
is_numeric_dtype,
2221
is_scalar,
2322
)
2423

pandas/tests/computation/test_eval.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -758,16 +758,25 @@ class TestTypeCasting:
758758
# maybe someday... numexpr has too many upcasting rules now
759759
# chain(*(np.core.sctypes[x] for x in ['uint', 'int', 'float']))
760760
@pytest.mark.parametrize("left_right", [("df", "3"), ("3", "df")])
761-
def test_binop_typecasting(self, engine, parser, op, float_numpy_dtype, left_right):
762-
df = DataFrame(
763-
np.random.default_rng(2).standard_normal((5, 3)), dtype=float_numpy_dtype
764-
)
761+
def test_binop_typecasting(
762+
self, engine, parser, op, complex_or_float_dtype, left_right, request
763+
):
764+
# GH#21374
765+
dtype = complex_or_float_dtype
766+
df = DataFrame(np.random.default_rng(2).standard_normal((5, 3)), dtype=dtype)
765767
left, right = left_right
766768
s = f"{left} {op} {right}"
767769
res = pd.eval(s, engine=engine, parser=parser)
768-
assert df.values.dtype == float_numpy_dtype
769-
assert res.values.dtype == float_numpy_dtype
770-
tm.assert_frame_equal(res, eval(s))
770+
if dtype == "complex64" and engine == "numexpr":
771+
mark = pytest.mark.xfail(
772+
reason="numexpr issue with complex that are upcast "
773+
"to complex 128 "
774+
"https://github.com/pydata/numexpr/issues/492"
775+
)
776+
request.node.add_marker(mark)
777+
assert df.values.dtype == dtype
778+
assert res.values.dtype == dtype
779+
tm.assert_frame_equal(res, eval(s), check_exact=False)
771780

772781

773782
# -------------------------------------

pandas/tests/frame/test_query_eval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def test_extension_array_eval(self, engine, parser):
206206
# GH#58748
207207
df = DataFrame({"a": pd.array([1, 2, 3]), "b": pd.array([4, 5, 6])})
208208
result = df.eval("a / b", engine=engine, parser=parser)
209-
expected = Series([0.25, 0.40, 0.50])
209+
expected = Series(pd.array([0.25, 0.40, 0.50]))
210210
tm.assert_series_equal(result, expected)
211211

212212

0 commit comments

Comments
 (0)