Skip to content

Commit

Permalink
Also test for darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
Smit-create committed Nov 3, 2022
1 parent b3ce842 commit 56ff110
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions quantecon/util/tests/test_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import time
from sys import platform
from numpy.testing import assert_allclose, assert_
from quantecon.util import tic, tac, toc, loop_timer

Expand All @@ -15,9 +14,6 @@ def setup_method(self):
self.digits = 10

def test_timer(self):
if platform == 'darwin':
# skip for darwin
return

tic()

Expand All @@ -30,20 +26,14 @@ def test_timer(self):
time.sleep(self.h)
tm3 = toc()

rtol = 0.1

if platform == 'win32':
# pytest platform specific issue
rtol *= 2
rtol = 0.5
atol = 0.05

for actual, desired in zip([tm1, tm2, tm3],
[self.h, self.h, self.h*3]):
assert_allclose(actual, desired, rtol=rtol)
assert_allclose(actual, desired, atol=atol, rtol=rtol)

def test_loop(self):
if platform == 'darwin':
# skip for darwin
return

def test_function_one_arg(n):
return time.sleep(n)
Expand All @@ -56,15 +46,13 @@ def test_function_two_arg(n, a):
test_two_arg = \
loop_timer(5, test_function_two_arg, [self.h, 1], digits=10)

rtol = 0.1
rtol = 0.5
atol = 0.05

if platform == 'win32':
# pytest platform specific issue
rtol *= 2
for tm in test_one_arg:
assert_allclose(tm, self.h, rtol=rtol)
assert_allclose(tm, self.h, atol=atol, rtol=rtol)
for tm in test_two_arg:
assert_allclose(tm, self.h, rtol=rtol)
assert_allclose(tm, self.h, atol=atol, rtol=rtol)

for (average_time, average_of_best) in [test_one_arg, test_two_arg]:
assert_(average_time >= average_of_best)

0 comments on commit 56ff110

Please sign in to comment.