提交 15f3621e authored 作者: nouiz's avatar nouiz

Merge pull request #975 from lamblin/expand_home

Expand ~ in base_compiledir and compiledir.
......@@ -58,7 +58,14 @@ def default_compiledirname():
return safe
def filter_base_compiledir(path):
# Expand '~' in path
return os.path.expanduser(str(path))
def filter_compiledir(path):
# Expand '~' in path
path = os.path.expanduser(path)
# Turn path into the 'real' path. This ensures that:
# 1. There is no relative path, which would fail e.g. when trying to
# import modules from the compile dir.
......@@ -119,13 +126,16 @@ else:
AddConfigVar('base_compiledir',
"platform-independent root directory for compiled modules",
StrParam(default_base_compiledir, allow_override=False))
ConfigParam(
default_base_compiledir,
filter=filter_base_compiledir,
allow_override=False))
AddConfigVar('compiledir',
"platform-dependent cache directory for compiled modules",
ConfigParam(
os.path.join(
os.path.expanduser(config.base_compiledir),
config.base_compiledir,
default_compiledirname()),
filter=filter_compiledir,
allow_override=False))
......
......@@ -9,7 +9,7 @@ class T_load_tensor(unittest.TestCase):
def test0(self):
data = numpy.arange(5, dtype=numpy.int32)
filename = os.path.join(
os.path.expanduser(theano.config.base_compiledir),
theano.config.base_compiledir,
"_test.npy")
numpy.save(filename, data)
path = Variable(Generic())
......@@ -21,7 +21,7 @@ class T_load_tensor(unittest.TestCase):
def test_memmap(self):
data = numpy.arange(5, dtype=numpy.int32)
filename = os.path.join(
os.path.expanduser(theano.config.base_compiledir),
theano.config.base_compiledir,
"_test.npy")
numpy.save(filename, data)
path = Variable(Generic())
......@@ -31,5 +31,5 @@ class T_load_tensor(unittest.TestCase):
def tearDown(self):
os.remove(os.path.join(
os.path.expanduser(theano.config.base_compiledir),
theano.config.base_compiledir,
"_test.npy"))
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论