assert_almost_equal / equals should allow access to np.allclose · Issue #9457 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@rockg

Description

@rockg

I am testing the equivalence of two large DataFrames (9084x367). The two are the same up to 1x10-13 but when np.array_equal fails there is a much slower code path (comparing these two frames takes upwards of 20 seconds). If I'm not mistaken, if the arrays aren't equivalent it does a more complicated version of np.allclose. I think a good intermediate step would be to check for array equivalence and then as a the second step call np.allclose--or maybe just do this on the outset. If that fails, which it will if there are any NaNs or if the tolerance is not met, then it will use the current logic. Or we could use np.isclose to consider NaNs as equivalent.

https://github.com/pydata/pandas/blob/master/pandas/src/testing.pyx#L85