Skip to content

MAINT: Deprecate link aliases - #8547

Merged
bashtage merged 3 commits into
statsmodels:mainfrom
bashtage:depr-link-aliases
Dec 8, 2022
Merged

bashtage merged 3 commits into
statsmodels:mainfrom
bashtage:depr-link-aliases

Conversation

@bashtage

@bashtage bashtage commented Dec 1, 2022

Copy link
Copy Markdown
Member
  • code/documentation is well formatted.
  • properly formatted commit message. See
    NumPy's guide.
Details

Notes:

  • It is essential that you add a test when making code changes. Tests are not
    needed for doc changes.
  • When adding a new function, test values should usually be verified in another package (e.g., R/SAS/Stata).
  • When fixing a bug, you must add a test that would produce the bug in main and
    then show that it is fixed with the new code.
  • New code additions must be well formatted. Changes should pass flake8. If on Linux or OSX, you can
    verify you changes are well formatted by running
    git diff upstream/main -u -- "*.py" | flake8 --diff --isolated
    
    assuming flake8 is installed. This command is also available on Windows
    using the Windows System for Linux once flake8 is installed in the
    local Linux environment. While passing this test is not required, it is good practice and it help
    improve code quality in statsmodels.
  • Docstring additions must render correctly, including escapes and LaTeX.

@bashtage

bashtage commented Dec 1, 2022 •

Copy link
Copy Markdown
Member Author

@josef-pkt What do you think about this? At a minimum the aliases should disappear from the docs to avoid all of the problems they create. I think it would be best to only have a canonical name.

@josef-pkt

Copy link
Copy Markdown
Member

Yes, I'm all in favor, #8323

@josef-pkt

Copy link
Copy Markdown
Member

another cleanup would be to rename all lower case (sub)classes that are not duplicates/aliases to standard python class names with capitalized first letter.
But that at least does not mess up the documentation.

warnings.simplefilter("error")
sm.families.NegativeBinomial(alpha=1.0)
with warnings.catch_warnings():
warnings.simplefilter("error")

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.

this is a check that NegativeBinomial raises if alpha is unchanged
needs to stay

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.

The warning for negbin is a UserWarning, AFAIR
so this could be more selective to handle both kinds of warning

I guess the following will only raise the UserWarning

sm.families.NegativeBinomial(link=sm.families.links.NegativeBinomial(alpha=1.0),
alpha=1.0)

def test_get_prediction(self):
with pytest.warns(DeprecationWarning):
# deprecation warning for linear keyword
pred1 = self.res1.get_prediction() # GLM

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.

why did you remove these?
I just added them a while ago.

pred_kwds = {}

pred_kwds['linear'] = False
# pred_kwds['linear'] = False

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.

is required to get a deprecation warning
I lost the deprecation warning and backwards compat behavior when I tried to drop this

will be merge conflict with my previous commit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Isn't the linear is deprecated warning old?

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.

AFAIR, only some in discrete like Poisson are old deprecations.
GLM is the most recent, added only 1 month ago #8505
GLM get_prediction is trickier because the return class differs between backwards compatible old "linear" usage and new "which" usage

@josef-pkt

Copy link
Copy Markdown
Member

In the family module, the families have link attributes which should use the new names
e.g. for Binomial family
links = [L.Logit, L.probit, L.cauchy, L.Log, L.LogC, L.CLogLog, L.LogLog, L.identity]

I'm waiting for this to be merged, then I will make a PR to make link check/exception optional. That would have many merge conflicts with the correction of families links attributes

@bashtage
bashtage merged commit e5d1a35 into statsmodels:main Dec 8, 2022
@bashtage
bashtage deleted the depr-link-aliases branch December 8, 2022 18:58
@bashtage

bashtage commented Dec 8, 2022

Copy link
Copy Markdown
Member Author

Same buggy test failed here as well.

@josef-pkt

Copy link
Copy Markdown
Member

I will cleanup some warnings.

I had 2 warnings for all genmod unit tests a few days ago, now there are 149 warnings

@josef-pkt

Copy link
Copy Markdown
Member

@bashtage
Why did you use FutureWarning instead of DeprecationWarning?
any specific reason?

@bashtage

bashtage commented Dec 9, 2022

Copy link
Copy Markdown
Member Author

Future warning is for users, deprecation warning is for library writers.

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.

2 participants