Skip to content

Commit a0b3a51

Browse files
committed
Fix test
1 parent f0338ab commit a0b3a51

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pandas/computation/tests/test_eval.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -1481,23 +1481,29 @@ def test_binary_functions(self):
14811481
def test_df_use_case(self):
14821482
df = DataFrame({'a': np.random.randn(10),
14831483
'b': np.random.randn(10)})
1484-
df.eval("e = arctan2(sin(a), b)")
1484+
df.eval("e = arctan2(sin(a), b)",
1485+
engine=self.engine,
1486+
parser=self.parser)
14851487
got = df.e
14861488
expect = np.arctan2(np.sin(df.a), df.b)
14871489
pd.util.testing.assert_almost_equal(got, expect)
14881490

14891491
def test_df_arithmetic_subexpression(self):
14901492
df = DataFrame({'a': np.random.randn(10),
14911493
'b': np.random.randn(10)})
1492-
df.eval("e = sin(a + b)")
1494+
df.eval("e = sin(a + b)",
1495+
engine=self.engine,
1496+
parser=self.parser)
14931497
got = df.e
14941498
expect = np.sin(df.a + df.b)
14951499
pd.util.testing.assert_almost_equal(got, expect)
14961500

14971501
def check_result_type(self, dtype, expect_dtype):
14981502
df = DataFrame({'a': np.random.randn(10).astype(dtype)})
14991503
self.assertEqual(df.a.dtype, dtype)
1500-
df.eval("b = sin(a)")
1504+
df.eval("b = sin(a)",
1505+
engine=self.engine,
1506+
parser=self.parser)
15011507
got = df.b
15021508
expect = np.sin(df.a)
15031509
self.assertEqual(expect.dtype, got.dtype)
@@ -1510,9 +1516,15 @@ def test_result_types(self):
15101516
self.check_result_type(np.float32, np.float32)
15111517
self.check_result_type(np.float64, np.float64)
15121518
# Did not test complex64 because DataFrame is converting it to
1513-
# complex128
1519+
# complex128. Due to https://github.com/pydata/pandas/issues/10952
15141520
self.check_result_type(np.complex128, np.complex128)
15151521

1522+
def test_undefined_func(self):
1523+
df = DataFrame({'a': np.random.randn(10)})
1524+
with tm.assertRaises(ValueError):
1525+
df.eval("mysin(a)",
1526+
engine=self.engine,
1527+
parser=self.parser)
15161528

15171529
class TestMathPythonPandas(TestMathPythonPython):
15181530
@classmethod

0 commit comments

Comments
 (0)