Closed KronosTheLate closed 1 year ago
Unfortunately we can't do that, as we need to allow any callable object, which includes any type. The same problem applies to many methods in Base.
Also note that sum(1, 1)
has the same problem. This should be changed in Base first if we wanted to change this here.
So... should this be changed in base? It is an issue here until it is fixed there, so instead of closing this issue, would it not be more appropriate to open an issue in base and refer to this (still existing and therefore open) issue? Or are you saying that this can not really ever be fixed, and is therefore not to be considered an issue?
I don't think this can be fixed, so you could try to discuss this in Base but I'm pretty sure about the outcome. But see https://github.com/JuliaStats/Statistics.jl/pull/131 for an alternative "fix".
Alright, that seems like a better fix - to dispatch only on the case with numbers passed. So then I know that this issue is still noted and worked on somewhere - thanks ^_^
Duplicate of #100
A naive user (like me) might expect there to be a vararg method for
mean
, which computes the mean of all arguments if they are numbers [1]. However, if one tries to do that, a not-so-helpful error is produced:This PR restricts the type of
f
, so that an appropriateMethodError
should be thrown (I have not tested).[1] An alternative fix would be to define such a method, as in
mean(args::Number...) = mean([args...])
. I am not sure what is preferable, but the suggested PR seems more clear.