MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / __init__

Method __init__

tensorpack/dataflow/common.py:776–809  ·  view source on GitHub ↗
(self, el, pos, depth=0, max_list=3)

Source from the content-addressed store, hash-verified

774
775 class _elementInfo(object):
776 def __init__(self, el, pos, depth=0, max_list=3):
777 self.shape = ""
778 self.type = type(el).__name__
779 self.dtype = ""
780 self.range = ""
781
782 self.sub_elements = []
783
784 self.ident = " " * (depth * 2)
785 self.pos = pos
786
787 numpy_scalar_types = list(itertools.chain(*np.sctypes.values()))
788
789 if isinstance(el, (int, float, bool)):
790 self.range = " with value {}".format(el)
791 elif type(el) is np.ndarray:
792 self.shape = " of shape {}".format(el.shape)
793 self.dtype = ":{}".format(str(el.dtype))
794 self.range = " in range [{}, {}]".format(el.min(), el.max())
795 elif type(el) in numpy_scalar_types:
796 self.range = " with value {}".format(el)
797 elif isinstance(el, (list, tuple)):
798 self.shape = " of len {}".format(len(el))
799
800 if depth < max_depth:
801 for k, subel in enumerate(el):
802 if k < max_list:
803 self.sub_elements.append(_elementInfo(subel, k, depth + 1, max_list))
804 else:
805 self.sub_elements.append(" " * ((depth + 1) * 2) + '...')
806 break
807 else:
808 if len(el) > 0:
809 self.sub_elements.append(" " * ((depth + 1) * 2) + ' ...')
810
811 def __str__(self):
812 strings = []

Callers

nothing calls this directly

Calls 5

_elementInfoClass · 0.85
formatMethod · 0.80
minMethod · 0.80
maxMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected