Skip to content
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

Throw an error when passing empty input to cov #93

Merged
merged 1 commit into from
Oct 26, 2021
Merged

Conversation

nalimilan
Copy link
Member

@nalimilan nalimilan commented Oct 26, 2021

https://github.com/JuliaLang/Statistics.jl/pull/85 unintentionnally changed the behavior of cov, which now allows passing two empty vectors instead of throwing an error. This is inconsistent with cor. If we wanted to return a value, NaN would be more appropriate and consistent with var, but for now make this an error again.

Also add tests to cover all empty inputs for similar functions. Unfortunately it turns out we are quite inconsistent already, as
cor and cov allow empty matrices already, but cov returns -0.0 while cor, std and var return NaN.

This change should be backported to Julia 1.7 before it is released to avoid breaking code if we do it later.

74897fe unintentionnally changed the behavior of `cov`,
which now allows passing two empty vectors instead of throwing an error.
This is inconsistent with `cor`. If we wanted to return a value, `NaN`
would be more appropriate and consistent with `var`,
but for now make this an error again.

Also add tests to cover all empty inputs for similar functions.
Unfortunately it turns out we are quite inconsistent already, as
`cor` and `cov` allow empty matrices already, but `cov` returns `-0.0`
while `cor`, `std` and `var` return `NaN`.
@codecov
Copy link

codecov bot commented Oct 26, 2021

Codecov Report

Merging #93 (2f8cda4) into master (74897fe) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
+ Coverage   96.89%   96.91%   +0.02%     
==========================================
  Files           1        1              
  Lines         419      422       +3     
==========================================
+ Hits          406      409       +3     
  Misses         13       13              
Impacted Files Coverage Δ
src/Statistics.jl 96.91% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 74897fe...2f8cda4. Read the comment docs.

@nalimilan nalimilan merged commit 52998f2 into master Oct 26, 2021
@nalimilan nalimilan deleted the nl/covempty branch October 26, 2021 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants