Reflect dimension in approx repr for numpy arrays.
This commit is contained in:
@@ -82,14 +82,18 @@ class ApproxNumpy(ApproxBase):
|
||||
"""
|
||||
|
||||
def __repr__(self):
|
||||
# It might be nice to rewrite this function to account for the
|
||||
# shape of the array...
|
||||
import numpy as np
|
||||
|
||||
list_scalars = []
|
||||
for x in np.ndindex(self.expected.shape):
|
||||
list_scalars.append(self._approx_scalar(np.asscalar(self.expected[x])))
|
||||
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())
|
||||
|
||||
return "approx({!r})".format(list_scalars)
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
|
||||
Reference in New Issue
Block a user