Skip to content

Fix a bunch of NameErrors by adding missing imports etc - #3515

Closed
jbrockmendel wants to merge 6 commits into
statsmodels:masterfrom
jbrockmendel:flake8_fixes
Closed

jbrockmendel wants to merge 6 commits into
statsmodels:masterfrom
jbrockmendel:flake8_fixes

Conversation

@jbrockmendel

Copy link
Copy Markdown
Contributor

Ran:

flake8 --filename=./statsmodels/tsa/* | grep undefined

and went through to fix everything it turned up. In most cases it was just a matter of a missing import. In a couple there were method definitions missing keyword arguments that could be inferred by context.

The two cases most deserving double-checking are

  1. tsa.kalmanf.StateSpaceModel.kalmanfilter --> Assumed that call to _univariatefilter was intended to be self._univariatefilter defined two methods earlier.
  2. tsa.vector_ar.SVARResults.sirf_errband_mc --> Assumed that definition of opt_B should mirror the case 19 lines later.

One case left un-handled was calls to ARIMAProcess in tsa.arima_process. Didn't want to guess what was intended there.

For now just looked at tsa/*, will do the same for other directories if this PR is OK.

@josef-pkt

Copy link
Copy Markdown
Member

@jbrockmendel Thanks
This looks good based on the brief look. We need to check some of those, e.g. in SVAR, because I'm not sure how good test coverage is. If there is a flake error, it should mean that there is no test coverage for it.

in general: making changes across modules might result in merge conflicts with other PRs. This would affect at most a few modules, but a quick search of open PRs with label:comp-xxx might be useful. (That's what I will have to do before merging.)

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.0001%) to 90.282% when pulling 14f33df on jbrockmendel:flake8_fixes into ab03a63 on statsmodels:master.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.0001%) to 90.282% when pulling 14f33df on jbrockmendel:flake8_fixes into ab03a63 on statsmodels:master.

@bashtage

Copy link
Copy Markdown
Member

I would suggest not fixing thing in name == main -- rather it would be better to delete these.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

@bashtage I'm inclined to agree, but for now am trying to be non-opinionated while getting up to speed with the code-base.

@josef-pkt

Copy link
Copy Markdown
Member

to the __main__ code
If you are looking at the sandbox modules, then the part in the "if main" are often the only examples to show what the module was or is supposed to do.
In some cases I have moved those parts into the internal examples folders, but so far I have avoided trying to do a full sandbox cleanup because I didn't want to decide what is obsolete and what might still be reused.
The sandbox is like stalled PRs, that we wrote in the early years of statsmodels. Some is obsolete or superseded by newer code or by new packages outside of statsmodels. Some of it can likely be picked up again at some point. Some of it is like an 85% finished PR that just needs some final cleaning and adding missing unit tests. Some of it is dead because it's unlikely that someone is getting interested in it again.

I think outside of the sandbox almost all if __name__ == '__main__' should be gone by now.

@josef-pkt

Copy link
Copy Markdown
Member

this type of PRs are not necessarily good for users: Instead of exceptions they might get incorrect numbers without any indication that they are not unit tested.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

I can get on board with erring on the side of correctness. Would you prefer NotImplementedErrors instead? Something that communicates to users that we're aware of the issue.

Heck, an error of the form NotImplementedError("If you have an example we can make it into a test case") could be a win-win.

@jbrockmendel jbrockmendel mentioned this pull request May 28, 2017
@jbrockmendel

Copy link
Copy Markdown
Contributor Author

This is a dead-letter.

@jbrockmendel
jbrockmendel deleted the flake8_fixes branch June 2, 2017 16:27
@jbrockmendel jbrockmendel mentioned this pull request Sep 6, 2018
49 of 94 tasks
@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.

4 participants