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

expansion of singleton arguments with map/pmap #1530

Closed
ghost opened this issue Nov 12, 2012 · 5 comments
Closed

expansion of singleton arguments with map/pmap #1530

ghost opened this issue Nov 12, 2012 · 5 comments

Comments

@ghost
Copy link

ghost commented Nov 12, 2012

In some cases, map will "expand" singleton arguments, which is great:

julia> map(+,{1,1,1},{2,2,2})
3-element Any Array:
 3
 3
 3

julia> map(+,{1,1,1},2)
3-element Int64 Array:
 3
 3
 3

However, this doesn't work very systematically:

julia> map(+,{1,1,1},{2,2,2},{3,3,3})
3-element Any Array:
 6
 6
 6

julia> map(+,{1,1,1},2,{3,3,3})
no method map(Function,Array{Any,1},Int64,Array{Any,1})
 in method_missing at base.jl:70

julia> map(+,{1,1,1},{2,2,2},3)
no method map(Function,Array{Any,1},Array{Any,1},Int64)
 in method_missing at base.jl:70

And, with pmap, it doesn't seem to work at all:

julia> pmap(+,{1,1,1},{2,2,2})
3-element Any Array:
 3
 3
 3

julia> pmap(+,{1,1,1},2)
exception on 1: no method ref(Int64,Int64)
exception on 1: no method ref(Int64,Int64)
exception on 1: no method ref(Int64,Int64)
3-element Any Array:
 #undef
 #undef
 #undef
@JeffBezanson
Copy link
Member

I think it would be better if map didn't do any kind of automatic expansion, since the arguments might be any containers and then it might not be clear what is and isn't being expanded. Can be done instead with map(x->x+2, [1,2,3]).

@StefanKarpinski
Copy link
Member

I agree. The expansion thing in map/pmap seems like a misfeature to me.

@ghost
Copy link
Author

ghost commented Nov 12, 2012

I see the logic behind keeping this out of map. However, the realistic use case for doing this would be a large-scale optimization where one wants to map some function over a dataset, but needs to pass a structure of constants to each function evaluation as well. Setting up to explicitly copy that structure to each child process is somewhat tiring. I've tried using closures, but that seems to cause chaos with serialization for pmap... Workarounds are easy for using map without expansion-- pmap not so much because of serialization.

It seems like iterators would be another nice solution here... Do map/pmap support those?

@JeffBezanson
Copy link
Member

Serializing closures is supposed to work; we do it all the time. It would be great if you could write up the case that caused chaos as an issue.

@ghost
Copy link
Author

ghost commented Nov 12, 2012

OK, will do. It is tricky to get a simple self-contained example, but I'll try to trace where the problems are coming from.

fredrikekre pushed a commit that referenced this issue Dec 13, 2019
…34091)

git log --oneline 0c2dddd40e4d7492d2a7337be54c345011e5f1e1^..8e236a7f993f1e732ffd0ab5c15736b2594e4109

8e236a7 (HEAD -> master, origin/master, origin/HEAD) Merge pull request #1544 from JuliaLang/sk/telemetry
90b8482 telemetry: factor out telemetry file loading
228fb97 CI telemetry: send indicators for common CI env vars
246dbd0 Pkg protocol: basic anonymous opt-out telemetry
e66a75f Introduce special REPL syntax for shared environments (#1488)
afeb1ee Merge pull request #1538 from JuliaLang/sk/pkg-client-auth
9c357bb Pkg client auth: support connecting to authenticated Pkg servers
6dd7f34 PlatformEngines: revert API part of headers support (broken)
6825b48 Merge pull request #1539 from 00vareladavid/00/fixes
3f1cf40 it is invalid to `add` a package with no commits
0766765 test: default environment should be created when the primary depot does not exist
43f46f8 check no overwrite is occuring when resolving from a project file
37b6853 handle primary depot as relative path
53fdf24 Check for duplicate name/UUID input
8a6387c Remove redundant precompile statement
4d0901e Dont throw error when autocompleting faulty input (#1530)
d69f6d7 Refactor and test `Pkg.test` (#1427)
8ca8b6d PlatformEngines: use `tar -m` to ignore mtimes (#1537)
6797928 Make sure sandbox's temp Project.toml and Manifest.toml files are writable (#1534)
f968cc9 clarify: stacked envs only affect top-level loading (#1529)
0dfef59 PlatformEngines.download: add header support (#1531)
49ab53e Fix tree hashing with nested empty directories (#1522)
0c2dddd fix #1514: install_archive call in backwards_compatible_isolation (#1517)
KristofferC pushed a commit that referenced this issue Apr 11, 2020
…34091)

git log --oneline 0c2dddd40e4d7492d2a7337be54c345011e5f1e1^..8e236a7f993f1e732ffd0ab5c15736b2594e4109

8e236a7 (HEAD -> master, origin/master, origin/HEAD) Merge pull request #1544 from JuliaLang/sk/telemetry
90b8482 telemetry: factor out telemetry file loading
228fb97 CI telemetry: send indicators for common CI env vars
246dbd0 Pkg protocol: basic anonymous opt-out telemetry
e66a75f Introduce special REPL syntax for shared environments (#1488)
afeb1ee Merge pull request #1538 from JuliaLang/sk/pkg-client-auth
9c357bb Pkg client auth: support connecting to authenticated Pkg servers
6dd7f34 PlatformEngines: revert API part of headers support (broken)
6825b48 Merge pull request #1539 from 00vareladavid/00/fixes
3f1cf40 it is invalid to `add` a package with no commits
0766765 test: default environment should be created when the primary depot does not exist
43f46f8 check no overwrite is occuring when resolving from a project file
37b6853 handle primary depot as relative path
53fdf24 Check for duplicate name/UUID input
8a6387c Remove redundant precompile statement
4d0901e Dont throw error when autocompleting faulty input (#1530)
d69f6d7 Refactor and test `Pkg.test` (#1427)
8ca8b6d PlatformEngines: use `tar -m` to ignore mtimes (#1537)
6797928 Make sure sandbox's temp Project.toml and Manifest.toml files are writable (#1534)
f968cc9 clarify: stacked envs only affect top-level loading (#1529)
0dfef59 PlatformEngines.download: add header support (#1531)
49ab53e Fix tree hashing with nested empty directories (#1522)
0c2dddd fix #1514: install_archive call in backwards_compatible_isolation (#1517)
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