JuliaStats / Statistics.jl

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

Fix hint on mean(::Number, ::Number) #131

Closed LilithHafner closed 1 year ago

LilithHafner commented 1 year ago

Back before I know about middle, I tried mean(1, 2) and was briefly confused before settling on mean((1, 2)) or mean([1, 2]). A better hint in the error message would have helped me.

Before:

julia> mean(1, 2)
ERROR: MethodError: objects of type Int64 are not callable
Maybe you forgot to use an operator such as *, ^, %, / etc. ?
Stacktrace:
[...]

After:

julia> mean(1, 2)
ERROR: ArgumentError: mean(f, itr) requires a function and an iterable.
       Perhaps you meant middle(x, y)?
Stacktrace:
[...]

Fixes #99

LilithHafner commented 1 year ago

This adds more code just for an error message, so I can see why folks might be hesitant to merge it and/or decide to decline this PR. Is that what is happening, or has this simply fallen by the wayside?

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 :tada:

Comparison is base (a3feba2) 96.94% compared to head (620d9d7) 96.98%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #131 +/- ## ========================================== + Coverage 96.94% 96.98% +0.03% ========================================== Files 1 1 Lines 426 431 +5 ========================================== + Hits 413 418 +5 Misses 13 13 ``` | [Impacted Files](https://app.codecov.io/gh/JuliaStats/Statistics.jl/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats) | Coverage Δ | | |---|---|---| | [src/Statistics.jl](https://app.codecov.io/gh/JuliaStats/Statistics.jl/pull/131?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL1N0YXRpc3RpY3Muamw=) | `96.98% <100.00%> (+0.03%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

LilithHafner commented 1 year ago

Bump