test in links require exact class so Logit can't work in place of logit #2036

Closed
brentp opened this Issue Oct 9, 2014 · 1 comment

Projects

None yet

2 participants

@brentp
brentp commented Oct 9, 2014

Since logit is a subclass of Logit and the test is for isinstance(link, links), then class attribute links must always have the parent class because Logit is not an instance of logit.

This could be fixed by :

  • using logit = Logit in links.py instead of subclassing
  • using Logit in place of logit in Binomial.links (and never using subclass anywhere else)
  • change test to check issubclass instead of isinstance

Below is the code to reproduce:

from statsmodels.api import GLM
from statsmodels.genmod.families import Binomial
from statsmodels.genmod.families.links import Logit, logit

import numpy as np

x = np.random.randn(15)
y = np.zeros_like(x)

# this works
print GLM(x, y, family=Binomial(link=logit))

# this doesnt
print GLM(x, y, family=Binomial(link=Logit))
@josef-pkt
Member

I'm closing as duplicate of #1509
see PR #1880 which doesn't fix the check, but allows users to turn it off

searching for the issue I also found #28 which might be one of our oldest issues (2009)

@josef-pkt josef-pkt closed this Oct 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment