Skip to content

Commit 0d34af2

Browse files
Fix mkl warning in default_blas_ldflags
1 parent d660ea7 commit 0d34af2

File tree

2 files changed

+47
-32
lines changed

2 files changed

+47
-32
lines changed

tests/test_config.py

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,60 @@
11
"""
22
Test config options.
33
"""
4+
import logging
5+
from unittest.mock import patch
46

7+
from theano.configdefaults import default_blas_ldflags
58
from theano.configparser import THEANO_FLAGS_DICT, AddConfigVar, ConfigParam
69

710

8-
class TestConfig:
9-
def test_invalid_default(self):
10-
# Ensure an invalid default value found in the Theano code only causes
11-
# a crash if it is not overridden by the user.
12-
13-
def filter(val):
14-
if val == "invalid":
15-
raise ValueError()
16-
else:
17-
return val
18-
19-
try:
20-
# This should raise a ValueError because the default value is
21-
# invalid.
22-
AddConfigVar(
23-
"T_config.test_invalid_default_a",
24-
doc="unittest",
25-
configparam=ConfigParam("invalid", filter=filter),
26-
in_c_key=False,
27-
)
28-
raise AssertionError()
29-
except ValueError:
30-
pass
31-
32-
THEANO_FLAGS_DICT["T_config.test_invalid_default_b"] = "ok"
33-
# This should succeed since we defined a proper value, even
34-
# though the default was invalid.
11+
def test_invalid_default():
12+
# Ensure an invalid default value found in the Theano code only causes
13+
# a crash if it is not overridden by the user.
14+
15+
def filter(val):
16+
if val == "invalid":
17+
raise ValueError()
18+
else:
19+
return val
20+
21+
try:
22+
# This should raise a ValueError because the default value is
23+
# invalid.
3524
AddConfigVar(
36-
"T_config.test_invalid_default_b",
25+
"T_config.test_invalid_default_a",
3726
doc="unittest",
3827
configparam=ConfigParam("invalid", filter=filter),
3928
in_c_key=False,
4029
)
30+
raise AssertionError()
31+
except ValueError:
32+
pass
33+
34+
THEANO_FLAGS_DICT["T_config.test_invalid_default_b"] = "ok"
35+
# This should succeed since we defined a proper value, even
36+
# though the default was invalid.
37+
AddConfigVar(
38+
"T_config.test_invalid_default_b",
39+
doc="unittest",
40+
configparam=ConfigParam("invalid", filter=filter),
41+
in_c_key=False,
42+
)
43+
44+
# Check that the flag has been removed
45+
assert "T_config.test_invalid_default_b" not in THEANO_FLAGS_DICT
46+
47+
# TODO We should remove these dummy options on test exit.
48+
49+
50+
@patch("theano.configdefaults.try_blas_flag", return_value=None)
51+
@patch("theano.configdefaults.sys")
52+
def test_default_blas_ldflags(sys_mock, try_blas_flag_mock, caplog):
53+
54+
sys_mock.version = "3.8.0 | packaged by conda-forge | (default, Nov 22 2019, 19:11:38) \n[GCC 7.3.0]"
4155

42-
# Check that the flag has been removed
43-
assert "T_config.test_invalid_default_b" not in THEANO_FLAGS_DICT
56+
with patch.dict("sys.modules", {"mkl": None}):
57+
with caplog.at_level(logging.WARNING):
58+
default_blas_ldflags()
4459

45-
# TODO We should remove these dummy options on test exit.
60+
assert "install mkl with" in caplog.text

theano/configdefaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,7 @@ def default_blas_ldflags():
18351835
# the fallback and test -lblas could give slow computation, so
18361836
# warn about this.
18371837
for warn in warn_record:
1838-
_logger.warning(*warn)
1838+
_logger.warning(warn)
18391839
del warn_record
18401840

18411841
# Some environment don't have the lib dir in LD_LIBRARY_PATH.

0 commit comments

Comments
 (0)