From c50d34effc7d1e1e0ed4b752b8a927b92a37af48 Mon Sep 17 00:00:00 2001 From: einarr Date: Sun, 22 Nov 2009 18:25:43 +0000 Subject: [PATCH] Changed from deprecated scipy.stats.mean() to numpy.mean(). --- laydi/lib/blmplots.py | 4 ++-- laydi/lib/cx_stats.py | 8 ++++---- laydi/lib/cx_utils.py | 6 +++--- laydi/lib/select_generators.py | 4 ++-- laydi/lib/validation.py | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/laydi/lib/blmplots.py b/laydi/lib/blmplots.py index 3403ece..295d03c 100644 --- a/laydi/lib/blmplots.py +++ b/laydi/lib/blmplots.py @@ -10,7 +10,7 @@ import gtk import laydi from laydi import plots, main,logger import scipy -from scipy import dot,sum,diag,arange,log,mean,newaxis,sqrt,apply_along_axis,empty +from scipy import dot,sum,diag,arange,log,newaxis,sqrt,apply_along_axis,empty from scipy.stats import corrcoef def correlation_loadings(data, T, test=True): @@ -418,7 +418,7 @@ class TRBiplot(plots.ScatterPlot): # normalize B Bnorm = scipy.apply_along_axis(scipy.linalg.norm, 1, B) x = model._dataset['X'].copy() - Xc = x._array - mean(x._array,0)[newaxis] + Xc = x._array - x._array.mean(0)[newaxis] w_rot = B/Bnorm t_rot = dot(Xc, w_rot) diff --git a/laydi/lib/cx_stats.py b/laydi/lib/cx_stats.py index d8233f1..2ee668e 100644 --- a/laydi/lib/cx_stats.py +++ b/laydi/lib/cx_stats.py @@ -5,7 +5,7 @@ from scipy import zeros,zeros_like,sqrt,dot,trace,sign,round_,argmax,\ sort,ravel,newaxis,asarray,diag,sum,outer,argsort,arange,ones_like,\ all,apply_along_axis,eye,atleast_2d,empty from scipy.linalg import svd,inv,norm,det,sqrtm -from scipy.stats import mean,median +from scipy.stats import median #import plots_lpls @@ -46,7 +46,7 @@ def hotelling(Pcv, P, p_center='med', cov_center='med', P_ctr = median(Pcv, 0) elif p_center=='mean': # fixme: mean is unstable - P_ctr = mean(Pcv, 0) + P_ctr = Pcv.mean(0) else: #use full P_ctr = P @@ -59,7 +59,7 @@ def hotelling(Pcv, P, p_center='med', cov_center='med', if cov_center == 'med': Cov = median(Cov_i, 0) else: - Cov = mean(Cov_i, 0) + Cov = Cov_i.mean(0) reg_cov = (1. - alpha)*Cov_i + alpha*Cov for i in xrange(n): @@ -428,7 +428,7 @@ def fdr(tsq, tsqp, loc_method='mean'): n_false[j,i] = (tsqp[:,i]>tsq[j]).sum() #cPickle.dump(n_false, open("/tmp/nfalse.dat_"+str(n), "w")) if loc_method=='mean': - fp = mean(n_false,1) + fp = n_false.mean(1) elif loc_method == 'median': fp = median(n_false.T) else: diff --git a/laydi/lib/cx_utils.py b/laydi/lib/cx_utils.py index 281390a..ce381d9 100644 --- a/laydi/lib/cx_utils.py +++ b/laydi/lib/cx_utils.py @@ -3,7 +3,7 @@ from scipy import apply_along_axis,newaxis,zeros,\ trace,zeros_like,sign,sort,real,argsort,rand,array,\ matrix,nan from scipy.linalg import norm,svd,inv,eig -from scipy.stats import median,mean +from scipy.stats import median def normalise(a, axis=0, return_scales=False): s = apply_along_axis(norm, axis, a) @@ -99,11 +99,11 @@ def mat_center(X,axis=0,ret_mn=False): print "The X data needs to be two-dimensional" if axis==0: - mnX = mean(X,axis)[newaxis] + mnX = X.mean(axis)[newaxis] Xs = X - mnX elif axis==1: - mnX = mean(X,axis)[newaxis] + mnX = X.mean(axis)[newaxis] Xs = (X.T - mnX).T if ret_mn: return Xs,mnX diff --git a/laydi/lib/select_generators.py b/laydi/lib/select_generators.py index 6a258b4..046a6af 100644 --- a/laydi/lib/select_generators.py +++ b/laydi/lib/select_generators.py @@ -1,6 +1,6 @@ """Matrix cross validation selection generators """ -from scipy import take,arange,ceil,repeat,newaxis,mean,asarray,dot,ones,\ +from scipy import take,arange,ceil,repeat,newaxis,asarray,dot,ones,\ random,array_split,floor,vstack,asarray,minimum from cx_utils import randperm @@ -188,7 +188,7 @@ def diag_pert(a, n_sets=10, center=True, index_out=False): nm=n*m start_inds = array_split(randperm(m),n_sets) # we use random start diags if center: - a = a - mean(a, 0)[newaxis] + a = a - a.mean(0)[newaxis] for v in range(n_sets): a_out = a.copy() out = [] diff --git a/laydi/lib/validation.py b/laydi/lib/validation.py index 2620a1e..6d01ace 100644 --- a/laydi/lib/validation.py +++ b/laydi/lib/validation.py @@ -1,6 +1,6 @@ """This module implements some common validation schemes from pca and pls. """ -from scipy import ones,mean,sqrt,dot,newaxis,zeros,sum,empty,\ +from scipy import ones,sqrt,dot,newaxis,zeros,sum,empty,\ apply_along_axis,eye,kron,array,sort,zeros_like,argmax,atleast_2d from scipy.stats import median from scipy.linalg import triu,inv,svd,norm