The following code was working in December 2015 with then current version of Numba.
It is an implementation of the Wolff algorithm forr simulating the Ising model.
Numba used to optimize this code very well.
The code is unusable without it.
########################################################################
from numpy import *
from numba import jit, vectorize
@vectorize()
def rint(i):
return randint(i)
@jit
def neighbourhood(n,dtype=byte):
I = eye(n,dtype=dtype)
return vstack([-I, I])
@jit
def cluster(lattice, prob):
nn = neighbourhood(lattice.ndim)
dims = array(lattice.shape)
n=0
S=[]
start = rint(dims)
state = not lattice[tuple(start)]
new = start[newaxis,:]
while True:
lattice[tuple(new.T)] = state
S.extend(new)
if not S:
break
n+=1
current = S.pop()
neighbours = ((current + nn) % dims)
candidates = logical_xor(state, lattice[tuple(neighbours.T)])
flips = logical_and(candidates,
np.random.random(len(candidates)) < prob)
new=neighbours[flips]
return n*(2*state-1)
d=2**9
A = zeros((d,d), dtype=bool)
cluster(A, 0.9)
########################################################################
I just tried to run it again with Numba 0.30.0 it throws
ValueError: cannot compute fingerprint of empty list
I do not know what to make of that message.
Has Numba stopped supporting some constructs in the last 12 months?
Can somebody explain the problem or at least what the message is trying to tell me?
thanks
Daniel