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

remove some ::Callable argument restrictions no longer necessary #29692

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ function mapreduce_impl(f, op::Union{typeof(max), typeof(min)},
v
end

maximum(f::Callable, a) = mapreduce(f, max, a)
minimum(f::Callable, a) = mapreduce(f, min, a)
maximum(f, a) = mapreduce(f, max, a)
minimum(f, a) = mapreduce(f, min, a)

"""
maximum(itr)
Expand Down
2 changes: 1 addition & 1 deletion base/reducedim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ for (fname, _fname, op) in [(:sum, :_sum, :add_sum), (:prod, :_prod,
@eval begin
# User-facing methods with keyword arguments
@inline ($fname)(a::AbstractArray; dims=:) = ($_fname)(a, dims)
@inline ($fname)(f::Callable, a::AbstractArray; dims=:) = ($_fname)(f, a, dims)
@inline ($fname)(f, a::AbstractArray; dims=:) = ($_fname)(f, a, dims)

# Underlying implementations using dispatch
($_fname)(a, ::Colon) = ($_fname)(identity, a, :)
Expand Down
2 changes: 1 addition & 1 deletion base/set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ julia> unique(x -> x^2, [1, -1, 3, -3, 4])
4
```
"""
function unique(f::Callable, C)
function unique(f, C)
out = Vector{eltype(C)}()
seen = Set()
for x in C
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Statistics/src/Statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ julia> mean([√1, √2, √3])
1.3820881233139908
```
"""
function mean(f::Base.Callable, itr)
function mean(f, itr)
y = iterate(itr)
if y === nothing
return Base.mapreduce_empty_iter(f, Base.add_sum, itr,
Expand All @@ -73,7 +73,7 @@ function mean(f::Base.Callable, itr)
end
return total/count
end
mean(f::Base.Callable, A::AbstractArray) = sum(f, A) / length(A)
mean(f, A::AbstractArray) = sum(f, A) / length(A)

"""
mean!(r, v)
Expand Down