Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible bug in dump method #1

Open
lodurality opened this issue Dec 8, 2016 · 1 comment
Open

possible bug in dump method #1

lodurality opened this issue Dec 8, 2016 · 1 comment
Assignees

Comments

@lodurality
Copy link
Member

lodurality commented Dec 8, 2016

Pipeliner doesn't dump config in the old version. Maybe it's because we are trying to pickle lambdas as well

/home/deaddy/Repos/Connectomics/Reskit/reskit/core.py in dump(self, path)
    116         with open(path, 'wb') as f:
    117             for attr in sorted(self.__dict__.keys()):
--> 118                 dump(getattr(self, attr), f)
    119 
    120     def load(self, path):

AttributeError: Can't pickle local object 'gen_dist.<locals>.<lambda>'
@lodurality
Copy link
Member Author

I found the solution -- it's lambda usage indeed

def gen_dist(p): return lambda x,y: minkowski(x.reshape(-1),y.reshape(-1),p)

We should use partial from functools in future:

from functools import partial
def gen_dist(x, y, p): 
    return minkowski(x.reshape(-1),y.reshape(-1),p)

func_list = [chebyshev] + [partial(gen_dist, p=i) for i in [1, 2]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants