neurospin / pylearn-epac

Embarrassingly Parallel Array Computing: EPAC is a machine learning workflow builder.
BSD 3-Clause "New" or "Revised" License
12 stars 3 forks source link

VirtualList cannot be saved using pickle #15

Closed JinpengLI closed 11 years ago

JinpengLI commented 11 years ago

Since VirtualList use member variable to copy a callback function, it cannot be saved by pickle. I have reverted back to old version using parent to find the callback function. Just let you know what I modified, @duchesnay .

Pickle all attributes except one

see : http://stackoverflow.com/questions/6635331/pickle-all-attributes-except-one

class Foo(object):
    def __init__(self):
        self.a = 'spam'
        self.b = 'eggs'
        self.c = 42
        self.fn = self.my_func
    def my_func(self):
        print 'My hovercraft is full of eels'

import pickle
pickle.dumps(Foo())              # throws a "can't pickle instancemethod objects" TypeError