Re: [myhdl-list] _Waiter.diff [was: intbv.saturate, intbv.wrap]
Brought to you by:
jandecaluwe
From: Christopher L. F. <chr...@gm...> - 2008-07-23 11:32:21
|
> >> This would compare using '=='. Thomas has proposed to replace >> this with 'is' test. I still don't really see what difference >> this would make. Can you explain issue/error that you >> are seeing? > I proposed to remove the tuple because there is a problem with numpy > comparison. > This is a short test on the interactiv shell. > > =============================================== >>>> a=[1,2] >>>> b=[4,5] >>>> a in b > = False >>>> from numpy import arange >>>> a = arange(3) >>>> a in b > --------------------------------------------------------------------------- > ValueError Traceback (most recent > call last) > > ValueError: The truth value of an array with more than one element is > ambiguous. > Use a.any() or a.all() > ================================================= I had not realized that this error was only for numpy arrays as the example Thomas provided demonstrates. I had originally thought this would have failed for a list as well. Is this an issue/error with the numpy array? Here is the snippet of code that I am using that fails. @instance def stimulus(): """ The following is a basic testbench to stimulate the CIC filter and create some plots. """ yield clk.posedge rst.next = True yield delay(10) rst.next = False yield delay(10) for ii in range(Nloops): for jj in range(Nfft): x.next = int(L * uniform(-1, 1)) xs[jj] = float(x)/L ysave[jj] = float(y._val)/L # Undo fix-point yield clk.negedge favg = favg + abs(fft(ysave, Nfft)) / Nfft xfavg = xfavg + abs(fft(xs))/Nfft favg = favg / Nloops xfavg = xfavg / Nloops |