-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
Erm, how should I code if I want to use .map() with a function that takes extra parameter? I have installed the master branch with pip install --upgrade git+https://github.com/dask/dask (on python3.4 on a linux machine) just to be sure
import dask.bag as db
from functools import partial
def hello(a):
return a
def world(a, b):
return a
print(db.from_sequence(range(10)).map(hello).compute())
print(db.from_sequence(range(10)).map(partial(hello)).compute())
# none of these work
print(db.from_sequence(range(10)).map(partial(world, b=100)).compute())
print(db.from_sequence(range(10)).map(world, b=100).compute())
# but this would work
print(db.from_sequence(range(10)).map(lambda x: world(x, 100)).compute())
These are the error messages I am getting
Traceback (most recent call last):
File "address_retriever/foo.py", line 14, in <module>
print(db.from_sequence(range(10)).map(partial(world, b=100)).compute())
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/base.py", line 37, in compute
return compute(self, **kwargs)[0]
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/base.py", line 110, in compute
results = get(dsk, keys, **kwargs)
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/multiprocessing.py", line 77, in get
queue=queue, get_id=_process_get_id, **kwargs)
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/async.py", line 481, in get_async
raise(remote_exception(res, tb))
dask.async.TypeError: functools.partial object argument after * must be a sequence, not int
Traceback
---------
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/async.py", line 264, in execute_task
result = _execute_task(task, data)
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/async.py", line 246, in _execute_task
return func(*args2)
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/bag/core.py", line 1387, in reify
seq = list(seq)
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/compatibility.py", line 28, in apply
return func(*args)
and
Traceback (most recent call last):
File "address_retriever/foo.py", line 14, in <module>
print(db.from_sequence(range(10)).map(world, b=100).compute())
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/base.py", line 37, in compute
return compute(self, **kwargs)[0]
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/base.py", line 110, in compute
results = get(dsk, keys, **kwargs)
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/multiprocessing.py", line 77, in get
queue=queue, get_id=_process_get_id, **kwargs)
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/async.py", line 481, in get_async
raise(remote_exception(res, tb))
dask.async.TypeError: apply() got an unexpected keyword argument 'b'
Traceback
---------
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/async.py", line 264, in execute_task
result = _execute_task(task, data)
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/async.py", line 246, in _execute_task
return func(*args2)
File "/home/jeffrey04/machine-learning/lib/python3.4/site-packages/dask/bag/core.py", line 1387, in reify
seq = list(seq)
Metadata
Metadata
Assignees
Labels
No labels