Move recursive_map from local to free function

This commit is contained in:
Bruno Oliveira 2018-08-01 07:30:40 -03:00
parent ad5ddaf55a
commit 2a2f888909
1 changed files with 7 additions and 7 deletions

View File

@ -101,20 +101,20 @@ class ApproxBase(object):
pass
class ApproxNumpy(ApproxBase):
"""
Perform approximate comparisons where the expected value is numpy array.
"""
def __repr__(self):
def recursive_map(f, x):
if isinstance(x, list):
return list(recursive_map(f, xi) for xi in x)
else:
return f(x)
list_scalars = recursive_map(self._approx_scalar, self.expected.tolist())
class ApproxNumpy(ApproxBase):
"""
Perform approximate comparisons where the expected value is numpy array.
"""
def __repr__(self):
list_scalars = recursive_map(self._approx_scalar, self.expected.tolist())
return "approx({!r})".format(list_scalars)
if sys.version_info[0] == 2: