提交 57864f52 authored 作者: Michael Osthege's avatar Michael Osthege 提交者: Brandon T. Willard

Move cmodule-related config registration to tests.gof.cmodule

This untangles the `theano.configdefaults` module from the `theano.gof` sub-package, thereby removing an import cycle. Closes #94
上级 ec994f62
...@@ -5,11 +5,13 @@ But this one tests a current behavior that isn't good: the c_code isn't ...@@ -5,11 +5,13 @@ But this one tests a current behavior that isn't good: the c_code isn't
deterministic based on the input type and the op. deterministic based on the input type and the op.
""" """
import logging
from unittest.mock import patch
import numpy as np import numpy as np
import theano import theano
from theano.gof.cmodule import GCC_compiler from theano.gof.cmodule import GCC_compiler, default_blas_ldflags
class MyOp(theano.compile.ops.DeepCopyOp): class MyOp(theano.compile.ops.DeepCopyOp):
...@@ -68,3 +70,16 @@ def test_flag_detection(): ...@@ -68,3 +70,16 @@ def test_flag_detection():
# but was not detected because that path is not usually taken, # but was not detected because that path is not usually taken,
# so we test it here directly. # so we test it here directly.
GCC_compiler.try_flags(["-lblas"]) GCC_compiler.try_flags(["-lblas"])
@patch("theano.gof.cmodule.try_blas_flag", return_value=None)
@patch("theano.gof.cmodule.sys")
def test_default_blas_ldflags(sys_mock, try_blas_flag_mock, caplog):
sys_mock.version = "3.8.0 | packaged by conda-forge | (default, Nov 22 2019, 19:11:38) \n[GCC 7.3.0]"
with patch.dict("sys.modules", {"mkl": None}):
with caplog.at_level(logging.WARNING):
default_blas_ldflags()
assert "install mkl with" in caplog.text
"""Test config options.""" """Test config options."""
import configparser as stdlib_configparser import configparser as stdlib_configparser
import logging
from unittest.mock import patch
import pytest import pytest
from theano import configdefaults, configparser from theano import configdefaults, configparser
from theano.configdefaults import default_blas_ldflags, short_platform from theano.configdefaults import short_platform
from theano.configparser import ConfigParam from theano.configparser import ConfigParam
...@@ -287,15 +285,3 @@ class TestConfigHelperFunctions: ...@@ -287,15 +285,3 @@ class TestConfigHelperFunctions:
def test_short_platform(self, release, platform, answer): def test_short_platform(self, release, platform, answer):
o = short_platform(release, platform) o = short_platform(release, platform)
assert o == answer, (o, answer) assert o == answer, (o, answer)
@patch("theano.configdefaults.try_blas_flag", return_value=None)
@patch("theano.configdefaults.sys")
def test_default_blas_ldflags(self, sys_mock, try_blas_flag_mock, caplog):
sys_mock.version = "3.8.0 | packaged by conda-forge | (default, Nov 22 2019, 19:11:38) \n[GCC 7.3.0]"
with patch.dict("sys.modules", {"mkl": None}):
with caplog.at_level(logging.WARNING):
default_blas_ldflags()
assert "install mkl with" in caplog.text
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论