Skip to content

Commit

Permalink
Adding (skipped) test to numba.tests.test_unary_ops based on user bug…
Browse files Browse the repository at this point in the history
… report.
  • Loading branch information
Jon Riehl committed Nov 9, 2012
1 parent 5802e8e commit d3325c3
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion numba/tests/test_unary_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
from numba import *
from . import test_support

import numpy, math

import unittest


def unary_minus(x):
return -x

Expand All @@ -19,6 +22,14 @@ def unary_not_pred(p):
def unary_invert(x):
return ~x

def maxstar1d(a, b):
M = a.shape[0]
res = numpy.empty(M)
for i in range(M):
res[i] = numpy.max(a[i], b[i]) + numpy.log1p(
numpy.exp(-numpy.abs(a[i] - b[i])))
return res


class TestUnaryOps(unittest.TestCase):
def test_unary_minus(self):
Expand All @@ -45,6 +56,14 @@ def test_unary_invert(self):
self.assertEqual(test_fn(test_val), ~test_val)
self.assertEqual(test_fn(test_val), unary_invert(test_val))

@test_support.checkSkipFlag("Object arithmetic not currently supported.")
def test_maxstar1d(self):
test_fn = jit('f8[:](f8[:],f8[:])')(maxstar1d)
test_a = numpy.random.random(10)
test_b = numpy.random.random(10)
self.assertTrue((test_fn(test_a, test_b) ==
maxstar1d(test_a, test_b)).all())


if __name__ == "__main__":
unittest.main()
test_support.main()

0 comments on commit d3325c3

Please sign in to comment.