Move recursive_map from local to free function
This commit is contained in:
parent
ad5ddaf55a
commit
2a2f888909
|
@ -101,20 +101,20 @@ class ApproxBase(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ApproxNumpy(ApproxBase):
|
|
||||||
"""
|
|
||||||
Perform approximate comparisons where the expected value is numpy array.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
def recursive_map(f, x):
|
def recursive_map(f, x):
|
||||||
if isinstance(x, list):
|
if isinstance(x, list):
|
||||||
return list(recursive_map(f, xi) for xi in x)
|
return list(recursive_map(f, xi) for xi in x)
|
||||||
else:
|
else:
|
||||||
return f(x)
|
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)
|
return "approx({!r})".format(list_scalars)
|
||||||
|
|
||||||
if sys.version_info[0] == 2:
|
if sys.version_info[0] == 2:
|
||||||
|
|
Loading…
Reference in New Issue