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

Pickling of multivarlinreg objects #36

Merged
merged 4 commits into from
Mar 19, 2018
Merged

Pickling of multivarlinreg objects #36

merged 4 commits into from
Mar 19, 2018

Conversation

saroele
Copy link
Member

@saroele saroele commented Mar 8, 2018

This pull requests solves pickling issues with patsy in the multivarlinreg.
Solution: with __getstate__() and __setstate__() we can modify the object to be pickled and restore it.
Implementation details as described in the docstring of __getstate__() :

    Remove attributes that cannot be pickled and store as dict.

    Each fit has a model.formula which is a patsy ModelDesc and this cannot be pickled.
    We use our knowledge of this ModelDesc (as we build it up manually in the do_analysis() method)
    and decompose it into a dictionary.  This dictionary is stored in the list 'formulas',
    one dict per fit.

    Finally we have to remove each fit entirely (not just the formula), it is built-up again
    from self.formulas in the __setstate__ method.

ping @JrtPec who needs this functionality. Maybe you can check and merge this PR?

@coveralls
Copy link

Coverage Status

Coverage increased (+1.05%) to 92.027% when pulling 7fd46a5 on issue35 into 7a91d29 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+1.05%) to 92.027% when pulling 7fd46a5 on issue35 into 7a91d29 on master.

@JrtPec JrtPec merged commit 3a6af26 into master Mar 19, 2018
@JrtPec JrtPec deleted the issue35 branch March 19, 2018 18:54
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

3 participants