예제 #1
0
파일: test_wavelets.py 프로젝트: uniomni/CV
    def test_big(self):
        from RandomArray import seed, random

        seed(13, 17)

        X = random((1024, 512))

        Y = fwt2(X)
        X1 = ifwt2(Y)
        assert Numeric.allclose(X - X1, 0)
예제 #2
0
 def testLinearLeastSquares(self):
     """
     From bug #503733.
     """
     # XXX not positive on this yet
     import LinearAlgebra
     from RandomArray import seed, random
     seed(7,19)
     (n, m) = (180, 35)
     yp = random((n,m))
     y  = random(n)
     x, residuals, rank, sv = LinearAlgebra.linear_least_squares(yp, y)
     # shouldn't segfault.
     assert rank == m
예제 #3
0
파일: test_wavelets.py 프로젝트: uniomni/CV
    def test_ifwt2c(self):

        from RandomArray import seed, random

        seed(13, 17)

        X = random((8, 4))

        Y = ifwt2(X)
        Y = ifwt2(Y)

        Y = fwt2(Y)
        X1 = fwt2(Y)
        assert Numeric.allclose(X - X1, 0)
예제 #4
0
def simple_rdp(s, dir=None, vel=None, fraction=0.25,
			   fgcolor=(255,255,255), bgcolor=(128,128,128),
			   rseed=None):
	if rseed:
		old_seed = get_seed()
		seed(rseed[0], rseed[1])
	if dir is None:
		for n in range(3):
			if n == 0:
				m = uniform(0.0, 1.0, shape=(s.w, s.h))
			mc = where(greater(m, fraction), bgcolor[n], fgcolor[n])
			s.array[:,:,n] = mc[::].astype(UnsignedInt8)
	else:
		dx = -int(round(vel * math.cos(math.pi * dir / 180.0)))
		dy = int(round(vel * math.sin(math.pi * dir / 180.0)))
		a = s.array[:,:,:]
		a = concatenate((a[dx:,:,:],a[:dx,:,:]), axis=0)
		a = concatenate((a[:,dy:,:],a[:,:dy,:]), axis=1)
		s.array[:,:,:] = a[::]
		
	if rseed:
		seed(old_seed[0], old_seed[1])
예제 #5
0
 def initializeRandomNumbersFromTime():
     random.seed()
     seed(0, 0)
예제 #6
0
try:
    if numeric == "Numeric":
        import RNG
    elif numeric == "NumPy":
        import numpy.oldnumeric.rng as RNG
except ImportError:
    pass

if RNG is None:

    if numeric == "Numeric":
        from RandomArray import uniform, seed
    elif numeric == "NumPy":
        from numpy.oldnumeric.random_array import uniform, seed
    random = __import__('random')
    seed(1, 1)
    random.seed(1)

    def initializeRandomNumbersFromTime():
        random.seed()
        seed(0, 0)

    def gaussian(mean, std, shape=None):
        if shape is None:
            x = random.normalvariate(0., 1.)
        else:
            x = N.zeros(shape, N.Float)
            xflat = N.ravel(x)
            for i in range(len(xflat)):
                xflat[i] = random.normalvariate(0., 1.)
        return mean + std * x
예제 #7
0
 def initializeRandomNumbersFromTime():
     random.seed()
     seed(0, 0)
예제 #8
0
    if numeric == "Numeric":
        import RNG
    elif numeric == "NumPy":
        import numpy.oldnumeric.rng as RNG
except ImportError:
    pass


if RNG is None:

    if numeric == "Numeric":
        from RandomArray import uniform, seed
    elif numeric == "NumPy":
        from numpy.oldnumeric.random_array import uniform, seed
    random = __import__('random')
    seed(1, 1)
    random.seed(1)

    def initializeRandomNumbersFromTime():
        random.seed()
        seed(0, 0)

    def gaussian(mean, std, shape=None):
        if shape is None:
            x = random.normalvariate(0., 1.)
        else:
            x = N.zeros(shape, N.Float)
            xflat = N.ravel(x)
            for i in range(len(xflat)):
                xflat[i] = random.normalvariate(0., 1.)
        return mean + std*x