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

Skip to content

Commit 2063e81

Browse files
authored
Merge pull request #8331 from anntzer/dont-use-__builtins__
Don't index into __builtins__ (not supported by PyPy).
2 parents 6030485 + 7eee4c2 commit 2063e81

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6103,6 +6103,10 @@ def hist(self, x, bins=None, range=None, normed=False, weights=None,
61036103
.. plot:: mpl_examples/statistics/histogram_demo_features.py
61046104
61056105
"""
6106+
# Avoid shadowing the builtin.
6107+
bin_range = range
6108+
del range
6109+
61066110
def _normalize_input(inp, ename='input'):
61076111
"""Normalize 1 or 2d input into list of np.ndarray or
61086112
a single 2D np.ndarray.
@@ -6147,13 +6151,6 @@ def _normalize_input(inp, ename='input'):
61476151
if bins is None:
61486152
bins = rcParams['hist.bins']
61496153

6150-
# xrange becomes range after 2to3
6151-
bin_range = range
6152-
range = __builtins__["range"]
6153-
6154-
# NOTE: the range keyword overwrites the built-in func range !!!
6155-
# needs to be fixed in numpy !!!
6156-
61576154
# Validate string inputs here so we don't have to clutter
61586155
# subsequent code.
61596156
if histtype not in ['bar', 'barstacked', 'step', 'stepfilled']:
@@ -6514,10 +6511,7 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None,
65146511
.. plot:: mpl_examples/statistics/plot_hist.py
65156512
"""
65166513

6517-
# xrange becomes range after 2to3
6518-
bin_range = range
6519-
range = __builtins__["range"]
6520-
h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=bin_range,
6514+
h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range,
65216515
normed=normed, weights=weights)
65226516

65236517
if cmin is not None:

0 commit comments

Comments
 (0)