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

map(Integer, ::Vector{Any}) throws #10633

Closed
simonster opened this issue Mar 25, 2015 · 7 comments
Closed

map(Integer, ::Vector{Any}) throws #10633

simonster opened this issue Mar 25, 2015 · 7 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@simonster
Copy link
Member

julia> map(Integer, Any[1, 2])
ERROR: MethodError: `one` has no method matching one(::Type{Any})
 in map at abstractarray.jl:379
hayd added a commit to hayd/julia that referenced this issue Mar 26, 2015
@simonster simonster added the bug Indicates an unexpected problem or unintended behavior label Mar 26, 2015
@hayd
Copy link
Member

hayd commented Mar 26, 2015

Should this return Integer[1, 2]? If so, I have a fix (not the above commit).

@JeffBezanson
Copy link
Member

Ideally no; it should return Int[1, 2]. However for empty arrays it could use the trick in your commit.

@hayd
Copy link
Member

hayd commented Mar 26, 2015

The example I was testing in my branch was Any[1, 2., Int8(3), UInt8(4)], though perhaps this is an unreasonable example. (map in abstractarray gets the eltype from the first element.)

@simonster
Copy link
Member Author

Are these methods actually necessary? On my system, they don't actually seem any faster than the general map method:

julia> x = map(Float64, rand(Int, 100000000));

julia> @time for i = 1:10; map(Integer, x); end
elapsed time: 2.734174725 seconds (7629 MB allocated, 1.92% gc time in 9 pauses with 1 full sweep)

julia> @time for i = 1:10; invoke(map, (Any, Vector), Integer, x); end
elapsed time: 2.658263088 seconds (7629 MB allocated, 0.67% gc time in 9 pauses with 0 full sweep)

julia> @time for i = 1:10; map(Integer, x); end
elapsed time: 2.73453461 seconds (7629 MB allocated, 0.66% gc time in 9 pauses with 0 full sweep)

julia> @time for i = 1:10; invoke(map, (Any, Vector), Integer, x); end
elapsed time: 2.633010239 seconds (7629 MB allocated, 0.67% gc time in 9 pauses with 0 full sweep

@JeffBezanson
Copy link
Member

Yes, it's definitely arguable that these definitions just complicate things and should use the same map as everything else. I think they originate from trying to get a better type for the empty array case.

@simonster
Copy link
Member Author

We could use a comprehension, but that's just kicking the can down the road on #7258.

@JeffBezanson JeffBezanson changed the title map(::Integer, ::Vector{Any}) throws map(Integer, ::Vector{Any}) throws Apr 25, 2015
@vtjnash
Copy link
Member

vtjnash commented Jul 20, 2016

@JeffBezanson can we fix this now?

@JeffBezanson JeffBezanson self-assigned this Aug 16, 2016
JeffBezanson added a commit that referenced this issue Aug 17, 2016
fix #10633, remove redundant definitions for `map(Integer, a)` etc.
tkelman pushed a commit that referenced this issue Aug 21, 2016
mfasi pushed a commit to mfasi/julia that referenced this issue Sep 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants