using Joblib memory library with partial objects
Asked Answered
M

0

9

I have a function with two parameters:

def foo(x,y):
   # some complicated math
   return result

and I define partials using the functools library:

f1 = partial(foo,1)
f2 = partial(foo,2)

Now I would like to use the joblib.Memory library to cache the results in disk to avoid re-computation.

from joblib import Memory
mem = Memory(cachedir = '/tmp')    
f1c = mem.cache(f1)
f2c = mem.cache(f2)
res1 = f1c(10)
res2 = f1c(10)

When I run the code, I get the warning:

JobLibCollisionWarning: Cannot detect name collisions
for function 'unknown

Also the results are not cached. Is there a way to use partial objects with Memory library?

Minetta answered 15/11, 2016 at 14:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.