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

Skip to content

Commit 2fb47bc

Browse files
committed
drop "new" keyword of np.histogram() for numpy 1.2 or later
svn path=/trunk/matplotlib/; revision=6503
1 parent 5705bd8 commit 2fb47bc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2008-12-07 drop the deprecated "new" keyword of np.histogram() for
2+
numpy 1.2 or later. -JJL
3+
14
2008-12-06 Fixed a bug in svg backend that new_figure_manager()
25
ignores keywords arguments such as figsize, etc. -JJL
36

lib/matplotlib/axes.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6550,12 +6550,20 @@ def hist(self, x, bins=10, range=None, normed=False, cumulative=False,
65506550
# case do not autoscale axes.
65516551
binsgiven = (cbook.iterable(bins) or range != None)
65526552

6553+
# check the version of the numpy
6554+
np_version = float(".".join(np.__version__.split(".")[:2]))
6555+
if np_version < 1.2: # version 1.1
6556+
hist_kwargs = dict(range=range,
6557+
normed=bool(normed), new=True)
6558+
else: # version 1.2 and later, drop new=True
6559+
hist_kwargs = dict(range=range,
6560+
normed=bool(normed))
6561+
65536562
n = []
65546563
for i in xrange(len(x)):
65556564
# this will automatically overwrite bins,
65566565
# so that each histogram uses the same bins
6557-
m, bins = np.histogram(x[i], bins, range=range,
6558-
normed=bool(normed), new=True)
6566+
m, bins = np.histogram(x[i], bins, **hist_kwargs)
65596567
n.append(m)
65606568

65616569
if cumulative:

0 commit comments

Comments
 (0)