提交 0a391daa authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Some fixes to let nose identify tests properly

This is required for the script `run_tests_in_batch.py` to work properly: it must be possible to identify each test by its name.
上级 897af646
...@@ -372,7 +372,8 @@ def rand_of_dtype(shape, dtype): ...@@ -372,7 +372,8 @@ def rand_of_dtype(shape, dtype):
def makeBroadcastTester(op, expected, checks={}, name=None, **kwargs): def makeBroadcastTester(op, expected, checks={}, name=None, **kwargs):
name = str(op) if name is None:
name = str(op)
# Here we ensure the test name matches the name of the variable defined in # Here we ensure the test name matches the name of the variable defined in
# this script. This is needed to properly identify the test e.g. with the # this script. This is needed to properly identify the test e.g. with the
# --with-id option of nosetests, or simply to rerun a specific test that # --with-id option of nosetests, or simply to rerun a specific test that
...@@ -628,6 +629,7 @@ CeilIntDivTester = makeBroadcastTester( ...@@ -628,6 +629,7 @@ CeilIntDivTester = makeBroadcastTester(
uinteger=(randint(2, 3).astype("uint8"), uinteger=(randint(2, 3).astype("uint8"),
randint_nonzero(2, 3).astype("uint8")), randint_nonzero(2, 3).astype("uint8")),
), ),
name='CeilIntDiv',
# As we implement this function with neq, the gradient returned is always 0. # As we implement this function with neq, the gradient returned is always 0.
# grad=_grad_broadcast_div_mod_normal, # grad=_grad_broadcast_div_mod_normal,
# grad_rtol=div_grad_rtol, # grad_rtol=div_grad_rtol,
...@@ -674,10 +676,13 @@ _grad_broadcast_pow_normal = dict(same_shapes = (rand_ranged(1, 5, (2, 3)), rand ...@@ -674,10 +676,13 @@ _grad_broadcast_pow_normal = dict(same_shapes = (rand_ranged(1, 5, (2, 3)), rand
_good_broadcast_pow_normal_float_pow = copy(_good_broadcast_pow_normal_float) _good_broadcast_pow_normal_float_pow = copy(_good_broadcast_pow_normal_float)
del _good_broadcast_pow_normal_float_pow["empty2"] del _good_broadcast_pow_normal_float_pow["empty2"]
PowTester = makeBroadcastTester(op = pow, PowTester = makeBroadcastTester(
expected = lambda x, y: check_floatX((x, y), x ** y), op=pow,
good = _good_broadcast_pow_normal_float, expected=lambda x, y: check_floatX((x, y), x ** y),
grad = _grad_broadcast_pow_normal) good=_good_broadcast_pow_normal_float,
grad= _grad_broadcast_pow_normal,
name='Pow')
PowInplaceTester = makeBroadcastTester(op = inplace.pow_inplace, PowInplaceTester = makeBroadcastTester(op = inplace.pow_inplace,
expected = lambda x, y: x ** y, expected = lambda x, y: x ** y,
good = _good_broadcast_pow_normal_float_pow, good = _good_broadcast_pow_normal_float_pow,
...@@ -1090,15 +1095,19 @@ ErfcInplaceTester = makeBroadcastTester(op = inplace.erfc_inplace, ...@@ -1090,15 +1095,19 @@ ErfcInplaceTester = makeBroadcastTester(op = inplace.erfc_inplace,
inplace = True, inplace = True,
skip = skip_scipy) skip = skip_scipy)
ZerosLikeTester = makeBroadcastTester(op = tensor.zeros_like, ZerosLikeTester = makeBroadcastTester(
expected = numpy.zeros_like, op=tensor.zeros_like,
good = _good_broadcast_unary_normal, expected=numpy.zeros_like,
grad = _grad_broadcast_unary_normal) good=_good_broadcast_unary_normal,
grad=_grad_broadcast_unary_normal,
name='ZerosLike')
OnesLikeTester = makeBroadcastTester(op = tensor.ones_like, OnesLikeTester = makeBroadcastTester(
expected = numpy.ones_like, op=tensor.ones_like,
good = _good_broadcast_unary_normal, expected=numpy.ones_like,
grad = _grad_broadcast_unary_normal) good=_good_broadcast_unary_normal,
grad=_grad_broadcast_unary_normal,
name='OnesLike')
DotTester = makeTester(name = 'DotTester', DotTester = makeTester(name = 'DotTester',
op = dot, op = dot,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论