-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Description
I am testing pandas 0.13 (built against numexpr 2.2.2, numpy 1.8.0, scipy 0.13.2, all linked to MKL 10.3 using Scientific Linux 6.4's stock gcc 4.7.4), and test_pow fails with an array not equal error:
FAIL: test_pow (pandas.computation.tests.test_eval.TestEvalNumexprPandas)
Traceback (most recent call last):
File "/software/python-2.7-2014q1-el6-x86_64/lib/python2.7/site-packages/pandas/computation/tests/test_eval.py", line 192, in test_pow
self.check_pow(lhs, '*_', rhs)
File "/software/python-2.7-2014q1-el6-x86_64/lib/python2.7/site-packages/pandas/computation/tests/test_eval.py", line 94, in wrapper
f(self, lhs, arith1, rhs, *args, *_kwargs)
File "/software/python-2.7-2014q1-el6-x86_64/lib/python2.7/site-packages/pandas/computation/tests/test_eval.py", line 408, in check_pow
assert_array_equal(result, expected)
File "/software/python-2.7-2014q1-el6-x86_64/lib/python2.7/site-packages/numpy/testing/utils.py", line 718, in assert_array_equal
verbose=verbose, header='Arrays are not equal')
File "/software/python-2.7-2014q1-el6-x86_64/lib/python2.7/site-packages/numpy/testing/utils.py", line 644, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not equal
(mismatch 25.8064516129%)
x: array([[ 6.98492548e-01, 5.39900967e-01, 1.87991705e+00,
7.67724670e-01, nan],
[ nan, 1.18493281e+00, 4.15163610e+01,...
y: array([[ 6.98492548e-01, 5.39900967e-01, 1.87991705e+00,
7.67724670e-01, nan],
[ nan, 1.18493281e+00, 4.15163610e+01,...
I have modified the check_pow function in that test to identify the error and print out the difference in result and expected:
@skip_incompatible_operand
def check_pow(self, lhs, arith1, rhs):
ex = 'lhs {0} rhs'.format(arith1)
expected = self.get_expected_pow_result(lhs, rhs)
result = pd.eval(ex, engine=self.engine, parser=self.parser)
if (np.isscalar(lhs) and np.isscalar(rhs) and
_is_py3_complex_incompat(result, expected)):
self.assertRaises(AssertionError, assert_array_equal, result,
expected)
else:
print result, expected, result-expected
assert_array_equal(result, expected,verbose=True)
ex = '(lhs {0} rhs) {0} rhs'.format(arith1)
result = pd.eval(ex, engine=self.engine, parser=self.parser)
expected = self.get_expected_pow_result(
self.get_expected_pow_result(lhs, rhs), rhs)
print result, expected, result-expected
assert_array_equal(result, expected)
Which yields the following (only differences reported for brevity):
[10 rows x 5 columns] 0 1 2 3 4
0 -2.775558e-17 NaN 0.000000e+00 -2.220446e-16 0.000000e+00
1 0.000000e+00 1.110223e-16 NaN NaN NaN
2 0.000000e+00 NaN NaN NaN NaN
3 0.000000e+00 NaN NaN 0.000000e+00 0.000000e+00
4 NaN 0.000000e+00 1.110223e-16 0.000000e+00 2.220446e-16
5 NaN -1.110223e-16 -5.551115e-17 0.000000e+00 0.000000e+00
6 NaN NaN 0.000000e+00 NaN -4.440892e-16
7 -1.110223e-16 NaN NaN 3.552714e-15 NaN
8 NaN 0.000000e+00 0.000000e+00 NaN 2.220446e-16
9 0.000000e+00 0.000000e+00 NaN 0.000000e+00 0.000000e+00
and
[10 rows x 5 columns] 0 1 2 3 4
0 0.000000e+00 NaN 0.000000e+00 0.000000e+00 0.000000e+00
1 0.000000e+00 1.110223e-16 NaN NaN NaN
2 2.220446e-16 NaN NaN NaN NaN
3 0.000000e+00 NaN NaN 5.551115e-17 0.000000e+00
4 NaN 0.000000e+00 1.110223e-16 0.000000e+00 2.220446e-16
5 NaN -1.110223e-16 0.000000e+00 0.000000e+00 0.000000e+00
6 NaN NaN 0.000000e+00 NaN 1.110223e-16
7 2.220446e-16 NaN NaN -4.336809e-19 NaN
8 NaN 0.000000e+00 0.000000e+00 NaN -1.110223e-16
9 0.000000e+00 1.110223e-16 NaN 0.000000e+00 0.000000e+00
The differences are only at machine precision, and may be due to the use of MKL rather than standard blas (I haven't dug any further). I have verified that changing the test from assert_array_equal to assert_allclose allows the test to succeed.