Skip to content

BUG: Remove change of global pickle method - #4963

Merged
josef-pkt merged 1 commit into
statsmodels:masterfrom
bashtage:fix-functional-pickle
Sep 15, 2018
Merged

josef-pkt merged 1 commit into
statsmodels:masterfrom
bashtage:fix-functional-pickle

Conversation

@bashtage

Copy link
Copy Markdown
Member

Refactor PCA and Kernel methods to avoid instance methods
Remove buggy pickling method change in functional graphics

closes #4772

@jbrockmendel

Copy link
Copy Markdown
Contributor

+1

@coveralls

coveralls commented Aug 22, 2018 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.004%) to 83.915% when pulling 064c5c3 on bashtage:fix-functional-pickle into 4b57473 on statsmodels:master.

@bashtage
bashtage force-pushed the fix-functional-pickle branch from 56b9766 to fb6787e Compare August 23, 2018 11:09
@codecov-io

codecov-io commented Aug 23, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #4963 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4963      +/-   ##
==========================================
+ Coverage   81.41%   81.43%   +0.01%     
==========================================
  Files         581      581              
  Lines       90277    90271       -6     
  Branches    10101    10103       +2     
==========================================
+ Hits        73503    73508       +5     
+ Misses      14485    14478       -7     
+ Partials     2289     2285       -4
Impacted Files Coverage Δ
statsmodels/graphics/functional.py 78.03% <100%> (-0.09%) ⬇️
statsmodels/multivariate/pca.py 95.36% <100%> (+0.01%) ⬆️
statsmodels/nonparametric/kernel_regression.py 93.21% <100%> (ø) ⬆️
statsmodels/nonparametric/_kernel_base.py 89.18% <100%> (+0.17%) ⬆️
statsmodels/regression/mixed_linear_model.py 89.77% <0%> (+0.79%) ⬆️

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 4b57473...064c5c3. Read the comment docs.

@jbrockmendel jbrockmendel mentioned this pull request Sep 8, 2018
31 of 32 tasks
@bashtage
bashtage force-pushed the fix-functional-pickle branch 2 times, most recently from bf0860f to eaabf14 Compare September 10, 2018 21:04
Refactor PCA and Kernel methods to avoid instance methods
Remove buggy pickling method change in functional graphics

closes statsmodels#4772
@bashtage
bashtage force-pushed the fix-functional-pickle branch from eaabf14 to 064c5c3 Compare September 11, 2018 07:19
@josef-pkt

Copy link
Copy Markdown
Member

LGTM,
copyreg was added in #4049, based on a quick look I don't see what it was needed for, i.e. if some pickling doesn't work anymore and we don't have unit tests for it.

merging

@bashtage Thank you

@josef-pkt
josef-pkt merged commit 3bb3ef2 into statsmodels:master Sep 15, 2018
@bashtage
bashtage deleted the fix-functional-pickle branch September 15, 2018 18:54
@josef-pkt josef-pkt added this to the 0.10 milestone Sep 15, 2018
@bashtage

Copy link
Copy Markdown
Member Author

It was added to allow pickling of instances from what I can tell. Instances that use dicts to hold functions can't be trivially pickled and so these should be avoided. It would be a good idea to test pickling everything model in the api and every result to avoid these issues in the future.

@josef-pkt

josef-pkt commented Sep 15, 2018 •

Copy link
Copy Markdown
Member

We have pickling and remove_data tests in base for the core models outside of tsa. But this might not have kept up with recent models, and does not cover non-model objects that don't inherit base models e.g. remove_data, load and save are LikelihoodModelResults methods.

@jbrockmendel

Copy link
Copy Markdown
Contributor

Instances that use dicts to hold functions can't be trivially pickled and so these should be avoided

The only remaining special cases that come to mind are NegativeBinomial and DiscreteResults. De-special-izing those would not be too difficult.

remove_data, load and save are LikelihoodModelResults methods

load and save are also duplicated in wrapper.ResultsWrapper. I'm not clear on why they are needed in both places, but not gonna make a big deal out of it. Is there a compelling reason why these are in LikelihoodModelResults instead of just Results?

We have pickling and remove_data tests in base for the core models outside of tsa

The current implementation of remove_data makes it really easy for things to fall through the cracks, see #4421.

@josef-pkt

Copy link
Copy Markdown
Member

I don't remember why the wrapper also has load save, I guess it is because we also need to pickle the wrapper class and not just the underlying results class.
There is no explanation for this in #188 and some related issues that I briefly checked

The advantage of the current implementation is that it is "boring", i.e. it's conceptually very simple and we mainly need to check that everything is in the white lists.

I didn't check: I think ZeroInflated and similar models will most likely not work correctly with remove_data, because the model contains submodels that need to be handled separately.

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.

statsmodels.graphics.functional pickle issue

5 participants