New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAINT: split distributions.py into three files #3134
Conversation
can you check what git blame shows on your computer? github doesn't track moves or renames. |
Putting it in a single commit is probably as good as it gets. |
@josef-pkt I'm pretty bad with git, so I don't know what options to use for git blame. The git commit command gave the following interpretation:
According to some googling, I don't think that git can track blame across splits, although it can track renaming. In this case, I think that it treats |
@argriffing I use git gui which has Browse Branch Files that can be used the follow a line through it's history. git is much better in this than other vcs, It can keep track of cut and paste as long as the two segments don't diverge much. |
@josef-pkt I don't have gui access to the machine I'm using for development, but I locally cloned the argriffing/scipy repo and checked out the specific retry-split-distribution branch, and much of the git-gui blame history seems to be available. Opposite of git's stdout output from my commit, the blame history seems almost full for |
Because the diffs are hard to read, I'll add some extra commentary that might help reviewing. The split was easier than I was afraid it might be, but two parts needed more attention than just copying and pasting. First, the base class of continuous and discrete distributions calls globals() at one point when it needs to do something related to docstring generation (I think), and this broke when the files were split. I patched this by just letting that function take an extra optional parameter which I used to pass the globals() from the file with the derived class (discrete only). Second, both the continuous and discrete distributions use a noncentral chi square distribution, so I put the logpdf, cdf, and pdf of this class into the third file and called them from the continuous-specific and discrete-specific classes. |
try: | ||
meth = globals()[name] | ||
except KeyError: | ||
meth = morevars[name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this second nested try/except and added the optional argument morevars
so that rv_discrete
can pass its globals()
into this base class function. This works around problems caused by the effect of file splitting on the dictionary returned by globals()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC adding this was an attempt to work around the problem with inspect
ing the signatures of _pdf
and friends for discrete sample distribution, where global module-level functions are being attached as instancemethods
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the first try-except and passing around globals()
can be avoided altogether by passing to _construct_argparser
the methods themselves, rather than their names.
(No idea why I made it more complicated than it actually needs to be.) Can you have a look at ev-br@7840023? I tried sending a PR against your PR but I don't seem to be able to figure out how to do it.
I added line comments to the parts that needed special attention when the |
\begin{bikeshedding} |
@ev-br I don't know know much about |
@ev-br manually incorporated your changes to remove the calls to globals() |
Overall looks good to me. Some comments:
|
Removal of All tests pass also with numpy 1.5.1 |
…structure module and prune redundant imports
@rgommers the PR is updated according to your comments |
MAINT: split distributions.py into three files
This looks good to me now, merging. Thanks Alex. |
@argriffing: This was a much needed, long overdue refactoring job. Thanks! |
This seems to have backwards incompatibly changed |
Fixed again by gh-3292 |
This is a redo of #3128 with fewer commits.