Changeset 770


Ignore:
Timestamp:
11/14/14 17:28:54 (18 months ago)
Author:
mmckerns
Message:

using the faster numpy.product versus numpy.prod

Location:
mystic/_math
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mystic/_math/grid.py

    r769 r770  
    7272    if ones: result = sorted(result, key=lambda v: random()) 
    7373    else: result[:nfact] = sorted(result[:nfact], key=lambda v: random()) 
    74     from numpy import prod 
    75     result = [prod(result[i::dim]) for i in range(dim)] 
     74    from numpy import product 
     75    result = [product(result[i::dim]) for i in range(dim)] 
    7676    # if not ones, now needs a full sort to sort in the 1s 
    7777    if not ones: result = sorted(result, key=lambda v: random()) 
  • mystic/_math/measures.py

    r768 r770  
    503503    zmass -- member scaling when mass = 0.0 
    504504""" 
    505   from numpy import prod 
     505  from numpy import product 
    506506  weights = asarray(list(weights)) #XXX: faster to use x = array(x, copy=True) ? 
    507   w = float(prod(weights)) 
     507  w = float(product(weights)) 
    508508  n = len(weights) 
    509509  if not w:  #XXX: is this the best behavior? 
     
    546546   (1,4,7), (2,4,7), (3,4,7), (1,5,7), (2,5,7), (3,5,7)] 
    547547""" 
    548  #from numpy import prod, array, ones 
     548 #from numpy import product, array, ones 
    549549 #ndim = len(samples) 
    550550 #npts = [len(s) for s in samples] 
    551551 #z = [] 
    552552 #for i in range(ndim): 
    553  #  tmp = list(array([n*ones(prod(npts[:i])) for n in samples[i]]).flatten()) 
    554  #  z.append( prod(npts[i+1:])*tmp ) 
     553 #  tmp = list(array([n*ones(product(npts[:i])) for n in samples[i]]).flatten()) 
     554 #  z.append( product(npts[i+1:])*tmp ) 
    555555 #del tmp 
    556556 #zT = [] 
     
    558558 #  zT.append( tuple([y.pop(0) for y in z]) ) 
    559559 #return zT 
    560 # from numpy import prod, array, ones 
     560# from numpy import product, array, ones 
    561561# ndim = len(samples) 
    562562# npts = [len(s) for s in samples] 
    563 # z = ones((ndim, prod(npts)))  # z.T of what's needed 
     563# z = ones((ndim, product(npts)))  # z.T of what's needed 
    564564# for i in range(ndim): 
    565 #   tmp = list(array([n*ones(prod(npts[:i])) for n in samples[i]]).flatten()) 
    566 #   z[i] = prod(npts[i+1:])*tmp 
     565#   tmp = list(array([n*ones(product(npts[:i])) for n in samples[i]]).flatten()) 
     566#   z[i] = product(npts[i+1:])*tmp 
    567567# return [tuple(i) for i in z.T] 
    568568  ndim = len(samples) 
     
    594594  [[1,2,3], [4,5], [6,7]] 
    595595""" 
    596 # from numpy import prod, array 
     596# from numpy import product, array 
    597597# ndim = len(npts) 
    598598# z = [] 
    599599# for i in range(ndim): 
    600 #   tmp = array(samples[:int(len(samples)/prod(npts[i+1:]))]).T[i] 
    601 #   z.append( list(tmp[::int(prod(npts[:i]))]) ) 
     600#   tmp = array(samples[:int(len(samples)/product(npts[i+1:]))]).T[i] 
     601#   z.append( list(tmp[::int(product(npts[:i]))]) ) 
    602602# return z 
    603603  _samples = [] 
Note: See TracChangeset for help on using the changeset viewer.