Closed lukeolson closed 5 years ago
Hm, interesting. It definitely should not take that long. Wonder if it is a mac-related thing. I never run the code on Windows or mac. I can relax the rtol I guess.
Would you mind testing one thing? What happens if you swap the two lines
t0 = utils.timeit() time = utils.Time()
to
time = utils.Time() t0 = utils.timeit()
Maybe creating the Time-instance takes to long?
On 13 June 2019 17:42:49 CEST, Luke Olson notifications@github.com wrote:
I'm seeing a test failure most of the time (like 9 out of 10). It looks like successive times is around 1e-5 for me, which is triggering the assert. It's not clear why it's so large.>
(emg3d1) ± pytest .> ================================ test session starts =================================> platform darwin -- Python 3.7.3, pytest-4.6.3, py-1.8.0, pluggy-0.12.0> plugins: cov-2.7.1> collected 28 items tests/test_njitted.py ...... [ 21%]> tests/test_solver.py ........ [ 50%]> tests/test_utils.py ........F..... [100%]> ====================================== FAILURES ======================================> _____________________________________ test_Time ______________________________________> def test_Time():> t0 = utils.timeit() # Create almost at the same time a> time = utils.Time() # t0-stamp and a Time-instance.> assert_allclose(t0, time.t0)> E AssertionError: > E Not equal to tolerance rtol=1e-07, atol=0> E > E Mismatch: 100%> E Max absolute difference: 1.493e-06> E Max relative difference: 3.3439148e-07> E x: array(4.464825)> E y: array(4.464827)> tests/test_utils.py:383: AssertionError> ======================== 1 failed, 27 passed in 5.43 seconds =========================> ```> ```> In [18]: t1=emg3d.utils.timeit();t2=emg3d.utils.timeit();print(t1,t2,t2-t1) 81.447158438 81.447194455 3.6016999999333166e-05> ```> -- > You are receiving this because you are subscribed to this thread.> Reply to this email directly or view it on GitHub:> https://github.com/empymod/emg3d/issues/13
Ok here it is ... no diff:
t0 = emg3d.utils.timeit()
time = emg3d.utils.Time()
print(t0, time.t0, t0-time.t0)
153.729586209 153.729616075 -2.9866000005540627e-05
time = emg3d.utils.Time()
t0 = emg3d.utils.timeit()
print(t0, time.t0, time.t0-t0)
175.297739731 175.297710666 2.906500000676715e-05
Now if I just time the timing instance I get something on the order of 1e-7:
%timeit time = emg3d.utils.Time()
383 ns ± 4.38 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
%timeit t0 = emg3d.utils.timeit()
212 ns ± 3.83 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
I pushed a fix for this (setting atol=1e-3
, hence milliseconds). Only in the master branch for now, but it will be in the final release for the JOSS journal. Thanks for bringing this to my attention!
I'm seeing a test failure most of the time (like 9 out of 10). It looks like successive times is around 1e-5 for me, which is triggering the assert. It's not clear why it's so large.