def test_cauchy_kernel_0(): """ Test case where sigma = 0, expect 0 return. """ sigma = tf.constant(0, dtype=tf.float32) expect = tf.constant(0, dtype=tf.float32) get = label.cauchy_kernel1d(sigma) assert get == expect
def test_cauchy_kernel_0(): """ Test case where sigma = 0, expect 0 return. """ sigma = 0 get = label.cauchy_kernel1d(sigma) expect = 0 assert get == expect
def test_cauchy_kernel_else(): """ Test case where sigma is not 0, expect tensor returned. """ sigma = 3 get = tf.cast(label.cauchy_kernel1d(sigma), dtype=tf.float64) list_vals = range(-sigma * 5, sigma * 5 + 1) exp = [1 / ((x / sigma)**2 + 1) for x in list_vals] expect = tf.convert_to_tensor(exp, dtype=tf.float64) expect = expect / tf.reduce_sum(expect) assert assertTensorsEqual(get, expect)
def test_cauchy_kernel_else(): """ Test case where sigma is not 0, expect tensor returned. """ sigma = 3 get = tf.cast(label.cauchy_kernel1d(sigma), dtype=tf.float32) expect = [ 1 / ((x / sigma)**2 + 1) for x in range(-sigma * 5, sigma * 5 + 1) ] expect = tf.convert_to_tensor(expect, dtype=tf.float32) expect = expect / tf.reduce_sum(expect) assert is_equal_tf(get, expect)