/[escript]/trunk/escript/py_src/util.py
ViewVC logotype

Diff of /trunk/escript/py_src/util.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 876 by ksteube, Thu Oct 19 03:50:23 2006 UTC revision 881 by gross, Thu Oct 26 02:54:47 2006 UTC
# Line 4066  def minimum(*args): Line 4066  def minimum(*args):
4066            out=add(out,mult(whereNegative(diff),diff))            out=add(out,mult(whereNegative(diff),diff))
4067      return out      return out
4068    
4069  def clip(arg,minval=0.,maxval=1.):  def clip(arg,minval=None,maxval=None):
4070      """      """
4071      cuts the values of arg between minval and maxval      cuts the values of arg between minval and maxval
4072    
4073      @param arg: argument      @param arg: argument
4074      @type arg: L{numarray.NumArray}, L{escript.Data}, L{Symbol}, C{int} or C{float}      @type arg: L{numarray.NumArray}, L{escript.Data}, L{Symbol}, C{int} or C{float}
4075      @param minval: lower range      @param minval: lower range. If None no lower range is applied
4076      @type minval: C{float}      @type minval: C{float} or C{None}
4077      @param maxval: upper range      @param maxval: upper range. If None no upper range is applied
4078      @type maxval: C{float}      @type maxval: C{float} or C{None}
4079      @return: is on object with all its value between minval and maxval. value of the argument that greater then minval and      @return: is on object with all its value between minval and maxval. value of the argument that greater then minval and
4080               less then maxval are unchanged.               less then maxval are unchanged.
4081      @rtype: L{numarray.NumArray}, L{escript.Data}, L{Symbol}, C{int} or C{float} depending on the input      @rtype: L{numarray.NumArray}, L{escript.Data}, L{Symbol}, C{int} or C{float} depending on the input
4082      @raise ValueError: if minval>maxval      @raise ValueError: if minval>maxval
4083      """      """
4084      if minval>maxval:      if not minval==None and not maxval==None:
4085         raise ValueError,"minval = %s must be less then maxval %s"%(minval,maxval)         if minval>maxval:
4086      return minimum(maximum(minval,arg),maxval)            raise ValueError,"minval = %s must be less then maxval %s"%(minval,maxval)
4087        if minval == None:
4088            tmp=arg
4089        else:
4090            tmp=maximum(minval,arg)
4091        if maxval == None:
4092            return tmp
4093        else:
4094            return minimum(tmp,maxval)
4095    
4096        
4097  def inner(arg0,arg1):  def inner(arg0,arg1):

Legend:
Removed from v.876  
changed lines
  Added in v.881

  ViewVC Help
Powered by ViewVC 1.1.26