@@ -248,7 +248,8 @@ def check_operands(left, right, cmp_op):
248
248
for ex in (ex1 , ex2 , ex3 ):
249
249
result = pd .eval (ex , engine = self .engine ,
250
250
parser = self .parser )
251
- tm .assert_numpy_array_equal (result , expected )
251
+
252
+ tm .assert_almost_equal (result , expected )
252
253
253
254
def check_simple_cmp_op (self , lhs , cmp1 , rhs ):
254
255
ex = 'lhs {0} rhs' .format (cmp1 )
@@ -265,7 +266,8 @@ def check_binary_arith_op(self, lhs, arith1, rhs):
265
266
ex = 'lhs {0} rhs' .format (arith1 )
266
267
result = pd .eval (ex , engine = self .engine , parser = self .parser )
267
268
expected = _eval_single_bin (lhs , arith1 , rhs , self .engine )
268
- tm .assert_numpy_array_equal (result , expected )
269
+
270
+ tm .assert_almost_equal (result , expected )
269
271
ex = 'lhs {0} rhs {0} rhs' .format (arith1 )
270
272
result = pd .eval (ex , engine = self .engine , parser = self .parser )
271
273
nlhs = _eval_single_bin (lhs , arith1 , rhs ,
@@ -280,8 +282,10 @@ def check_alignment(self, result, nlhs, ghs, op):
280
282
# TypeError, AttributeError: series or frame with scalar align
281
283
pass
282
284
else :
285
+
286
+ # direct numpy comparison
283
287
expected = self .ne .evaluate ('nlhs {0} ghs' .format (op ))
284
- tm .assert_numpy_array_equal (result , expected )
288
+ tm .assert_numpy_array_equal (result . values , expected )
285
289
286
290
# modulus, pow, and floor division require special casing
287
291
@@ -349,12 +353,12 @@ def check_single_invert_op(self, lhs, cmp1, rhs):
349
353
elb = np .array ([bool (el )])
350
354
expected = ~ elb
351
355
result = pd .eval ('~elb' , engine = self .engine , parser = self .parser )
352
- tm .assert_numpy_array_equal (expected , result )
356
+ tm .assert_almost_equal (expected , result )
353
357
354
358
for engine in self .current_engines :
355
359
tm .skip_if_no_ne (engine )
356
- tm .assert_numpy_array_equal (result , pd .eval ('~elb' , engine = engine ,
357
- parser = self .parser ))
360
+ tm .assert_almost_equal (result , pd .eval ('~elb' , engine = engine ,
361
+ parser = self .parser ))
358
362
359
363
def check_compound_invert_op (self , lhs , cmp1 , rhs ):
360
364
skip_these = 'in' , 'not in'
@@ -374,13 +378,13 @@ def check_compound_invert_op(self, lhs, cmp1, rhs):
374
378
else :
375
379
expected = ~ expected
376
380
result = pd .eval (ex , engine = self .engine , parser = self .parser )
377
- tm .assert_numpy_array_equal (expected , result )
381
+ tm .assert_almost_equal (expected , result )
378
382
379
383
# make sure the other engines work the same as this one
380
384
for engine in self .current_engines :
381
385
tm .skip_if_no_ne (engine )
382
386
ev = pd .eval (ex , engine = self .engine , parser = self .parser )
383
- tm .assert_numpy_array_equal (ev , result )
387
+ tm .assert_almost_equal (ev , result )
384
388
385
389
def ex (self , op , var_name = 'lhs' ):
386
390
return '{0}{1}' .format (op , var_name )
@@ -728,7 +732,7 @@ def check_alignment(self, result, nlhs, ghs, op):
728
732
pass
729
733
else :
730
734
expected = eval ('nlhs {0} ghs' .format (op ))
731
- tm .assert_numpy_array_equal (result , expected )
735
+ tm .assert_almost_equal (result , expected )
732
736
733
737
734
738
class TestEvalPythonPandas (TestEvalPythonPython ):
0 commit comments