Fix some of the new math filters

This commit is contained in:
Toshio Kuratomi 2014-12-16 16:09:17 -08:00
parent 7ab1e52575
commit c808c8a22a

View file

@ -21,7 +21,7 @@ from ansible import errors
def isnotanumber(x): def isnotanumber(x):
try: try:
return math.isnan(x) return math.isnan(x)
except TypeError, e: except TypeError:
return False return False
@ -30,14 +30,14 @@ def logarithm(x, base=math.e):
if base == 10: if base == 10:
return math.log10(x) return math.log10(x)
else: else:
return = math.log(x, base) return math.log(x, base)
except TypeError, e: except TypeError, e:
raise errors.AnsibleFilterError('log() can only be used on numbers: %s' % str(e)) raise errors.AnsibleFilterError('log() can only be used on numbers: %s' % str(e))
def power(x): def power(x, y):
try: try:
return math.pow(x,y) return math.pow(x, y)
except TypeError, e: except TypeError, e:
raise errors.AnsibleFilterError('pow() can only be used on numbers: %s' % str(e)) raise errors.AnsibleFilterError('pow() can only be used on numbers: %s' % str(e))