ValueError: cannot compute fingerprint of empty list

0 views
Skip to first unread message

Daniel Mahler

unread,
Jan 9, 2017, 9:19:00 AM1/9/17
to Numba Public Discussion - Public
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

Stanley Seibert

unread,
Jan 9, 2017, 1:08:11 PM1/9/17
to Numba Public Discussion - Public
Hi Daniel,

I can reproduce the error you see.  I think in this case you aren't seeing a feature that was removed, but rather a new feature that is interfering with an old one.  A tightening of our testing for lists in nopython mode seems to be interfering with object mode and its attempt to lift the while loop.  This error should not bubble up to the user, so I've opened a github issue to track the problem:

https://github.com/numba/numba/issues/2238

I should note that after testing this code with Numba 0.22.1 (the version that would have been current in Dec 2015), I don't see how Numba was compiling this code with any performance improvement.  It looks like all of cluster() falls back to object mode.


--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users+unsubscribe@continuum.io.
To post to this group, send email to numba...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/502fd3b8-112a-43ca-969b-ea2f229fdbdb%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Reply all
Reply to author
Forward
0 new messages