Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ValueError: Cannot pickle code objects from closures

The following code produces a strange error ValueError: Cannot pickle code objects from closures in Sage 9.4. It does not happen at SageCell, and also disappears if I remove if set(v)&S condition. What's wrong?

def mytestproc(n,G,S):
    V = [v for v in G.vertices() if set(v)&S]
    return n*len(V)

def test(n):
  G = DiGraph()
  return sum( val for _,val in sage.parallel.multiprocessing_sage.parallel_iter(2, mytestproc, [((n,G,S),{}) for S in Subsets(1..n)]) )

test(2)

ValueError: Cannot pickle code objects from closures

The following code produces a strange error ValueError: Cannot pickle code objects from closures in Sage 9.4. It does not happen at SageCell, and also disappears if I remove if set(v)&S condition. What's wrong?

def mytestproc(n,G,S):
    V = [v for v in G.vertices() if set(v)&S]
    return n*len(V)

def test(n):
  G = DiGraph()
  return sum( val for _,val in sage.parallel.multiprocessing_sage.parallel_iter(2, mytestproc, [((n,G,S),{}) for S in Subsets(1..n)]) )

test(2)

ValueError: Cannot pickle code objects from closures

The following code produces a strange error ValueError: Cannot pickle code objects from closures in Sage 9.4. It does not happen at SageCell, and also disappears if I remove if set(v)&S condition. What's wrong?

def mytestproc(n,G,S):
    V = [v for v in G.vertices() if set(v)&S]
    return n*len(V)

def test(n):
  G = DiGraph()
  return sum( val for _,val in sage.parallel.multiprocessing_sage.parallel_iter(2, mytestproc, [((n,G,S),{}) for S in Subsets(1..n)]) )

test(2)