diff --git a/Makefile b/Makefile index dd31333..d71b925 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ testall: make -C test DATATYPE=int16_t CFLAGADD="$(CFLAGADD)" test make -C test DATATYPE=float CFLAGADD="$(CFLAGADD)" test make -C test DATATYPE=double CFLAGADD="$(CFLAGADD)" test + echo "all tests passed" tarball: clean hg archive -r v$(KFVER) -t tgz kiss_fft$(KFVER).tar.gz diff --git a/test/testkiss.py b/test/testkiss.py index a5f7005..5749c7c 100755 --- a/test/testkiss.py +++ b/test/testkiss.py @@ -7,8 +7,7 @@ import random import struct import popen2 import getopt -import Numeric -import FFT +import numpy pi=math.pi e=math.e @@ -26,7 +25,7 @@ elif datatype=='int16_t': fmt='h' minsnr=10 elif datatype=='int32_t': - fmt='l' + fmt='i' elif datatype=='simd': fmt='4f' sys.stderr.write('testkiss.py does not yet test simd') @@ -39,21 +38,21 @@ else: def dopack(x,cpx=1): - x = Numeric.reshape( x, ( Numeric.size(x),) ) + x = numpy.reshape( x, ( numpy.size(x),) ) if cpx: s = ''.join( [ struct.pack(fmt*2,c.real,c.imag) for c in x ] ) else: - s = ''.join( [ struct.pack(fmt,c) for c in x ] ) + s = ''.join( [ struct.pack(fmt,c.real) for c in x ] ) return s def dounpack(x,cpx): uf = fmt * ( len(x) / struct.calcsize(fmt) ) s = struct.unpack(uf,x) if cpx: - return Numeric.array(s[::2]) + Numeric.array( s[1::2] )*j + return numpy.array(s[::2]) + numpy.array( s[1::2] )*j else: - return Numeric.array(s ) + return numpy.array(s ) def make_random(dims=[1]): res = [] @@ -67,11 +66,11 @@ def make_random(dims=[1]): res.append( complex(r,i) ) else: res.append( make_random( dims[1:] ) ) - return Numeric.array(res) + return numpy.array(res) def flatten(x): - ntotal = Numeric.product(Numeric.shape(x)) - return Numeric.reshape(x,(ntotal,)) + ntotal = numpy.size(x) + return numpy.reshape(x,(ntotal,)) def randmat( ndims ): dims=[] @@ -85,11 +84,11 @@ def randmat( ndims ): def test_fft(ndims): x=randmat( ndims ) - print 'dimensions=%s' % str( Numeric.shape(x) ), + if doreal: - xver = FFT.real_fftnd(x) + xver = numpy.fft.rfftn(x) else: - xver = FFT.fftnd(x) + xver = numpy.fft.fftn(x) open('/tmp/fftexp.dat','w').write(dopack( flatten(xver) , True ) ) @@ -97,8 +96,8 @@ def test_fft(ndims): err = xver - x2 errf = flatten(err) xverf = flatten(xver) - errpow = Numeric.vdot(errf,errf)+1e-10 - sigpow = Numeric.vdot(xverf,xverf)+1e-10 + errpow = numpy.vdot(errf,errf)+1e-10 + sigpow = numpy.vdot(xverf,xverf)+1e-10 snr = 10*math.log10(abs(sigpow/errpow) ) print 'SNR (compared to NumPy) : %.1fdB' % float(snr) @@ -109,9 +108,9 @@ def test_fft(ndims): sys.exit(1) def dofft(x): - dims=list( Numeric.shape(x) ) + dims=list( numpy.shape(x) ) x = flatten(x) - iscomp = (type(x[0]) == complex) + iscomp = (all(x.conj()==x)==False) scale=1 if datatype=='int16_t': @@ -126,6 +125,7 @@ def dofft(x): if doreal: cmd += ' -R ' + print cmd p = popen2.Popen3(cmd ) open('/tmp/fftin.dat','w').write(dopack( x , iscomp ) ) @@ -141,7 +141,7 @@ def dofft(x): res = scale * res p.wait() - return Numeric.reshape(res,dims) + return numpy.reshape(res,dims) def main(): opts,args = getopt.getopt(sys.argv[1:],'r')