Skip to content
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

MNT: reference the proper variable in bootstrapper #7868

Merged
merged 1 commit into from Jan 19, 2017

Conversation

phobson
Copy link
Member

@phobson phobson commented Jan 18, 2017

Cleans up some unclear code that magically worked due to python's scoping rules.

ref comment

@phobson phobson added this to the 2.0.1 (next bug fix release) milestone Jan 18, 2017
@tacaswell tacaswell changed the title MNT: reference the proper variable in bootstrapper [MRG+1] MNT: reference the proper variable in bootstrapper Jan 18, 2017
Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

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

This looks good.

(I think at some point, we'll maybe have to expose a couple of parameters to make sure some elements are reproducible in this piece of code, but that is out of scope for this PR).

@NelleV NelleV changed the title [MRG+1] MNT: reference the proper variable in bootstrapper [MRG+2] MNT: reference the proper variable in bootstrapper Jan 18, 2017
@phobson
Copy link
Member Author

phobson commented Jan 18, 2017

@NelleV 100% agree. I almost started to do that this morning, but day-job things need my attention.

I convinced myself I'd sneak such improvements in with MEP 28

ii = np.random.randint(M, size=(N, M))
bsData = x[ii]
bs_index = np.random.randint(M, size=(N, M))
bsData = data[bs_index]
Copy link
Contributor

@anntzer anntzer Jan 18, 2017

Choose a reason for hiding this comment

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

np.random.choice(data, N * len(data), replace=True).reshape((N, M))?

Copy link
Member Author

Choose a reason for hiding this comment

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

@anntzer that looks like it would work too. Not sure that performance would be significantly impacted in either direction. So I'm going to punt of figuring out which is better until the refactor associated with MEP 28 like a mentioned in my comment to Nelle.

Copy link
Contributor

Choose a reason for hiding this comment

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

np.random.choice(, ...) is basically implemented as array[np.random.randint(...)] so it's the same.

@@ -1941,8 +1941,8 @@ def _bootstrap_median(data, N=5000):
M = len(data)
percentiles = [2.5, 97.5]

ii = np.random.randint(M, size=(N, M))
bsData = x[ii]
bs_index = np.random.randint(M, size=(N, M))
Copy link

Choose a reason for hiding this comment

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

Much better than before! Using underscored bs_index next to camelcased bsData is a bit strange... bsIndices would be my choice. but I'm nitpicking :)

Copy link
Member

Choose a reason for hiding this comment

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

The latter is not pep8 compliant, so I'd rather go for the pep8 compliant one though it is not coherent on this particular function.

@NelleV
Copy link
Member

NelleV commented Jan 18, 2017

I am very tempted not to wait for appveyor…

@dopplershift
Copy link
Contributor

Meh, unless we're cutting a release right now I don't see what merging early buys...

@NelleV
Copy link
Member

NelleV commented Jan 18, 2017

@dopplershift We have a lot of pull requests opened right now, and if PRs don't appear on the first page, they tend to be forgotten by reviewers.

@codecov-io
Copy link

Current coverage is 62.12% (diff: 100%)

Merging #7868 into master will not change coverage

@@             master      #7868   diff @@
==========================================
  Files           174        174          
  Lines         56072      56072          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          34833      34833          
  Misses        21239      21239          
  Partials          0          0          

Powered by Codecov. Last update 2374c9b...3ffb884

@NelleV NelleV merged commit 81075b5 into matplotlib:master Jan 19, 2017
@NelleV
Copy link
Member

NelleV commented Jan 19, 2017

Thanks @phobson !

@phobson phobson deleted the fix-boxplot-bootstrapper branch January 19, 2017 05:18
@phobson phobson changed the title [MRG+2] MNT: reference the proper variable in bootstrapper MNT: reference the proper variable in bootstrapper Jan 23, 2017
@QuLogic
Copy link
Member

QuLogic commented Jan 30, 2017

Backported to v2.0.x as c4dee7a.

QuLogic pushed a commit that referenced this pull request Jan 30, 2017
MNT: reference the proper variable in bootstrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants