Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
Minor fixes to tests (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Moldovan committed Nov 11, 2017
1 parent 09b1ca4 commit 8e5a2ec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
15 changes: 11 additions & 4 deletions tests/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def tanh(a):
return np.tanh(a)


def I_assign(a):
def identity_assign(a):
b = a
return b

Expand Down Expand Up @@ -314,7 +314,7 @@ def third_pow(a):


def direct_third_pow(a):
return a**3
return a ** 3


def iter_third_pow1(a):
Expand Down Expand Up @@ -392,7 +392,11 @@ def numpy_exp2(a):


def numpy_sqrt(a):
return np.sqrt(a)
if a >= 0:
r = np.sqrt(a)
else:
r = np.sqrt(-a)
return r


def numpy_cos(a):
Expand Down Expand Up @@ -756,7 +760,10 @@ def stack_pushing(a):


def gradgrad_pow(a, b):
a = a ** b
if a >= 0:
a = a ** b
else:
a = (-a) ** b
return a


Expand Down
28 changes: 14 additions & 14 deletions tests/test_forward_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@
import utils


def test_grad_unary(func, preserve_result, a):
"""Test gradients of single-argument scalar functions."""
def test_deriv_unary(func, preserve_result, a):
"""Test derivatives of single-argument scalar functions."""
utils.test_forward_array(func, (0,), preserve_result, a)


def test_grad_binary(func, preserve_result, a, b):
"""Test gradients of two-argument scalar functions."""
def test_deriv_binary(func, preserve_result, a, b):
"""Test derivatives of two-argument scalar functions."""
utils.test_forward_array(func, (0,), preserve_result, a, b)


def test_grad_ternary(func, preserve_result, a, b, c):
"""Test gradients of three-argument scalar functions."""
def test_deriv_ternary(func, preserve_result, a, b, c):
"""Test derivatives of three-argument scalar functions."""
utils.test_forward_array(func, (0,), preserve_result, a, b, c)


def test_grad_binary_int(func, preserve_result, a, n):
"""Test gradients of functions with scalar and integer input."""
def test_deriv_binary_int(func, preserve_result, a, n):
"""Test derivatives of functions with scalar and integer input."""
utils.test_forward_array(func, (0,), preserve_result, a, n)


def test_grad_unary_tensor(func, t):
"""Test gradients of functions with single tensor input."""
def test_deriv_unary_tensor(func, t):
"""Test derivatives of functions with single tensor input."""
# TODO: remove trace test exemption when tests are consolidated.
if 'trace' in func.__name__:
return
Expand All @@ -58,17 +58,17 @@ def test_grad_unary_tensor(func, t):
tfe_utils.test_forward_tensor(func, (0,), t)


def test_grad_binary_tensor(func, t1, t2):
"""Test gradients of functions with binary tensor inputs."""
def test_deriv_binary_tensor(func, t1, t2):
"""Test derivatives of functions with binary tensor inputs."""
if any(n in func.__name__ for n in ('tfe_squared_difference',)):
utils.assert_forward_not_implemented(func, (0,))
return
tfe_utils.test_forward_tensor(func, (0,), t1, t2)
tfe_utils.test_forward_tensor(func, (1,), t1, t2)


def test_grad_image(func, timage, tkernel, conv2dstrides):
"""Test gradients of image functions."""
def test_deriv_image(func, timage, tkernel, conv2dstrides):
"""Test derivatives of image functions."""
utils.assert_forward_not_implemented(func, (0,))


Expand Down

0 comments on commit 8e5a2ec

Please sign in to comment.