提交 52da8b11 authored 作者: Hengjean's avatar Hengjean

Corrected documentation.

Added no axis test for matrices. Test results are now compared against numpy result
上级 244ba8b8
...@@ -973,7 +973,7 @@ Reductions ...@@ -973,7 +973,7 @@ Reductions
:Parameter: *x* Input tensor. :Parameter: *x* Input tensor.
:Parameter: *axis Axis along which to find the peaks. By default, :Parameter: *axis* Axis along which to find the peaks. By default,
flatten the array. flatten the array.
:Returns: A new array holding the result. :Returns: A new array holding the result.
......
...@@ -6796,9 +6796,9 @@ class test_ptp(unittest.TestCase): ...@@ -6796,9 +6796,9 @@ class test_ptp(unittest.TestCase):
y = rand_ranged(-1000, 1000, [100]) y = rand_ranged(-1000, 1000, [100])
result = f(y) result = f(y)
maxLessMin = [numpy.amax(y) - numpy.amin(y)] numpyResult = numpy.ptp(y, 0)
self.assertTrue(result == maxLessMin) self.assertTrue(numpy.array_equal(result, numpyResult))
def test_matrix_first_axis(self): def test_matrix_first_axis(self):
...@@ -6808,9 +6808,9 @@ class test_ptp(unittest.TestCase): ...@@ -6808,9 +6808,9 @@ class test_ptp(unittest.TestCase):
y = rand_ranged(-1000, 1000, [100, 100]) y = rand_ranged(-1000, 1000, [100, 100])
result = f(y) result = f(y)
maxLessMin = [numpy.amax(i) - numpy.amin(i) for i in y] numpyResult = numpy.ptp(y, 1)
self.assertTrue(numpy.array_equal(result, maxLessMin)) self.assertTrue(numpy.array_equal(result, numpyResult))
def test_matrix_second_axis(self): def test_matrix_second_axis(self):
x = matrix('x') x = matrix('x')
...@@ -6819,10 +6819,9 @@ class test_ptp(unittest.TestCase): ...@@ -6819,10 +6819,9 @@ class test_ptp(unittest.TestCase):
y = rand_ranged(-1000, 1000, [100, 100]) y = rand_ranged(-1000, 1000, [100, 100])
result = f(y) result = f(y)
y = numpy.swapaxes(y, 0, 1) numpyResult = numpy.ptp(y, 0)
maxLessMin = [numpy.amax(i) - numpy.amin(i) for i in y]
self.assertTrue(numpy.array_equal(result, maxLessMin)) self.assertTrue(numpy.array_equal(result, numpyResult))
def test_matrix_neg_axis(self): def test_matrix_neg_axis(self):
x = matrix('x') x = matrix('x')
...@@ -6831,9 +6830,20 @@ class test_ptp(unittest.TestCase): ...@@ -6831,9 +6830,20 @@ class test_ptp(unittest.TestCase):
y = rand_ranged(-1000, 1000, [100, 100]) y = rand_ranged(-1000, 1000, [100, 100])
result = f(y) result = f(y)
maxLessMin = [numpy.amax(i) - numpy.amin(i) for i in y] numpyResult = numpy.ptp(y, -1)
self.assertTrue(numpy.array_equal(result, maxLessMin)) self.assertTrue(numpy.array_equal(result, numpyResult))
def test_matrix_no_axis(self):
x = matrix('x')
p = ptp(x)
f = theano.function([x], p)
y = rand_ranged(-1000, 1000, [100, 100])
result = f(y)
numpyResult = numpy.ptp(y)
self.assertTrue(numpy.array_equal(result, numpyResult))
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论