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

Handle arrays in rounding functions #45

Closed
wants to merge 1 commit into from
Closed

Handle arrays in rounding functions #45

wants to merge 1 commit into from

Conversation

rened
Copy link
Member

@rened rened commented Feb 18, 2015

In v0.3, only iround is able to deal with arrays when a type is specified:

using Compat
julia> round(Integer,[1.0,2.0])
2-element Array{Int64,1}:
 1
 2
julia> ceil(Integer,[1.0,2.0])
ERROR: `iceil` has no method matching iceil(::Type{Integer}, ::Array{Float64,1})
 in ceil at /Users/rene/.julia/v0.3/Compat/src/Compat.jl:66

This PR defines a new compatibility function for arrays, making the above pass (like in v0.4)

@simonster
Copy link
Member

Definitely a good idea. Can you add some tests?

@rened
Copy link
Member Author

rened commented Mar 2, 2015

@simonster Added some tests!

@@ -67,6 +67,11 @@ if VERSION < v"0.4.0-dev+1387"
end

@test round(Int, 3//4) == 1
for x in [(round, iround), (ceil, iceil), (floor, ifloor), (trunc, itrunc)]
for v = Any[1, 1.1, [1,1], [1.1, 1.1], [1 1], [1.1 1.1]]
@test @compat x[1](Int,v) == x[2](v)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't actually need @compat

@rened
Copy link
Member Author

rened commented Mar 4, 2015

Thanks for your comments, good points of course! Updated.

@simonster simonster closed this in 8339923 Mar 29, 2015
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

Successfully merging this pull request may close these issues.

2 participants