Skip to content

Commit

Permalink
Merge pull request #1417 from jseabold/handle-data-pop
Browse files Browse the repository at this point in the history
REF: Let subclasses keep kwds attached to data.
  • Loading branch information
jseabold committed Feb 21, 2014
2 parents f10efe3 + 1263b66 commit 5fc8352
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions statsmodels/base/model.py
Expand Up @@ -59,19 +59,20 @@ def __init__(self, endog, exog=None, **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
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)
data = handle_data(endog, exog, missing, hasconst, **kwargs)
# 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
try:
setattr(self, key, data.__dict__.pop(key))
except KeyError: # panel already pops keys in data handling
pass
return data

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

0 comments on commit 5fc8352

Please sign in to comment.