Skip to content

Update _smoothers_lowess.pyx - #5556

Merged
bashtage merged 1 commit into
statsmodels:masterfrom
r-barnes:patch-1
May 16, 2019
Merged

bashtage merged 1 commit into
statsmodels:masterfrom
r-barnes:patch-1

Conversation

@r-barnes

@r-barnes r-barnes commented Apr 4, 2019

Copy link
Copy Markdown
Contributor

The user is supposed to supply a value in the range [0,1] to the argument frac in the Lowess smoother, but this is not enforced! As a result, if the user mistakenly supplies a value such as frac=40 (for 40%) the software silently defaults to frac=1. Instead, the user should be alerted to this mistake.

The user is supposed to supply a value in the range [0,1] to the argument frac in the Lowess smoother, but this is not enforced! As a result, if the user mistakenly supplies a value such as frac=40 (for 40%) the software silently defaults to frac=1. Instead, the user should be alerted to this mistake.
@r-barnes

r-barnes commented Apr 4, 2019

Copy link
Copy Markdown
Contributor Author

Alternatively, this patch could go in the Python code for the Lowess smoother here; however, it seems as though the check should be placed as closely to the usage as possible to prevent other code paths from inadvertently supplying the bad values this is supposed to exclude.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.02%) to 84.538% when pulling 49224cf on r-barnes:patch-1 into a251e4c on statsmodels:master.

@codecov

codecov Bot commented Apr 4, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #5556 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5556      +/-   ##
==========================================
+ Coverage   82.02%   82.03%   +<.01%     
==========================================
  Files         588      588              
  Lines       93062    93062              
  Branches    10317    10317              
==========================================
+ Hits        76336    76345       +9     
+ Misses      14361    14355       -6     
+ Partials     2365     2362       -3
Impacted Files Coverage Δ
statsmodels/regression/mixed_linear_model.py 90.23% <0%> (+0.77%) ⬆️

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 a251e4c...49224cf. Read the comment docs.

@bashtage

Copy link
Copy Markdown
Member

Happy to merge this PR if you can write a test that shows that it works for frac <0 and frac > 1.

@r-barnes

r-barnes commented May 1, 2019

Copy link
Copy Markdown
Contributor Author

I'm afraid I'm not sure where or how to do that.

@bashtage

bashtage commented May 1, 2019

Copy link
Copy Markdown
Member

You need to add a function to

https://github.com/statsmodels/statsmodels/blob/master/statsmodels/nonparametric/tests/test_lowess.py

which has the name patters test_<SOMTHING_MEANINGFUL> that will hit this issue and check that the error is raised. To check that an error is raised, you can follow the pattern here:

with pytest.raises(MissingDataError):

@bashtage

Copy link
Copy Markdown
Member

Thanks. While this really should have a test, thanks for helping -- all improvements are welcome.

@bashtage
bashtage merged commit 46dea1f into statsmodels:master May 16, 2019
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.

3 participants