예제 #1
0
def list_slice(list, start=0, to=None):
  start = util.numify(start)
  if start < 0:
    start = len(list) + start
  if to is None or to < 0:
    return list[start:]
  else:
    to = util.numify(to)
    return list[start:to + 1]
예제 #2
0
def list_defined(list, index=None):
  if index is None:
    return 1
  else:
    try:
      return int(list[util.numify(index)] is not None)
    except IndexError:
      return 0
예제 #3
0
 def sqrt(self, x):
     root = math.sqrt(numify(x))
     trunc = long(root)
     # Try to return an integer, if possible:
     if root == trunc:
         return trunc
     else:
         return root
예제 #4
0
def truncate_filter_factory(context, length=32, char="..."):
  length = numify(length)
  char = str(char)
  def truncate_filter(text=""):
    text = str(text)
    if len(text) <= length:
      return text
    else:
      return text[:length - len(char)] + char
  return truncate_filter
예제 #5
0
def list_splice(seq, start=0, length=None, *replace):
  start = util.numify(start)
  if start < 0:
    start = len(seq) + start
  if length is not None:
    stop = start + length
  else:
    stop = len(seq)
  if len(replace) == 1 and util.is_seq(replace[0]):
    replace = replace[0]
  s = slice(start, stop)
  removed = seq[s]
  seq[s] = replace
  return removed
예제 #6
0
 def srand(self, x):
     return Random.seed(numify(x))
예제 #7
0
 def asin(self, x):
     return math.asin(numify(x))
예제 #8
0
 def grad2rad(self, x):
     return math.radians(numify(x) * 0.9)
예제 #9
0
def list_item(list, item=0):
  try:
    return list[util.numify(item)]
  except IndexError:
    return None
예제 #10
0
 def coth(self, x):
     return 1.0 / math.tanh(numify(x))
예제 #11
0
 def rad2deg(self, x):
     return math.degrees(numify(x))
예제 #12
0
 def acos(self, x):
     return math.acos(numify(x))
예제 #13
0
 def cosh(self, x):
     return math.cosh(numify(x))
예제 #14
0
 def cot(self, x):
     return 1.0 / math.tan(numify(x))
예제 #15
0
 def asin(self, x):
     return math.asin(numify(x))
예제 #16
0
 def sec(self, x):
     return 1.0 / math.cos(numify(x))
예제 #17
0
 def csc(self, x):
     return 1.0 / math.sin(numify(x))
예제 #18
0
 def truly_random(self, x):
     if TrulyRandomFunction is None:
         raise Error("No truly_random dispatch function has been defined")
     return TrulyRandomFunction(numify(x))
예제 #19
0
 def atan(self, x):
     return math.atan(numify(x))
예제 #20
0
 def atan(self, x):
     return math.atan(numify(x))
예제 #21
0
 def acot(self, x):
     return math.pi / 2.0 - math.atan(numify(x))
예제 #22
0
 def asec(self, x):
     return math.acos(1.0 / numify(x))
예제 #23
0
 def csch(self, x):
     return 1.0 / math.sinh(numify(x))
예제 #24
0
 def acot(self, x):
     return math.pi / 2.0 - math.atan(numify(x))
예제 #25
0
 def acsch(self, x):
     x = numify(x)
     if x < 0:
         return math.log((1.0 - math.sqrt(1.0 + x * x)) / x)
     else:
         return math.log((1.0 + math.sqrt(1.0 + x * x)) / x)
예제 #26
0
 def sinh(self, x):
     return math.sinh(numify(x))
예제 #27
0
 def deg2rad(self, x):
     return math.radians(numify(x))
예제 #28
0
 def cosh(self, x):
     return math.cosh(numify(x))
예제 #29
0
 def log(self, x):
     return math.log(numify(x))
예제 #30
0
 def tanh(self, x):
     return math.tanh(numify(x))
예제 #31
0
 def hex(self, x):
     return int(str(numify(x)), 16)
예제 #32
0
 def csch(self, x):
     return 1.0 / math.sinh(numify(x))
예제 #33
0
 def cot(self, x):
     return 1.0 / math.tan(numify(x))
예제 #34
0
 def sech(self, x):
     return 1.0 / math.cosh(numify(x))
예제 #35
0
 def acos(self, x):
     return math.acos(numify(x))
예제 #36
0
 def coth(self, x):
     return 1.0 / math.tanh(numify(x))
예제 #37
0
 def asec(self, x):
     return math.acos(1.0 / numify(x))
예제 #38
0
 def asinh(self, x):
     x = numify(x)
     return math.log(x + math.sqrt(x * x + 1))
예제 #39
0
 def sinh(self, x):
     return math.sinh(numify(x))
예제 #40
0
 def acsch(self, x):
     x = numify(x)
     if x < 0:
         return math.log((1.0 - math.sqrt(1.0 + x * x)) / x)
     else:
         return math.log((1.0 + math.sqrt(1.0 + x * x)) / x)
예제 #41
0
 def tanh(self, x):
     return math.tanh(numify(x))
예제 #42
0
 def acoth(self, x):
     x = numify(x)
     return math.log((1.0 + x) / (1.0 - x)) / 2.0
예제 #43
0
 def sech(self, x):
     return 1.0 / math.cosh(numify(x))
예제 #44
0
 def rad2deg(self, x):
     return math.degrees(numify(x))
예제 #45
0
 def asinh(self, x):
     x = numify(x)
     return math.log(x + math.sqrt(x * x + 1))
예제 #46
0
 def rad2grad(self, x):
     return math.degrees(numify(x)) * 10.0 / 9.0
예제 #47
0
 def acoth(self, x):
     x = numify(x)
     return math.log((1.0 + x) / (1.0 - x)) / 2.0
예제 #48
0
 def deg2rad(self, x):
     return math.radians(numify(x))
예제 #49
0
 def rad2grad(self, x):
     return math.degrees(numify(x)) * 10.0 / 9.0
예제 #50
0
 def deg2grad(self, x):
     return numify(x) * 10.0 / 9.0
예제 #51
0
 def deg2grad(self, x):
     return numify(x) * 10.0 / 9.0
예제 #52
0
 def grad2rad(self, x):
     return math.radians(numify(x) * 0.9)
예제 #53
0
 def grad2deg(self, x):
     return numify(x) * 0.9
예제 #54
0
 def exp(self, x):
     return math.exp(numify(x))
예제 #55
0
 def repeat_filter(text=""):
   return str(text) * numify(count)
예제 #56
0
 def csc(self, x):
     return 1.0 / math.sin(numify(x))
예제 #57
0
 def int(self, x):
     return int(numify(x))
예제 #58
0
 def sec(self, x):
     return 1.0 / math.cos(numify(x))
예제 #59
0
 def atan2(self, x, y):
     return math.atan2(numify(x), numify(y))
예제 #60
0
 def rand(self, x):
     return Random.uniform(0, numify(x))