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

ENH: Make handle_data overwritable by subclasses. #1416

Merged
merged 1 commit into from Feb 21, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions statsmodels/base/model.py
Expand Up @@ -54,18 +54,25 @@ class Model(object):
def __init__(self, endog, exog=None, **kwargs):
missing = kwargs.pop('missing', 'none')
hasconst = kwargs.pop('hasconst', None)
self.data = handle_data(endog, exog, missing, hasconst, **kwargs)
self.data = self._handle_data(endog, exog, missing, hasconst,
**kwargs)
self.k_constant = self.data.k_constant
self.exog = self.data.exog
self.endog = self.data.endog
# kwargs arrays could have changed, easier to just attach here
for key in kwargs:
# pop so we don't start keeping all these twice or references
setattr(self, key, self.data.__dict__.pop(key))
try:
setattr(self, key, self.data.__dict__.pop(key))
except KeyError: # panel already pops keys in data handling
pass
self._data_attr = []
self._data_attr.extend(['exog', 'endog', 'data.exog', 'data.endog',
'data.orig_endog', 'data.orig_exog'])

def _handle_data(self, endog, exog, missing, hasconst, **kwargs):
return handle_data(endog, exog, missing, hasconst, **kwargs)

@classmethod
def from_formula(cls, formula, data, subset=None, *args, **kwargs):
"""
Expand Down