11#!/usr/bin/env python
22
3- import functools
43from itertools import product
54from distutils .version import LooseVersion
65
76import nose
8- from nose .tools import assert_raises , assert_true , assert_false , assert_equal
7+ from nose .tools import assert_raises
98
109from numpy .random import randn , rand , randint
1110import numpy as np
@@ -887,7 +886,7 @@ def check_complex_series_frame_alignment(self, engine, parser):
887886 expected = expected2 + df
888887
889888 res = pd .eval ('df2 + s + df' , engine = engine , parser = parser )
890- assert_equal (res .shape , expected .shape )
889+ tm . assert_equal (res .shape , expected .shape )
891890 assert_frame_equal (res , expected )
892891
893892 @slow
@@ -930,13 +929,13 @@ def check_performance_warning_for_poor_alignment(self, engine, parser):
930929 pd .eval ('df + s' , engine = engine , parser = parser )
931930
932931 if not is_python_engine :
933- assert_equal (len (w ), 1 )
932+ tm . assert_equal (len (w ), 1 )
934933 msg = str (w [0 ].message )
935934 expected = ("Alignment difference on axis {0} is larger"
936935 " than an order of magnitude on term {1!r}, "
937936 "by more than {2:.4g}; performance may suffer"
938937 "" .format (1 , 'df' , np .log10 (s .size - df .shape [1 ])))
939- assert_equal (msg , expected )
938+ tm . assert_equal (msg , expected )
940939
941940 def test_performance_warning_for_poor_alignment (self ):
942941 for engine , parser in ENGINES_PARSERS :
@@ -982,17 +981,17 @@ def test_simple_arith_ops(self):
982981 else :
983982 expec = _eval_single_bin (1 , op , 1 , self .engine )
984983 x = self .eval (ex , engine = self .engine , parser = self .parser )
985- assert_equal (x , expec )
984+ tm . assert_equal (x , expec )
986985
987986 expec = _eval_single_bin (x , op , 1 , self .engine )
988987 y = self .eval (ex2 , local_dict = {'x' : x }, engine = self .engine ,
989988 parser = self .parser )
990- assert_equal (y , expec )
989+ tm . assert_equal (y , expec )
991990
992991 expec = _eval_single_bin (1 , op , x + 1 , self .engine )
993992 y = self .eval (ex3 , local_dict = {'x' : x },
994993 engine = self .engine , parser = self .parser )
995- assert_equal (y , expec )
994+ tm . assert_equal (y , expec )
996995
997996 def test_simple_bool_ops (self ):
998997 for op , lhs , rhs in product (expr ._bool_ops_syms , (True , False ),
@@ -1024,7 +1023,7 @@ def test_4d_ndarray_fails(self):
10241023
10251024 def test_constant (self ):
10261025 x = self .eval ('1' )
1027- assert_equal (x , 1 )
1026+ tm . assert_equal (x , 1 )
10281027
10291028 def test_single_variable (self ):
10301029 df = DataFrame (randn (10 , 2 ))
@@ -1379,7 +1378,7 @@ def check_no_new_locals(self, engine, parser):
13791378 pd .eval ('x + 1' , local_dict = lcls , engine = engine , parser = parser )
13801379 lcls2 = locals ().copy ()
13811380 lcls2 .pop ('lcls' )
1382- assert_equal (lcls , lcls2 )
1381+ tm . assert_equal (lcls , lcls2 )
13831382
13841383 def test_no_new_locals (self ):
13851384 for engine , parser in product (_engines , expr ._parsers ):
@@ -1391,7 +1390,7 @@ def check_no_new_globals(self, engine, parser):
13911390 gbls = globals ().copy ()
13921391 pd .eval ('x + 1' , engine = engine , parser = parser )
13931392 gbls2 = globals ().copy ()
1394- assert_equal (gbls , gbls2 )
1393+ tm . assert_equal (gbls , gbls2 )
13951394
13961395 def test_no_new_globals (self ):
13971396 for engine , parser in product (_engines , expr ._parsers ):
@@ -1556,14 +1555,27 @@ def check_bool_ops_fails_on_scalars(gen, lhs, cmp, rhs, engine, parser):
15561555def test_bool_ops_fails_on_scalars ():
15571556 _bool_ops_syms = 'and' , 'or'
15581557 dtypes = int , float
1559- gen = {int : lambda : np .random .randint (10 ), float : np .random .randn }
1558+ gen = {int : lambda : np .random .randint (10 ), float : np .random .randn }
15601559 for engine , parser , dtype1 , cmp , dtype2 in product (_engines , expr ._parsers ,
15611560 dtypes , _bool_ops_syms ,
15621561 dtypes ):
15631562 yield (check_bool_ops_fails_on_scalars , gen , gen [dtype1 ](), cmp ,
15641563 gen [dtype2 ](), engine , parser )
15651564
15661565
1566+ def check_inf (engine , parser ):
1567+ tm .skip_if_no_ne (engine )
1568+ s = 'inf + 1'
1569+ expected = np .inf
1570+ result = pd .eval (s , engine = engine , parser = parser )
1571+ tm .assert_equal (result , expected )
1572+
1573+
1574+ def test_inf ():
1575+ for engine , parser in ENGINES_PARSERS :
1576+ yield check_inf , engine , parser
1577+
1578+
15671579if __name__ == '__main__' :
15681580 nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
15691581 exit = False )
0 commit comments