Closed inti closed 11 years ago
I think found the potential culprit, casting the variables sort this out Inti
scipy.weave.inline(
'''
int tot = 0;
for (int i=0; i < int(N); i++) {
for (int j=0; j < int(data[i]); j++) {
tot += ((float) rand()) / RAND_MAX < ((float) r)/(j+r);
}
}
*msum = tot;
''',
['N','data','r','msum'],
extra_compile_args=['-O3'])
I think I introduced that bug recently and I have it fixed on my local code; I'll push a change today in the Python code, though your casting fix may work as well.
Somehow I got to a version of flattendata that would call np.ma.concatenate, which cast things to MaskedArray
s that weave can't automatically convert as it can with numpy arrays. (If you debug that line in the Python interpeter, you'll see data is an instance of np.ma.MaskedArray instead of an ndarray.)
Here's the updated flattendata in util.stats:
def flattendata(data):
# data is either an array or a list of arrays
if isinstance(data,np.ndarray):
return data
elif isinstance(data,list):
if any(isinstance(d,np.ma.MaskedArray) for d in data):
return np.ma.concatenate(data)
else:
return np.concatenate(data)
else:
assert isinstance(data,int) or isinstance(data,float)
return np.array(data,ndmin=1)
Fixed in ca24b3e
hi Matt, I am trying to run this on our computer cluster. I am getting an error with the compilation of the weave.inline function on the negative binomial sampling. The code works find on my desktop machine scipy 0.11.0 numpy 1.6.2
on the cluster produces the error below scipy 0.12.0 numpy 1.7.1 both the latest
For some reason your other weave code compiles and runs but the one on the negative binomial does not. I wonder if you can see a reason for this an a possible solution.
Thanks a lot in advance, BW, Inti Pedroso