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

2-arg vectorized trunc doesn't work in Julia 0.5 #297

Closed
giordano opened this issue Jan 1, 2017 · 3 comments
Closed

2-arg vectorized trunc doesn't work in Julia 0.5 #297

giordano opened this issue Jan 1, 2017 · 3 comments

Comments

@giordano
Copy link

giordano commented Jan 1, 2017

In Julia 0.5

julia> trunc.(Int, 10rand(10))
ERROR: MethodError: no method matching size(::Type{Int64})
Closest candidates are:
  size{N}(::Any, ::Integer, ::Integer, ::Integer...) at abstractarray.jl:48
  size(::BitArray{1}) at bitarray.jl:39
  size(::BitArray{1}, ::Any) at bitarray.jl:43
  ...
 in broadcast_shape(::Type{T}, ::Array{Float64,1}) at ./broadcast.jl:31
 in broadcast_t(::Function, ::Type{Any}, ::Type{T}, ::Vararg{Any,N}) at ./broadcast.jl:213
 in broadcast(::Function, ::Type{T}, ::Array{Float64,1}) at ./broadcast.jl:230

Vectorized version of trunc is now preferred in master, after (probably) JuliaLang/julia#19791. Any chance to make it work in Julia 0.5 using Compat.jl?

@TotalVerb
Copy link
Contributor

See also related #291. Most of the broadcasting infrastructure would be quite difficult to backport, unfortunately.

@giordano
Copy link
Author

giordano commented Jan 2, 2017

See also related #291.

I know, I'm the same who reported that one ;-)

Most of the broadcasting infrastructure would be quite difficult to backport, unfortunately.

I suspected that, but keeping compatibility in packages for both 0.5 and 0.6 is hard. I have to choose between dropping support for 0.5 now and updating the package later. I think I'll do the former as soon as 0.6 is out.

@stevengj
Copy link
Member

stevengj commented Jan 2, 2017

We could define a limited number of broadcast and broadcast! methods just so that people can remove deprecations. e.g. broadcast(f::Function, T::Type, A::AbstractArray) = broadcast(x -> f(T, A), A) for the trunc, round, etcetera methods.

giordano added a commit to JuliaAstro/LombScargle.jl that referenced this issue Jan 7, 2017
`trunc.(Int, array)` does not work in Julia 0.5, nor a compatibility
utility currently exists to backport this syntax, unless
JuliaLang/Compat.jl#297 is fixed.
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

4 participants