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):
|
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):
|
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))]
|
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)
|
ignore_types = (VariableInspector, types.ModuleType)
|
||||||
return not k.startswith("_") and k not in IGNORE_NAMES and not isinstance(v, ignore_types)
|
return not k.startswith("_") and k not in IGNORE_NAMES and not isinstance(v, ignore_types)
|
||||||
|
|
||||||
def typename(obj):
|
def format_type(obj):
|
||||||
return type(obj).__name__
|
tn = typename(obj)
|
||||||
|
try:
|
||||||
|
dtype = obj.dtype
|
||||||
|
except AttributeError:
|
||||||
|
return tn
|
||||||
|
else:
|
||||||
|
return f"{dtype} {tn}"
|
||||||
|
|
||||||
def size(obj):
|
def format_size(obj):
|
||||||
try:
|
try:
|
||||||
return obj.shape
|
return obj.shape
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -116,14 +122,8 @@ def format_value(obj): #TODO: make magic numbers configurable
|
|||||||
res = res[:50] + SNIP + res[-50:]
|
res = res[:50] + SNIP + res[-50:]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def format_type(obj):
|
def typename(obj):
|
||||||
tn = typename(obj)
|
return type(obj).__name__
|
||||||
try:
|
|
||||||
dtype = obj.dtype
|
|
||||||
except AttributeError:
|
|
||||||
return tn
|
|
||||||
else:
|
|
||||||
return f"{dtype} {tn}"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user