Skip to content

MAINT/TST: Fix/Silence DeprecationWarnings - #5132

Closed
jbrockmendel wants to merge 10 commits into
statsmodels:masterfrom
jbrockmendel:manywarns3
Closed

jbrockmendel wants to merge 10 commits into
statsmodels:masterfrom
jbrockmendel:manywarns3

Conversation

@jbrockmendel

Copy link
Copy Markdown
Contributor

Each commit addresses a single source of these warnings.

Kept peripheral cleanup to a near minimum (the case that strayed farthest from this goal was that last commit, which touches regression._prediction and genmod._prediction).

It's conceivable that the way _penalties currently works is intentional, but it looks like grad was deprecated but internal usage was not updated to reflect that. If this perception is wrong then this commit will have to be reverted and those warnings addressed separately.

Made an executive decision to stop passing through numpy's RuntimeWarnings when tvalues includes a division by zero. On balance those tend to occur when other convergence-type problems occur, and an additional warning isn't all that helpful.

patsy change to make design_info.builder not need the .builder is effective as of patsy4.0, which is the required version according to setup.py

@bashtage

bashtage commented Sep 7, 2018

Copy link
Copy Markdown
Member

Only the massive set of new warnings should be suppressed. 0 div should still be allowed since these are really errors in test design.

Comment thread statsmodels/base/data.py Outdated
@classmethod
def _drop_nans(cls, x, nan_mask):
if hasattr(x, 'ix'):
if hasattr(x, 'loc'):

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.

cleaner to check for Series, DataFrame

Comment thread statsmodels/base/data.py Outdated
@classmethod
def _drop_nans_2d(cls, x, nan_mask):
if hasattr(x, 'ix'):
if hasattr(x, 'loc'):

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.

same

Comment thread statsmodels/base/model.py Outdated
Return the t-statistic for a given parameter estimate.
"""
return self.params / self.bse
with np.errstate(divide="ignore"):

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.

Should be shown to end users. Probably don't suppress here or in tests.

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.

Will revert here; merits discussion elsewhere.

lam = np.empty(shape=(self.nres,))
for i in range(self.nres):
ind = np.random.random_integers(0, n-1, size=(n,1))
ind = np.random.randint(0, n-1, size=(n, 1))

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.

Needs to be (0,n,size=(n,1)) -> not the deprecation warning saying +1. Former was closed. This is open.

e = e - np.mean(e) # recenter residuals
for i in range(self.nboot):
ind = np.random.random_integers(0, n-1, size=(n,1))
ind = np.random.randint(0, n-1, size=(n, 1))

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.

Same, (0,n)

----------
See Racine, J.: "Consistent Significance Testing for Nonparametric
Regression" Journal of Business \& Economics Statistics.
Regression" Journal of Business \\& Economics Statistics.

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 does this need any escaping?

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.

I'd be happy without; assumed previous author had a reason. Will change.

@@ -59,8 +59,8 @@ class TheilGLS(GLS):

.. math:: q = R \beta + v

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.

Better to make the docstring raw and leave single escapes than to mix and match escaped-escapes and non-escape sequences (e.g., \ and \b)

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.

Yah, wasn't super-happy with this mixed case thing.

:math:`E(u) = 0`, :math:`cov(u) = \Sigma`
:math:`cov(u, v) = \Sigma_p`, with full rank.
:math:`E(u) = 0`, :math:`cov(u) = \\Sigma`
:math:`cov(u, v) = \\Sigma_p`, with full rank.

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.

raw docstrings are just better with LaTeX math

@bashtage

bashtage commented Sep 7, 2018

Copy link
Copy Markdown
Member

I have quite a few that you don't have. but we have overlap, so will have conflicts Feel free to take them from mine into this and I'll close mine.

@bashtage bashtage mentioned this pull request Sep 7, 2018
@bashtage

bashtage commented Sep 7, 2018

Copy link
Copy Markdown
Member

I should add the dead simplest way to avoid these warnings (temporarily) is to

pip install pytest==3.7

which will pin to the last version that worked.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

Only the massive set of new warnings should be suppressed. 0 div should still be allowed since these are really errors in test design.

Fair enough.

so will have conflicts Feel free to take them from mine into this and I'll close mine.

I was thinking that you're more likely to get this past the maintainer in a timely manner than I am, so we should go the other way.

@josef-pkt

josef-pkt commented Sep 7, 2018 •

Copy link
Copy Markdown
Member

Can your make a PR with just this:
pip install pytest==3.7

I'm not sure whether there is not also a bug in pytest 3.8, and I would rather not change a lot of things right away, and let other packages figure this out first.
I'm a bit suspicious whether all this backslashes are really incorrect.

also there is https://github.com/pytest-dev/pytest/issues/3945 which I don't know how it affects us.
We have a huge amount of setup code. where we don't want to see warnings a Million times.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

I'm not sure whether there is not also a bug in pytest 3.8

What bug are you referring to?

I'm a bit suspicious whether all this backslashes are really incorrect.

Referring to regexes or docstrings or both?

and I would rather not change a lot of things

Totally out of character.

bashtage and I have unfortunate timing when it comes to trying to be helpful. I think the thing to do is merge #5135 when feasible and I'll rebase+repush with just the non-overlapping changes.

@bashtage

bashtage commented Sep 7, 2018 via email

Copy link
Copy Markdown
Member

@josef-pkt

Copy link
Copy Markdown
Member

what about the regexes like \[ ?
If you switch back to older pytest, then we see whether the unit tests actually still pass, instead of trying to get results through the warnings avalanche.

(Even if everything is fine, then I don't want to see the same deprecation warnings a thousand times each time pandas or numpy changes something that affects patsy or statsmodels.)

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

Rebased following #5135.

@bashtage

bashtage commented Sep 7, 2018

Copy link
Copy Markdown
Member

LGTM

@jbrockmendel jbrockmendel mentioned this pull request Sep 8, 2018
31 of 32 tasks
@jbrockmendel

Copy link
Copy Markdown
Contributor Author

@josef-pkt should I bother rebasing or is that just going to clog the CI?

@bashtage

bashtage commented Sep 9, 2018

Copy link
Copy Markdown
Member

Should be rebased and merged. Solves, among other issues, statsmodels calling code that statsmodels has deprecated.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

@josef-pkt is using the deprecated methods in penalties intentional? It seems that updating to using the non-deprecated methods is causing test failures.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

@josef-pkt this actually includes a non-trivial thing that does need your attention

@bashtage bashtage mentioned this pull request May 1, 2019
4 tasks done
@jbrockmendel
jbrockmendel deleted the manywarns3 branch May 2, 2019 17:22
@bashtage bashtage added the rejected Used for PRs with changes that are not acceptable label Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rejected Used for PRs with changes that are not acceptable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants