Esempio n. 1
0
 def run_binary_test(self, df, other, assert_func, test_flex=False,
                     numexpr_ops=set(['gt', 'lt', 'ge', 'le', 'eq', 'ne'])):
     """
     tests solely that the result is the same whether or not numexpr is
     enabled.  Need to test whether the function does the correct thing
     elsewhere.
     """
     expr._MIN_ELEMENTS = 0
     expr.set_test_mode(True)
     operations = ['gt', 'lt', 'ge', 'le', 'eq', 'ne']
     for arith in operations:
         if test_flex:
             op = lambda x, y: getattr(df, arith)(y)
             op.__name__ = arith
         else:
             op = getattr(operator, arith)
         expr.set_use_numexpr(False)
         expected = op(df, other)
         expr.set_use_numexpr(True)
         expr.get_test_result()
         result = op(df, other)
         used_numexpr = expr.get_test_result()
         try:
             if arith in numexpr_ops:
                 assert used_numexpr, "Did not use numexpr as expected."
             else:
                 assert not used_numexpr, "Used numexpr unexpectedly."
             assert_func(expected, result)
         except Exception:
             pprint_thing("Failed test with operation %r" % arith)
             pprint_thing("test_flex was %r" % test_flex)
             raise
Esempio n. 2
0
 def run_binary_test(self, df, other, assert_func, test_flex=False,
                     numexpr_ops=set(['gt', 'lt', 'ge', 'le', 'eq', 'ne'])):
     """
     tests solely that the result is the same whether or not numexpr is
     enabled.  Need to test whether the function does the correct thing
     elsewhere.
     """
     expr._MIN_ELEMENTS = 0
     expr.set_test_mode(True)
     operations = ['gt', 'lt', 'ge', 'le', 'eq', 'ne']
     for arith in operations:
         if test_flex:
             op = lambda x, y: getattr(df, arith)(y)
             op.__name__ = arith
         else:
             op = getattr(operator, arith)
         expr.set_use_numexpr(False)
         expected = op(df, other)
         expr.set_use_numexpr(True)
         expr.get_test_result()
         result = op(df, other)
         used_numexpr = expr.get_test_result()
         try:
             if arith in numexpr_ops:
                 assert used_numexpr, "Did not use numexpr as expected."
             else:
                 assert not used_numexpr, "Used numexpr unexpectedly."
             assert_func(expected, result)
         except Exception:
             com.pprint_thing("Failed test with operation %r" % arith)
             com.pprint_thing("test_flex was %r" % test_flex)
             raise