Changeset 627 for branches


Ignore:
Timestamp:
12/31/12 10:14:52 (3 years ago)
Author:
mmckerns
Message:

fix: discrete decorator index applies to all when index=None

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/decorate/wrapper.py

    r626 r627  
    4141 
    4242 
    43 from numpy import asarray, any, inf, vectorize, choose 
     43from numpy import asarray, any, inf, vectorize, choose, zeros, ones 
    4444def bounded(min=None, max=None): 
    4545    """impose an infinite barrier box constraint on a function 
     
    168168            xp = near(x, samples[0][arglo], samples[0][arghi]) 
    169169            # create a choice array from given indices 
    170             mask = xp*False #FIXME: better ways to do this 
    171             try: mask[sorted(index)] = True #FIXME: better ways to do this 
    172             except IndexError: pass 
     170            #FIXME: better ways to do the following 
     171            if index is None:  
     172                mask = ones(xp.size, dtype=bool) 
     173            else: 
     174                mask = zeros(xp.size, dtype=bool) 
     175                try: mask[sorted(index)] = True 
     176                except IndexError: pass 
    173177            xp = xtype(choose(mask, (x,xp))) 
    174178            return f(xp, *args, **kwds) 
Note: See TracChangeset for help on using the changeset viewer.