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

Skip to content

Commit dbbdfcb

Browse files
committed
Bugfixes in mlab.py to coerce inputs into numpy arrays.
svn path=/trunk/matplotlib/; revision=3505
1 parent 07794dc commit dbbdfcb

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2007-07-12 Bugfixes in mlab.py to coerce inputs into numpy arrays. -ADS
2+
13
2007-07-11 Added linespacing kwarg to text.Text - EF
24

35
2007-07-11 Added code to store font paths in SVG files. - MGD

lib/matplotlib/mlab.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ def psd(x, NFFT=256, Fs=2, detrend=detrend_none,
173173
if NFFT % 2:
174174
raise ValueError, 'NFFT must be a power of 2'
175175

176+
x = asarray(x) # make sure we're dealing with a numpy array
177+
176178
# zero pad x up to NFFT if it is shorter than NFFT
177179
if len(x)<NFFT:
178180
n = len(x)
@@ -240,6 +242,9 @@ def csd(x, y, NFFT=256, Fs=2, detrend=detrend_none,
240242

241243
if NFFT % 2:
242244
raise ValueError, 'NFFT must be a power of 2'
245+
246+
x = asarray(x) # make sure we're dealing with a numpy array
247+
y = asarray(y) # make sure we're dealing with a numpy array
243248

244249
# zero pad x and y up to NFFT if they are shorter than NFFT
245250
if len(x)<NFFT:
@@ -331,7 +336,7 @@ def corrcoef(*args):
331336
if len(args)==2:
332337
X = transpose(array([args[0]]+[args[1]]))
333338
elif len(args)==1:
334-
X = args[0]
339+
X = asarray(args[0])
335340
else:
336341
raise RuntimeError, 'Only expecting 1 or 2 arguments'
337342

0 commit comments

Comments
 (0)