Skip to content

SUMM/REF: refactor link argument in family - #3370

Merged
josef-pkt merged 1 commit into
statsmodels:masterfrom
lorentzenchr:families_link
Jan 30, 2017
Merged

josef-pkt merged 1 commit into
statsmodels:masterfrom
lorentzenchr:families_link

Conversation

@lorentzenchr

Copy link
Copy Markdown
Contributor

This should solve issue #2913.

@josef-pkt

Copy link
Copy Markdown
Member

Looks good overall, based on very quick browsing of the changes.
I will have to look and think about the details of the API changes, e.g. has Tweediie or are also others backwards incompatible changes that don't go through deprecation.

@lorentzenchr

Copy link
Copy Markdown
Contributor Author

The Tweedie __init__ is the only backwards incompatible API change, AFAIK. Since Tweedie is very new, I thought this would be acceptable.

@thequackdaddy

Copy link
Copy Markdown
Member

@josef-pkt @lorentzenchr

As possibly the only user of Tweedie here, I'm totally on board with this. passing link arguments via family was always a sloppy workaround so this makes the parameters roles more clear.

Thanks!

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.01%) to 88.036% when pulling e8e4966 on lorentzenchr:families_link into 22f2766 on statsmodels:master.

@lorentzenchr

Copy link
Copy Markdown
Contributor Author

The Tweedie __init__ is the only backwards incompatible API change, AFAIK. Since Tweedie is very new, I thought this would be acceptable.

@josef-pkt

Copy link
Copy Markdown
Member

@lorentzenchr Sorry for the slow reply (I had another unplanned detour in topics this week)
Tweedie should be fine.
#2913 also mentions Tweedie refactoring, so this improves consistency.


def __init__(self, link, variance):
self.link = link()
if inspect.isclass(link):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can avoid loading the inspect module and check directly
isinstance(link, type)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that inspect.isclass(object) is implemented as isinstance(object, type), see source. But this might work for python 3 only. According to this stackoverflow answer, the python 2 version needs types.ClassType which was removed in python 3. So I would stick with inspect.isclass.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the stackoverflow question, but I think the problem is only with old style classes which we don't use. But I don't have a python 2 open right now to check

@josef-pkt
josef-pkt merged commit 706f4b9 into statsmodels:master Jan 30, 2017
@josef-pkt

Copy link
Copy Markdown
Member

merged @lorentzenchr Thank you

@TomAugspurger TomAugspurger mentioned this pull request Feb 1, 2017
4 of 28 tasks
@lorentzenchr
lorentzenchr deleted the families_link branch February 1, 2017 17:28
TomAugspurger pushed a commit to TomAugspurger/statsmodels that referenced this pull request Feb 2, 2017
REF: refactor link argument in family
(cherry picked from commit 706f4b9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants