order and naming
This commit is contained in:
24
inspector.py
24
inspector.py
@ -82,7 +82,7 @@ class VariableInspector(object, metaclass=Singleton):
|
||||
|
||||
|
||||
def format_line(k, v):
|
||||
return LINE.format(k, format_type(v), size(v), format_value(v))
|
||||
return LINE.format(k, format_type(v), format_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))]
|
||||
@ -92,10 +92,16 @@ def is_good_entry(k, v):
|
||||
ignore_types = (VariableInspector, types.ModuleType)
|
||||
return not k.startswith("_") and k not in IGNORE_NAMES and not isinstance(v, ignore_types)
|
||||
|
||||
def typename(obj):
|
||||
return type(obj).__name__
|
||||
def format_type(obj):
|
||||
tn = typename(obj)
|
||||
try:
|
||||
dtype = obj.dtype
|
||||
except AttributeError:
|
||||
return tn
|
||||
else:
|
||||
return f"{dtype} {tn}"
|
||||
|
||||
def size(obj):
|
||||
def format_size(obj):
|
||||
try:
|
||||
return obj.shape
|
||||
except AttributeError:
|
||||
@ -116,14 +122,8 @@ def format_value(obj): #TODO: make magic numbers configurable
|
||||
res = res[:50] + SNIP + res[-50:]
|
||||
return res
|
||||
|
||||
def format_type(obj):
|
||||
tn = typename(obj)
|
||||
try:
|
||||
dtype = obj.dtype
|
||||
except AttributeError:
|
||||
return tn
|
||||
else:
|
||||
return f"{dtype} {tn}"
|
||||
def typename(obj):
|
||||
return type(obj).__name__
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user