Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MNT: reference the proper variable in bootstrapper #7868

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

Merged
merged 1 commit into from
Jan 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

estimate = np.median(bsData, axis=1, overwrite_input=True)

CI = np.percentile(estimate, percentiles)
Expand Down