Arguments not parsing for class method
Closed this issue · 1 comments
- Parallel TQDM version: pqdm==0.2.0
- Python version: Python 3.9.16
- Operating System: Ubuntu 18.04.5 LTS
Description
Thanks for this cool package!
I was able to get the parallel processing working for a custom function. However, when I added this function to class as a method, it appears that it is no longer receiving the arguments (neither args
or kwargs
works) as expected. I was able to recreate this with another simple example, using the math
package (below).
Am I missing something here? Is there a way to pass these arguments to a class method?
What I Did
from pqdm.processes import pqdm
import math
args = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
result = pqdm(args, math.sqrt(), n_jobs=2)
Results in the following error:
TypeError: math.sqrt() takes exactly one argument (0 given)
Note, for future reference, that the first error I encountered (trying to use a class method) was:
TypeError: 'module' object is not callable
Actually, I realized what my problem was here.
I accidentally imported pqdm as follows (when running my custom class method):
import pqdm
Instead of:
from pqdm.processes import pqdm
And I've confirmed that if you remove the parentheses to the math.sqrt
call (i.e., instead of math.sqrt()
, this test works:
from pqdm.processes import pqdm
import math
args = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
result = pqdm(args, math.sqrt, n_jobs=2)
I will close the issue. Sorry for my mistake here, but perhaps this will help someone in the future if they make the same import mistake I did.