improved string representation when finding list of arrays

This commit is contained in:
marco cammarata 2017-03-05 22:12:08 +01:00
parent 2c6f7663f6
commit 5a050bb5a3
1 changed files with 3 additions and 3 deletions

View File

@ -239,14 +239,14 @@ class DataStorage(dict):
for k in keys: for k in keys:
if k[0] == "_": continue if k[0] == "_": continue
obj = self[k] obj = self[k]
if isinstance(obj,np.ndarray): if isinstance(obj,(list,tuple,np.ndarray)) and all( [isinstance(v,np.ndarray) for v in obj]):
value_str = "list of arrays, shapes " + ",".join([str(v.shape) for v in obj[:5]]) + " ..."
elif isinstance(obj,np.ndarray):
value_str = "array, size %s, type %s"% ("x".join(map(str,obj.shape)),obj.dtype) value_str = "array, size %s, type %s"% ("x".join(map(str,obj.shape)),obj.dtype)
elif isinstance(obj,DataStorage): elif isinstance(obj,DataStorage):
value_str = str(obj)[:50] value_str = str(obj)[:50]
elif isinstance(obj,(str,DataStorage)): elif isinstance(obj,(str,DataStorage)):
value_str = obj[:50] value_str = obj[:50]
elif isinstance(obj,(list,tuple)) and all( [isinstance(v,np.ndarray) for v in obj]):
value_str = "list of arrays, shapes " + ",".join([str(v.shape) for v in obj[:5]]) + " ..."
elif self[k] is None: elif self[k] is None:
value_str = "None" value_str = "None"
else: else: