コード例 #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))