also show dtype if available

This commit is contained in:
2021-10-24 12:38:11 +02:00
parent 024680e96b
commit 597dfca483

View File

@ -79,7 +79,7 @@ class VariableInspector(object, metaclass=Singleton):
def format_line(k, v):
return LINE.format(k, typename(v), size(v), format_value(v))
return LINE.format(k, format_type(v), size(v), format_value(v))
def sorted_naturally(iterable, reverse=False):
natural = lambda item: [int(c) if c.isdigit() else c.casefold() for c in RE_DIGITS.split(str(item))]
@ -112,6 +112,15 @@ def format_value(obj): #TODO: make magic numbers configurable
res = res[:50] + " ... " + res[-50:]
return res
def format_type(obj):
tn = typename(obj)
try:
dtype = obj.dtype
except AttributeError:
return tn
else:
return f"{dtype} {tn}"
inspector = VariableInspector()