def additional_tests(): # XXX: does this guarantee that the package is the one in the dev trunk, and # not scikits.foo installed somewhere else ? import scikits.audiolab np = NumpyTest(scikits.audiolab) return np._test_suite_from_all_tests(np.package, level=10, verbosity=1)
def test_suite(*args): # XXX: this is to avoid recursive call to itself. This is an horrible hack, # I have no idea why infinite recursion happens otherwise. if len(args) > 0: import unittest return unittest.TestSuite() np = NumpyTest() np.testfile_patterns.append(r'test_examples.py') return np.test(level = -10, verbosity = 5)
def _test(method, level, verbosity, flags): """ Run test suite with level and verbosity. level: None --- do nothing, return None < 0 --- scan for tests of level=abs(level), don't run them, return TestSuite-list > 0 --- scan for tests of level, run them, return TestRunner verbosity: >= 0 --- show information messages > 1 --- show warnings on missing tests """ from numpy.testing import NumpyTest, importall importall('ptsa') return getattr(NumpyTest(), method)(level, verbosity=2)
def test(level=-1, verbosity=1): from numpy.testing import NumpyTest return NumpyTest().test(level, verbosity)
assert_almost_equal(polyfit(x, y, 3), numpy.polyfit(x, y, 3)) # ON 1D maskedarrays x = x.view(MaskedArray) x[0] = masked y = y.view(MaskedArray) y[0, 0] = y[-1, -1] = masked # (C, R, K, S, D) = polyfit(x, y[:, 0], 3, full=True) (c, r, k, s, d) = numpy.polyfit(x[1:], y[1:, 0].compressed(), 3, full=True) for (a, a_) in zip((C, R, K, S, D), (c, r, k, s, d)): assert_almost_equal(a, a_) # (C, R, K, S, D) = polyfit(x, y[:, -1], 3, full=True) (c, r, k, s, d) = numpy.polyfit(x[1:-1], y[1:-1, -1], 3, full=True) for (a, a_) in zip((C, R, K, S, D), (c, r, k, s, d)): assert_almost_equal(a, a_) # (C, R, K, S, D) = polyfit(x, y, 3, full=True) (c, r, k, s, d) = numpy.polyfit(x[1:-1], y[1:-1, :], 3, full=True) for (a, a_) in zip((C, R, K, S, D), (c, r, k, s, d)): assert_almost_equal(a, a_) ############################################################################### #------------------------------------------------------------------------------ if __name__ == "__main__": NumpyTest().run()
tn0 = time.time() z = f(x) return time.time() - tn0 def testf(x): for i in range(25): y = x**2 + 2.0 * x - 1.0 w = x**2 + 1.0 z = (y / w)**2 return z testf.test_name = 'Simple arithmetic' def testinplace(x): for i in range(25): y = x**2 y += 2.0 * x y -= 1.0 y /= x return y testinplace.test_name = 'Inplace operations' if __name__ == "__main__": NumpyTest('numpy.core.ma').run() #timingTest()
#! /usr/bin/env python # Last Change: Sun Jul 22 01:00 PM 2007 J from info import __doc__ from gauss_mix import GmParamError, GM from gmm_em import GmmParamError, GMM, EM from online_em import OnGMM as _OnGMM __all__ = filter(lambda s:not s.startswith('_'), dir()) from numpy.testing import NumpyTest test = NumpyTest().test def test_suite(*args): # XXX: this is to avoid recursive call to itself. This is an horrible hack, # I have no idea why infinite recursion happens otherwise. if len(args) > 0: import unittest return unittest.TestSuite() np = NumpyTest() np.testfile_patterns.append(r'test_examples.py') return np.test(level = -10, verbosity = 5)
tn0 = time.time() z = f(x) return time.time() - tn0 def testf(x): for i in range(25): y = x**2 + 2.0 * x - 1.0 w = x**2 + 1.0 z = (y / w)**2 return z testf.test_name = 'Simple arithmetic' def testinplace(x): for i in range(25): y = x**2 y += 2.0 * x y -= 1.0 y /= x return y testinplace.test_name = 'Inplace operations' if __name__ == "__main__": NumpyTest('numpy.ma').run() #timingTest()