JuliaStats / Statistics.jl

The Statistics stdlib that ships with Julia.
https://juliastats.org/Statistics.jl/dev/
Other
72 stars 40 forks source link

Wrong docstring for Statistics.mean #109

Closed cossio closed 2 years ago

cossio commented 2 years ago

Docstring for mean says that:

mean(f::Function, itr) Apply the function f to each element of collection itr and take the mean.

However, mean also works with callable structs, not just f::Function.

The docstring should be updated to reflect that.

Moelf commented 2 years ago

just remove ::Function? vocally we just mean callable here but since it's not a type and we don't have such an interface, we can keep using the "function" with small "f" to mean callable

jishnub commented 2 years ago

I'll not say that the docstring is wrong, as the suggested use is definitely valid. Perhaps it's better to suggest that the docstring is too narrow in scope.

ViralBShah commented 2 years ago

@nalimilan Should this be filed in the Statistics.jl repo?

nalimilan commented 2 years ago

Right. I've just filed https://github.com/JuliaLang/Statistics.jl/pull/110, which makes the minimal change of removing ::Function. This is consistent with the docstring for sum. "Function" is probably clearer for users than "callable" and the signature conveys the fact that any type is accepted for f.