this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

no longer use deprecated popen2 module

+7 -13
+7 -13
test/testkiss.py
··· 1 1 #!/usr/bin/env python 2 - # Copyright (c) 2003-2010, Mark Borgerding. All rights reserved. 2 + # Copyright (c) 2003-2019, Mark Borgerding. All rights reserved. 3 3 # This file is part of KISS FFT - https://github.com/mborgerding/kissfft 4 4 # 5 5 # SPDX-License-Identifier: BSD-3-Clause ··· 10 10 import os 11 11 import random 12 12 import struct 13 - import popen2 14 13 import getopt 15 14 import numpy 16 15 17 16 pi=math.pi 18 17 e=math.e 19 - j=complex(0,1) 20 18 21 19 doreal=0 22 20 ··· 55 53 uf = fmt * ( len(x) / struct.calcsize(fmt) ) 56 54 s = struct.unpack(uf,x) 57 55 if cpx: 58 - return numpy.array(s[::2]) + numpy.array( s[1::2] )*j 56 + return numpy.array(s[::2]) + numpy.array( s[1::2] )*1j 59 57 else: 60 58 return numpy.array(s ) 61 59 ··· 89 87 def test_fft(ndims): 90 88 x=randmat( ndims ) 91 89 92 - 93 90 if doreal: 94 91 xver = numpy.fft.rfftn(x) 95 92 else: 96 93 xver = numpy.fft.fftn(x) 97 94 98 - open('/tmp/fftexp.dat','w').write(dopack( flatten(xver) , True ) ) 99 - 100 95 x2=dofft(x,doreal) 101 96 err = xver - x2 102 97 errf = flatten(err) ··· 130 125 cmd += ' -R ' 131 126 132 127 print cmd 133 - p = popen2.Popen3(cmd ) 134 128 135 - open('/tmp/fftin.dat','w').write(dopack( x , isreal==False ) ) 129 + from subprocess import Popen,PIPE 130 + p = Popen(cmd,shell=True,stdin=PIPE,stdout=PIPE ) 136 131 137 - p.tochild.write( dopack( x , isreal==False ) ) 138 - p.tochild.close() 132 + p.stdin.write( dopack( x , isreal==False ) ) 133 + p.stdin.close() 139 134 140 - res = dounpack( p.fromchild.read() , 1 ) 141 - open('/tmp/fftout.dat','w').write(dopack( flatten(res) , True ) ) 135 + res = dounpack( p.stdout.read() , 1 ) 142 136 if doreal: 143 137 dims[-1] = int( dims[-1]/2 ) + 1 144 138