StatsBase.jl icon indicating copy to clipboard operation
StatsBase.jl copied to clipboard

functions that only support finite weights now throw errors for non-finites

Open aplavin opened this issue 1 year ago • 3 comments

AbstractWeights can contain any values, including NaNs – and many StatsBase functions work with them just fine. But not all, for some like sample it doesn't make sense. So, here I make these functions throw an exception instead of returning a potentially incorrect result.

Some docstrings, like the one for quantile, even explicitly say that

An error is raised if w contains any NaN values.

but this wasn't the case without this PR.

Ideally, NaNs should also be supported by concrete weights types included into StatsBase (https://github.com/JuliaStats/StatsBase.jl/issues/904), but this PR is independent of that.

aplavin avatar Jan 21 '24 21:01 aplavin

Nightly test failures unrelated

aplavin avatar Jan 21 '24 22:01 aplavin

bump... would be nice to turn silently wrong results into errors here

aplavin avatar Feb 06 '24 19:02 aplavin

another bump...

aplavin avatar Mar 03 '24 03:03 aplavin

and another bump...

aplavin avatar Mar 27 '24 20:03 aplavin

yet another bump...

aplavin avatar Apr 08 '24 08:04 aplavin

yet yet another bump...

aplavin avatar Apr 18 '24 18:04 aplavin

yet yet yet another bump...

aplavin avatar Apr 30 '24 01:04 aplavin

The PR can't be merged? "This branch has conflicts that must be resolved" and tests are failing.

devmotion avatar Apr 30 '24 08:04 devmotion

The PR can't be merged?

Idk the policy here, but saw that you approved these changes 1.5 months ago.

"This branch has conflicts that must be resolved"

I think these conflicts are due to code changes after this PR was created/approved. This is impossible to avoid in advance, of course the longer the PR stays unmerged the more conflicts will appear. Happy to update & resolve conflicts if you confirm that this PR will be merged after that.

tests are failing

Failures unrelated to changes in this PR:

Error During Test at /home/runner/work/StatsBase.jl/StatsBase.jl/test/scalarstats.jl:227
 Unexpected Pass
 Expression: (#= /home/runner/work/StatsBase.jl/StatsBase.jl/test/scalarstats.jl:227 =# @benchmark(mad($itr))).allocs < 200
 Got correct result, please change to @test if no longer broken.

aplavin avatar Apr 30 '24 12:04 aplavin

yet yet yet yet another bump...

aplavin avatar May 16 '24 12:05 aplavin

yet yet yet yet yet another bump...

aplavin avatar Jun 05 '24 13:06 aplavin

yet yet yet yet yet yet another bump...

aplavin avatar Jun 17 '24 17:06 aplavin