Skip to content

Commit

Permalink
remove some ::Callable argument restrictions no longer necessary (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Oct 19, 2018
1 parent 5f2759d commit 45e2ddf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
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

0 comments on commit 45e2ddf

Please sign in to comment.