Skip to content

Commit

Permalink
Recommend mean((x, y)) rather than middle((x, y))
Browse files Browse the repository at this point in the history
It seems more logical and simpler for users to recommend using the
same function. This also helps making Statistics a standalone package
(#128) as `mean` will be moved to Julia Base,
but `middle` will remain in Statistics.
  • Loading branch information
nalimilan committed Aug 15, 2023
1 parent 14438ab commit 42cd821
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ if !isdefined(Base, :mean)
f(itr)
catch MethodError
rethrow(ArgumentError("""mean(f, itr) requires a function and an iterable.
Perhaps you meant middle(x, y)?""",))
Perhaps you meant mean((x, y))?"""))
end
Base.reduce_first(+, f_value)/1
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ end
@test isnan(@inferred mean(Iterators.filter(x -> true, Float64[])))

# using a number as a "function"
@test_throws "ArgumentError: mean(f, itr) requires a function and an iterable.\nPerhaps you meant middle(x, y)" mean(1, 2)
@test_throws "ArgumentError: mean(f, itr) requires a function and an iterable.\nPerhaps you meant mean((x, y))" mean(1, 2)
struct T <: Number
x::Int
end
Expand Down

0 comments on commit 42cd821

Please sign in to comment.