mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Fix set theory filters for python3
The set theory filters need to use lists rather than generators on python3. Also add unit tests for most of the mathstuff filters Fixes #26494
This commit is contained in:
@@ -44,7 +44,7 @@ def intersect(a, b):
|
||||
if isinstance(a, collections.Hashable) and isinstance(b, collections.Hashable):
|
||||
c = set(a) & set(b)
|
||||
else:
|
||||
c = unique(filter(lambda x: x in b, a))
|
||||
c = unique([x for x in a if x in b])
|
||||
return c
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ def difference(a, b):
|
||||
if isinstance(a, collections.Hashable) and isinstance(b, collections.Hashable):
|
||||
c = set(a) - set(b)
|
||||
else:
|
||||
c = unique(filter(lambda x: x not in b, a))
|
||||
c = unique([x for x in a if x not in b])
|
||||
return c
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ def symmetric_difference(a, b):
|
||||
if isinstance(a, collections.Hashable) and isinstance(b, collections.Hashable):
|
||||
c = set(a) ^ set(b)
|
||||
else:
|
||||
c = unique(filter(lambda x: x not in intersect(a, b), union(a, b)))
|
||||
c = unique([x for x in union(a, b) if x not in intersect(a, b)])
|
||||
return c
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ def inversepower(x, base=2):
|
||||
return math.sqrt(x)
|
||||
else:
|
||||
return math.pow(x, 1.0 / float(base))
|
||||
except TypeError as e:
|
||||
except (ValueError, TypeError) as e:
|
||||
raise errors.AnsibleFilterError('root() can only be used on numbers: %s' % str(e))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user