Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/nipyPublic

Commit3437e20

Browse files
committed
np.float64 for npy.float
1 parent526f697 commit3437e20

File tree

49 files changed

+136
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+136
-136
lines changed

‎examples/ds105/ds105_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ def run_model(subj, run):
243243
tempdict= {}
244244
forvin ['sd','t','effect']:
245245
tempdict[v]=np.memmap(NamedTemporaryFile(prefix='%s%s.nii'
246-
% (n,v)),dtype=np.float,
246+
% (n,v)),dtype=np.float64,
247247
shape=volshape,mode='w+')
248248
output[n]=tempdict
249249

250250
forninfcons:
251251
output[n]=np.memmap(NamedTemporaryFile(prefix='%s%s.nii'
252-
% (n,v)),dtype=np.float,
252+
% (n,v)),dtype=np.float64,
253253
shape=volshape,mode='w+')
254254

255255
# Loop over the unique values of ar1

‎examples/fiac/fiac_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ def run_model(subj, run):
231231
tempdict= {}
232232
forvin ['sd','t','effect']:
233233
tempdict[v]=np.memmap(NamedTemporaryFile(prefix='%s%s.nii'
234-
% (n,v)),dtype=np.float,
234+
% (n,v)),dtype=np.float64,
235235
shape=volshape,mode='w+')
236236
output[n]=tempdict
237237

238238
forninfcons:
239239
output[n]=np.memmap(NamedTemporaryFile(prefix='%s%s.nii'
240-
% (n,v)),dtype=np.float,
240+
% (n,v)),dtype=np.float64,
241241
shape=volshape,mode='w+')
242242

243243
# Loop over the unique values of ar1

‎examples/fiac/fiac_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,12 @@ def rewrite_spec(subj, run, root = "/home/jtaylo/FIAC-HBM2009"):
336336
# This is due to the FIAC design
337337

338338
ifdesigntype=='evt':
339-
b=np.array([(d[0]['time'],1)],np.dtype([('time',np.float),
339+
b=np.array([(d[0]['time'],1)],np.dtype([('time',np.float64),
340340
('initial',np.int)]))
341341
d=d[1:]
342342
else:
343343
k=np.equal(np.arange(d.shape[0])%6,0)
344-
b=np.array([(tt,1)forttind[k]['time']],np.dtype([('time',np.float),
344+
b=np.array([(tt,1)forttind[k]['time']],np.dtype([('time',np.float64),
345345
('initial',np.int)]))
346346
d=d[~k]
347347

‎examples/formula/fir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def anon(x,k1=k1,k2=k2,k3=k3):
4444

4545
# We're going to evaluate at these specific values of time
4646
tt=np.linspace(0,50,101)
47-
tvals=tt.view(np.dtype([('t',np.float)]))
47+
tvals=tt.view(np.dtype([('t',np.float64)]))
4848

4949
# Some inter-stimulus intervals
5050
isis=np.random.uniform(low=0,high=3,size=(4,))+10.

‎examples/formula/multi_session_contrast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484
# our case the terms are t1, t2, and the (indicator coding) terms from the run
8585
# factor.
8686
rec=np.array([(tv1,tv2,s)fortv1,tv2,sinzip(ttval1,ttval2,run_no)],
87-
np.dtype([('t1',np.float),
88-
('t2',np.float),
87+
np.dtype([('t1',np.float64),
88+
('t2',np.float64),
8989
('run',np.int)]))
9090

9191
# The contrast we care about

‎examples/formula/parametric_design.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
X3=f3.design(tval,params,return_float=True)
4242

4343
# the columns or d/d_b0 and d/dl
44-
tt=tval.view(np.float)
44+
tt=tval.view(np.float64)
4545
v1=np.sum([hrf.glovert(tt-s)*np.exp(-4.5*a)fors,ainzip(t,dt)],0)
4646
v2=np.sum([-3.5*a*hrf.glovert(tt-s)*np.exp(-4.5*a)fors,ainzip(t,dt)],0)
4747

‎examples/interfaces/process_ds105.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def smooth(self, in_prefix='', out_prefix='s'):
274274
len(fwhm)
275275
exceptTypeError:
276276
fwhm= [fwhm]*3
277-
fwhm=np.asarray(fwhm,dtype=np.float).reshape(1,3)
277+
fwhm=np.asarray(fwhm,dtype=np.float64).reshape(1,3)
278278
sess_scans=scans_for_fnames(
279279
fnames_presuffix(self.data_def['functionals'],in_prefix))
280280
sinfo=make_job('spatial','smooth',

‎examples/interfaces/process_fiac.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def smooth(data_def, fwhm=8.0):
166166
len(fwhm)
167167
exceptTypeError:
168168
fwhm= [fwhm]*3
169-
fwhm=np.asarray(fwhm,dtype=np.float).reshape(1,3)
169+
fwhm=np.asarray(fwhm,dtype=np.float64).reshape(1,3)
170170
sess_scans=scans_for_fnames(fnames_presuffix(data_def['functionals'],'wa'))
171171
sinfo=make_job('spatial','smooth',
172172
{'data':np.vstack(sess_scans.flat),

‎examples/labs/need_data/glm_beta_and_variance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@
105105
mask=fmri_glm.mask.get_data()>0
106106

107107
# output beta images
108-
beta_map=np.tile(mask.astype(np.float)[...,np.newaxis],dim)
108+
beta_map=np.tile(mask.astype(np.float64)[...,np.newaxis],dim)
109109
beta_map[mask]=beta_hat.T
110110
beta_image=Nifti1Image(beta_map,fmri_glm.affine)
111111
beta_image.get_header()['descrip']= (
112112
'Parameter estimates of the localizer dataset')
113113
save(beta_image,path.join(write_dir,'beta.nii'))
114114
print("Beta image witten in %s"%write_dir)
115115

116-
variance_map=mask.astype(np.float)
116+
variance_map=mask.astype(np.float64)
117117
variance_map[mask]=variance_hat
118118

119119
# Create a snapshots of the variance image contrasts

‎nipy/algorithms/clustering/bgmm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def wishart_eval(n, V, W, dV=None, dW=None, piV=None):
146146
ltr=-np.trace(np.dot(piV,W))/2
147147
la= (n*p*math.log(2)+math.log(dV)*n)/2
148148
lg=math.log(math.pi)*p* (p-1)/4
149-
lg+=gammaln(np.arange(n-p+1,n+1).astype(np.float)/2).sum()
149+
lg+=gammaln(np.arange(n-p+1,n+1).astype(np.float64)/2).sum()
150150
lt=ldW+ltr-la-lg
151151
returnmath.exp(lt)
152152

@@ -757,7 +757,7 @@ def conditional_posterior_proba(self, x, z, perm=None):
757757
By default, no permutation is performed
758758
"""
759759
pop=self.pop(z)
760-
rpop= (pop+ (pop==0)).astype(np.float)
760+
rpop= (pop+ (pop==0)).astype(np.float64)
761761
dof=self.prior_dof+pop+1
762762
shrinkage=self.prior_shrinkage+pop
763763
weights=pop+self.prior_weights

‎nipy/algorithms/clustering/ggmixture.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def show(self, x):
290290
step=3.5*np.std(x)/np.exp(np.log(np.size(x))/3)
291291
bins=max(10,int((x.max()-x.min())/step))
292292
h,c=np.histogram(x,bins)
293-
h=h.astype(np.float)/np.size(x)
293+
h=h.astype(np.float64)/np.size(x)
294294
p=self.mixt
295295

296296
dc=c[1]-c[0]
@@ -646,7 +646,7 @@ def show(self, x, mpaxes=None):
646646
step=3.5*np.std(x)/np.exp(np.log(np.size(x))/3)
647647
bins=max(10,int((x.max()-x.min())/step))
648648
h,c=np.histogram(x,bins)
649-
h=h.astype(np.float)/np.size(x)
649+
h=h.astype(np.float64)/np.size(x)
650650
dc=c[1]-c[0]
651651

652652
ng=self.mixt[0]*_gam_dens(self.shape_n,self.scale_n,-c)

‎nipy/algorithms/clustering/tests/test_clustering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def testkmeans2(self):
2525
X=X+3*A
2626
L=np.concatenate([np.ones(5000),np.zeros(5000)]).astype(np.int)
2727
C,L,J=kmeans(X,2,L)
28-
l=L[:7000].astype(np.float)
28+
l=L[:7000].astype(np.float64)
2929
self.assert_(np.mean(l)>0.9)
3030

3131

‎nipy/algorithms/clustering/von_mises_fisher_mixture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def select_vmm_cv(krange, precision, x, null_class, cv_index,
360360
forkinkrange:
361361
mll.append(-np.inf)
362362
forjinrange(1):
363-
ll=np.zeros_like(cv_index).astype(np.float)
363+
ll=np.zeros_like(cv_index).astype(np.float64)
364364
foriinnp.unique(cv_index):
365365
xl=x[cv_index!=i]
366366
xt=x[cv_index==i]

‎nipy/algorithms/graph/tests/test_field.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
defbasic_field(nx=10,ny=10,nz=10):
1515
xyz=np.reshape(np.indices((nx,ny,nz)), (3,nx*ny*nz)).T
16-
data=np.sum(xyz,1).astype(np.float)
16+
data=np.sum(xyz,1).astype(np.float64)
1717
myfield=field_from_graph_and_data(wgraph_from_3d_grid(xyz,26),data)
1818
returnmyfield
1919

2020

2121
defbasic_field_random(nx=10,ny=10,nz=1):
2222
xyz=np.reshape(np.indices((nx,ny,nz)), (3,nx*ny*nz)).T
23-
data=0.5*nr.randn(nx*ny*nz,1)+np.sum(xyz,1).astype(np.float)
23+
data=0.5*nr.randn(nx*ny*nz,1)+np.sum(xyz,1).astype(np.float64)
2424
myfield=field_from_graph_and_data(wgraph_from_3d_grid(xyz,26),data)
2525
returnmyfield
2626

@@ -252,7 +252,7 @@ def test_constrained_voronoi_2(nbseeds=3):
252252
# Test the geodisc k-means algorithm
253253
xyz,x=np.zeros((30,3)),np.arange(30)
254254
xyz[:,0]=x
255-
y=np.array((x//10),np.float)
255+
y=np.array((x//10),np.float64)
256256
myfield=field_from_graph_and_data(wgraph_from_3d_grid(xyz,6),y)
257257
seeds=np.array([1,18,25])
258258
label=myfield.constrained_voronoi(seeds)

‎nipy/algorithms/graph/tests/test_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def test_concatenate2(n=10):
396396
deftest_anti_symmeterize():
397397
n=10
398398
eps=1.e-7
399-
M= (nr.rand(n,n)>0.7).astype(np.float)
399+
M= (nr.rand(n,n)>0.7).astype(np.float64)
400400
C=M-M.T
401401
G=wgraph_from_adjacency(M)
402402
G.anti_symmeterize()
@@ -432,7 +432,7 @@ def test_graph_create_from_coo_matrix():
432432
"""Test the creation of a graph from a sparse coo_matrix
433433
"""
434434
importscipy.sparseasspp
435-
a= (np.random.randn(5,5)>.8).astype(np.float)
435+
a= (np.random.randn(5,5)>.8).astype(np.float64)
436436
s=spp.coo_matrix(a)
437437
wg=wgraph_from_coo_matrix(s)
438438
b=wg.to_coo_matrix()
@@ -442,7 +442,7 @@ def test_graph_create_from_coo_matrix():
442442
deftest_to_coo_matrix():
443443
""" Test the generation of a sparse matrix as output
444444
"""
445-
a= (np.random.randn(5,5)>.8).astype(np.float)
445+
a= (np.random.randn(5,5)>.8).astype(np.float64)
446446
wg=wgraph_from_adjacency(a)
447447
b=wg.to_coo_matrix().todense()
448448
assert_array_equal(a,b)

‎nipy/algorithms/statistics/bench/bench_intvol.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def bench_lips3d():
2020
repeat=4
2121
bx_sz=60
2222
box1,box2,edge1,edge2=nonintersecting_boxes((bx_sz,)*3)
23-
c=np.indices(box1.shape).astype(np.float)
23+
c=np.indices(box1.shape).astype(np.float64)
2424
sys.stdout.flush()
2525
print("\nIntrinsic volumes 3D")
2626
print("--------------------")
@@ -44,7 +44,7 @@ def bench_lips2d():
4444
repeat=4
4545
bx_sz=500
4646
box1,box2,edge1,edge2=nonintersecting_boxes((bx_sz,)*2)
47-
c=np.indices(box1.shape).astype(np.float)
47+
c=np.indices(box1.shape).astype(np.float64)
4848
sys.stdout.flush()
4949
print("\nIntrinsic volumes 2D")
5050
print("--------------------")
@@ -68,7 +68,7 @@ def bench_lips1d():
6868
repeat=4
6969
bx_sz=100000
7070
box1,box2,edge1,edge2=nonintersecting_boxes((bx_sz,))
71-
c=np.indices(box1.shape).astype(np.float)
71+
c=np.indices(box1.shape).astype(np.float64)
7272
sys.stdout.flush()
7373
print("\nIntrinsic volumes 1D")
7474
print("--------------------")

‎nipy/algorithms/statistics/empirical_pvalue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def learn(self, left=0.2, right=0.8):
208208
medge=ledge+0.5*step
209209

210210
# remove null bins
211-
hist=hist[hist>0].astype(np.float)
211+
hist=hist[hist>0].astype(np.float64)
212212
medge=medge[:-1][hist>0]# edges include rightmost outer
213213

214214
# fit the histogram

‎nipy/algorithms/statistics/formula/formulae.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class Term(sympy.Symbol):
175175
recarray used to create a design matrix.
176176
177177
>>> t = Term('x')
178-
>>> xval = np.array([(3,),(4,),(5,)], np.dtype([('x', np.float)]))
178+
>>> xval = np.array([(3,),(4,),(5,)], np.dtype([('x', np.float64)]))
179179
>>> f = t.formula
180180
>>> d = f.design(xval)
181181
>>> print(d.dtype.descr)
@@ -377,7 +377,7 @@ def make_recarray(rows, names, dtypes=None, drop_name_dim=_NoValue):
377377
Create a recarray with named columns from a list or ndarray of `rows` and
378378
sequence of `names` for the columns. If `rows` is an ndarray, `dtypes` must
379379
be None, otherwise we raise a ValueError. Otherwise, if `dtypes` is None,
380-
we cast the data in all columns in `rows` as np.float. If `dtypes` is not
380+
we cast the data in all columns in `rows` as np.float64. If `dtypes` is not
381381
None, the routine uses `dtypes` as a dtype specifier for the output
382382
structured array.
383383
@@ -422,7 +422,7 @@ def make_recarray(rows, names, dtypes=None, drop_name_dim=_NoValue):
422422
array([(3, 4), (4, 6), (6, 8)],
423423
dtype=[('x', '<i8'), ('y', '<i8')])
424424
>>> make_recarray([[3, 4], [4, 6], [7, 9]], 'wv',
425-
... [np.float, np.int]) #doctest: +STRUCTARR_EQUAL
425+
... [np.float64, np.int_]) #doctest: +STRUCTARR_EQUAL
426426
array([(3.0, 4), (4.0, 6), (7.0, 9)],
427427
dtype=[('w', '<f8'), ('v', '<i8')])
428428
@@ -440,7 +440,7 @@ def make_recarray(rows, names, dtypes=None, drop_name_dim=_NoValue):
440440
return_recarray_from_array(rows,names,drop_name_dim)
441441
# Structured array from list
442442
ifdtypesisNone:
443-
dtype=np.dtype([(n,np.float)forninnames])
443+
dtype=np.dtype([(n,np.float64)forninnames])
444444
else:
445445
dtype=np.dtype([(n,d)forn,dinzip(names,dtypes)])
446446
# Peek at first value in iterable
@@ -519,7 +519,7 @@ def _getdiff(self):
519519

520520
def_getdtype(self):
521521
vnames= [str(s)forsinself.design_expr]
522-
returnnp.dtype([(n,np.float)forninvnames])
522+
returnnp.dtype([(n,np.float64)forninvnames])
523523
dtype=property(_getdtype,doc='The dtype of the design matrix of the Formula.')
524524

525525
def__repr__(self):
@@ -797,9 +797,9 @@ def _setup_design(self):
797797
# There is also an argument for parameters that are not
798798
# Terms.
799799

800-
self._dtypes= {'param':np.dtype([(str(p),np.float)forpinparams]),
801-
'term':np.dtype([(str(t),np.float)fortinterms]),
802-
'preterm':np.dtype([(n,np.float)forninpreterm])}
800+
self._dtypes= {'param':np.dtype([(str(p),np.float64)forpinparams]),
801+
'term':np.dtype([(str(t),np.float64)fortinterms]),
802+
'preterm':np.dtype([(n,np.float64)forninpreterm])}
803803

804804
self.__terms=terms
805805

@@ -819,7 +819,7 @@ def design(self,
819819
Recarray including fields that are not Terms in
820820
getparams(self.design_expr)
821821
return_float : bool, optional
822-
If True, return a np.float array rather than a np.recarray
822+
If True, return a np.float64 array rather than a np.recarray
823823
contrasts : None or dict, optional
824824
Contrasts. The items in this dictionary should be (str,
825825
Formula) pairs where a contrast matrix is constructed for
@@ -854,9 +854,9 @@ def design(self,
854854
# If the only term is an intercept,
855855
# the return value is a matrix of 1's.
856856
iflist(self.terms)== [sympy.Number(1)]:
857-
a=np.ones(preterm_recarray.shape[0],np.float)
857+
a=np.ones(preterm_recarray.shape[0],np.float64)
858858
ifnotreturn_float:
859-
a=a.view(np.dtype([('intercept',np.float)]))
859+
a=a.view(np.dtype([('intercept',np.float64)]))
860860
returna
861861
elifnotself._dtypes['term']:
862862
raiseValueError("none of the expresssions are self.terms "
@@ -882,7 +882,7 @@ def design(self,
882882
# The lambda created in self._setup_design needs to take a tuple of
883883
# columns as argument, not an ndarray, so each column
884884
# is extracted and put into float_tuple.
885-
float_array=term_recarray.view(np.float)
885+
float_array=term_recarray.view(np.float64)
886886
float_array.shape= (term_recarray.shape[0],-1)
887887
float_array=float_array.T
888888
float_tuple=tuple(float_array)
@@ -924,7 +924,7 @@ def design(self,
924924
ifreturn_floatorcontrasts:
925925
# If the design matrix is just a column of 1s
926926
# return a 1-dimensional array.
927-
D=np.squeeze(D.astype(np.float))
927+
D=np.squeeze(D.astype(np.float64))
928928
# If there are contrasts, the pseudo-inverse of D
929929
# must be computed.
930930
ifcontrasts:
@@ -980,7 +980,7 @@ def natural_spline(t, knots=None, order=3, intercept=False):
980980
--------
981981
>>> x = Term('x')
982982
>>> n = natural_spline(x, knots=[1,3,4], order=3)
983-
>>> xval = np.array([3,5,7.]).view(np.dtype([('x', np.float)]))
983+
>>> xval = np.array([3,5,7.]).view(np.dtype([('x', np.float64)]))
984984
>>> n.design(xval, return_float=True)
985985
array([[ 3., 9., 27., 8., 0., -0.],
986986
[ 5., 25., 125., 64., 8., 1.],
@@ -1120,7 +1120,7 @@ def fromcol(col, name):
11201120
11211121
Examples
11221122
--------
1123-
>>> data = np.array([(3,'a'),(4,'a'),(5,'b'),(3,'b')], np.dtype([('x', np.float), ('y', 'S1')]))
1123+
>>> data = np.array([(3,'a'),(4,'a'),(5,'b'),(3,'b')], np.dtype([('x', np.float64), ('y', 'S1')]))
11241124
>>> f1 = Factor.fromcol(data['y'], 'y')
11251125
>>> f2 = Factor.fromcol(data['x'], 'x')
11261126
>>> d = f1.design(data)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp