提交 e697280a authored 作者: Frederic's avatar Frederic

pep8

上级 ac7c37a3
......@@ -30,10 +30,10 @@ def good_seed_param(seed):
return True
AddConfigVar('unittests.rseed',
"Seed to use for randomized unit tests. "
"Special value 'random' means using a seed of None.",
StrParam(666, is_valid=good_seed_param),
in_c_key=False)
"Seed to use for randomized unit tests. "
"Special value 'random' means using a seed of None.",
StrParam(666, is_valid=good_seed_param),
in_c_key=False)
def fetch_seed(pseed=None):
......@@ -41,15 +41,15 @@ def fetch_seed(pseed=None):
Returns the seed to use for running the unit tests.
If an explicit seed is given, it will be used for seeding numpy's rng.
If not, it will use config.unittest.rseed (its default value is 666).
If config.unittest.rseed is set to "random", it will seed the rng with None,
which is equivalent to seeding with a random seed.
If config.unittest.rseed is set to "random", it will seed the rng with
None, which is equivalent to seeding with a random seed.
Useful for seeding RandomState objects.
>>> rng = numpy.random.RandomState(unittest_tools.fetch_seed())
"""
seed = pseed or config.unittests.rseed
if seed=='random':
if seed == 'random':
seed = None
try:
......@@ -58,8 +58,8 @@ def fetch_seed(pseed=None):
else:
seed = None
except ValueError:
print >> sys.stderr, 'Error: config.unittests.rseed contains '\
'invalid seed, using None instead'
print >> sys.stderr, ('Error: config.unittests.rseed contains '
'invalid seed, using None instead')
seed = None
return seed
......@@ -72,7 +72,7 @@ def seed_rng(pseed=None):
"""
seed = fetch_seed(pseed)
if pseed and pseed!=seed:
if pseed and pseed != seed:
print >> sys.stderr, 'Warning: using seed given by config.unittests.rseed=%i'\
'instead of seed %i given as parameter' % (seed, pseed)
numpy.random.seed(seed)
......@@ -155,7 +155,8 @@ class T_OpContractMixin(object):
assert op_i == self.clone(op_i)
assert op_i != self.other_op
for j, op_j in enumerate(self.ops):
if i == j: continue
if i == j:
continue
assert op_i != op_j
def test_hash(self):
......@@ -167,7 +168,8 @@ class T_OpContractMixin(object):
assert h_i == hash(self.clone(op_i))
assert h_i != hash(self.other_op)
for j, op_j in enumerate(self.ops):
if i == j: continue
if i == j:
continue
assert op_i != hash(op_j)
def test_name(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论