New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept any iterable in scalar stats #472
Conversation
Also improve a few docstrings.
count = 1 | ||
value, state = y | ||
y = iterate(x, state) | ||
# Use Welford algorithm as seen in (among other places) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's too bad I needed to copy the code from var
, but if we move this to Statistics it will be easy to share the code in a common internal method.
Codecov Report
@@ Coverage Diff @@
## master #472 +/- ##
==========================================
- Coverage 85.12% 83.76% -1.37%
==========================================
Files 21 21
Lines 2098 2156 +58
==========================================
+ Hits 1786 1806 +20
- Misses 312 350 +38
Continue to review full report at Codecov.
|
A solid improvement on the state of the world |
Make a copy when the element type is not concrete to ensure we choose an appropriate eltype.
Nice! Is this good to go? I think it's a really important improvement now that |
function mean_and_var(A::RealArray, w::AbstractWeights; corrected::DepBool=nothing) | ||
m = mean(A, w) | ||
v = varm(A, w, m; corrected=depcheck(:mean_and_var, corrected)) | ||
function mean_and_var(x::RealArray, w::AbstractWeights; corrected::DepBool=nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we still expect RealArray
here? I thought this should also work with other arrays. E.g. Vector{Union{Missing, Float64}}
as long as it does not contain missing
(which will simply throw an error at run time if it does). Same questions for methods below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there are many other things to fix in this file. I'd rather fix them separately in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is OK to leave it for later. I reacted because you explicitly named this PR "Accept any iterable ..." 😄 so I thought this is exactly the change you want to make in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the title is a bit too ambitious.
OK to merge then? |
Also improve a few docstrings.
Part of #449. Closes #342. Cc: @oxinabox