Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Fix time errors on windows and numpy warnings #645

Merged
merged 5 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions quantecon/tests/test_lqnash.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ def test_nnash(self):
xbar = tfi.dot(aaa[:2, 2])

# Define answers from matlab. TODO: this is ghetto
f1_ml = np.asarray(np.matrix("""\
0.243666582208565, 0.027236062661951, -6.827882928738190;
0.392370733875639, 0.139696450885998, -37.734107291009138"""))

f2_ml = np.asarray(np.matrix("""\
0.027236062661951, 0.243666582208565, -6.827882928738186;
0.139696450885998, 0.392370733875639, -37.734107291009131"""))
f1_ml = np.array([
[0.243666582208565, 0.027236062661951, -6.827882928738190],
[0.392370733875639, 0.139696450885998, -37.734107291009138]
])

f2_ml = np.array([
[0.027236062661951, 0.243666582208565, -6.827882928738186],
[0.139696450885998, 0.392370733875639, -37.734107291009131]
])

xbar_ml = np.array([1.246871007582702, 1.246871007582685])

Expand Down
21 changes: 10 additions & 11 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,15 +26,14 @@ def test_timer(self):
time.sleep(self.h)
tm3 = toc()

rtol = 0.1
rtol = 2
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 @@ -50,10 +45,14 @@ def test_function_two_arg(n, a):
loop_timer(5, test_function_one_arg, self.h, digits=10)
test_two_arg = \
loop_timer(5, test_function_two_arg, [self.h, 1], digits=10)

rtol = 2
atol = 0.05

for tm in test_one_arg:
assert(abs(tm - self.h) < 0.01), tm
assert_allclose(tm, self.h, atol=atol, rtol=rtol)
for tm in test_two_arg:
assert(abs(tm - self.h) < 0.01), tm
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)