~kenneth-arnold/pytables/dev

« back to all changes in this revision

Viewing changes to tables/numexpr/tests/test_numexpr.py

  • Committer: faltet
  • Date: 2009-06-22 13:06:51 UTC
  • Revision ID: vcs-imports@canonical.com-20090622130651-jtlqqudkoqcmqcr3
Numexpr module upgraded to 1.3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
237
237
for func in ['copy', 'ones_like', 'sqrt',
238
238
             'sin', 'cos', 'tan', 'arcsin', 'arccos', 'arctan',
239
239
             'sinh', 'cosh', 'tanh', 'arcsinh', 'arccosh', 'arctanh',
240
 
             'log', 'log1p', 'log10', 'exp', 'expm1']:
 
240
             'log', 'log1p', 'log10', 'exp', 'expm1', 'abs']:
241
241
    func1tests.append("a + %s(b+c)" % func)
242
242
tests.append(('1-ARG FUNCS', func1tests))
243
243
 
377
377
        assert_array_equal(respy, resnx)
378
378
        self.assertEqual(resnx.dtype.name, 'int64')
379
379
 
 
380
 
 
381
class test_uint32_int64(TestCase):
 
382
    def test_small_uint32(self):
 
383
        # Small uint32 should not be downgraded to ints.
 
384
        a = numpy.uint32(42)
 
385
        res = evaluate('a')
 
386
        assert_array_equal(res, 42)
 
387
        self.assertEqual(res.dtype.name, 'int64')
 
388
 
 
389
    def test_uint32_constant_promotion(self):
 
390
        int32array = arange(100, dtype='int32')
 
391
        a = numpy.uint32(2)
 
392
        res = int32array * a
 
393
        res32 = evaluate('int32array * 2')
 
394
        res64 = evaluate('int32array * a')
 
395
        assert_array_equal(res, res32)
 
396
        assert_array_equal(res, res64)
 
397
        self.assertEqual(res32.dtype.name, 'int32')
 
398
        self.assertEqual(res64.dtype.name, 'int64')
 
399
 
 
400
    def test_int64_array_promotion(self):
 
401
        uint32array = arange(100, dtype='uint32')
 
402
        int64array = arange(100, dtype='int64')
 
403
        respy = uint32array * int64array
 
404
        resnx = evaluate('uint32array * int64array')
 
405
        assert_array_equal(respy, resnx)
 
406
        self.assertEqual(resnx.dtype.name, 'int64')
 
407
 
 
408
 
380
409
class test_strings(TestCase):
381
410
    BLOCK_SIZE1 = 128
382
411
    BLOCK_SIZE2 = 8
532
561
        theSuite.addTest(unittest.makeSuite(test_evaluate))
533
562
        theSuite.addTest(unittest.makeSuite(test_expressions))
534
563
        theSuite.addTest(unittest.makeSuite(test_int32_int64))
 
564
        theSuite.addTest(unittest.makeSuite(test_uint32_int64))
535
565
        theSuite.addTest(unittest.makeSuite(test_strings))
536
566
        theSuite.addTest(
537
567
            unittest.makeSuite(test_irregular_stride) )