def get_dictionary(self, obj): if len(obj) > 1: d = OrderedDict() for idx, r in enumerate(obj): d[str(idx)] = r return d return defaultResolver.get_dictionary(obj)
def get_dictionary(self, obj): ret = dict() ret['__internals__'] = defaultResolver.get_dictionary(obj) if obj.size > 1024 * 1024: ret['min'] = 'ndarray too big, calculating min would slow down debugging' ret['max'] = 'ndarray too big, calculating max would slow down debugging' elif obj.size == 0: ret['min'] = 'array is empty' ret['max'] = 'array is empty' else: if self.is_numeric(obj): ret['min'] = obj.min() ret['max'] = obj.max() else: ret['min'] = 'not a numeric object' ret['max'] = 'not a numeric object' ret['shape'] = obj.shape ret['dtype'] = obj.dtype ret['size'] = obj.size try: ret['[0:%s] ' % (len(obj))] = list(obj[0:MAX_ITEMS_TO_HANDLE]) except: # This may not work depending on the array shape. pass return ret
def resolve(self, obj, attribute): if attribute == '__internals__': return defaultResolver.get_dictionary(obj) if attribute == 'min': if self.is_numeric(obj) and obj.size > 0: return obj.min() else: return None if attribute == 'max': if self.is_numeric(obj) and obj.size > 0: return obj.max() else: return None if attribute == 'shape': return obj.shape if attribute == 'dtype': return obj.dtype if attribute == 'size': return obj.size if attribute.startswith('['): container = NdArrayItemsContainer() i = 0 format_str = '%0' + str(int(len(str(len(obj))))) + 'd' for item in obj: setattr(container, format_str % i, item) i += 1 if i > MAX_ITEMS_TO_HANDLE: setattr(container, TOO_LARGE_ATTR, TOO_LARGE_MSG) break return container return None
def resolve(self, obj, attribute): if attribute == '__internals__': return defaultResolver.get_dictionary(obj) if attribute == 'min': if self.is_numeric(obj): return obj.min() else: return None if attribute == 'max': if self.is_numeric(obj): return obj.max() else: return None if attribute == 'shape': return obj.shape if attribute == 'dtype': return obj.dtype if attribute == 'size': return obj.size if attribute.startswith('['): container = NdArrayItemsContainer() i = 0 format_str = '%0' + str(int(len(str(len(obj))))) + 'd' for item in obj: setattr(container, format_str % i, item) i += 1 if i > MAX_ITEMS_TO_HANDLE: setattr(container, TOO_LARGE_ATTR, TOO_LARGE_MSG) break return container return None
def get_dictionary(self, obj): ret = dict() ret['__internals__'] = defaultResolver.get_dictionary(obj) if obj.size > 1024 * 1024: ret['min'] = 'ndarray too big, calculating min would slow down debugging' ret['max'] = 'ndarray too big, calculating max would slow down debugging' else: if self.is_numeric(obj): ret['min'] = obj.min() ret['max'] = obj.max() else: ret['min'] = 'not a numeric object' ret['max'] = 'not a numeric object' ret['shape'] = obj.shape ret['dtype'] = obj.dtype ret['size'] = obj.size ret['[0:%s] ' % (len(obj))] = list(obj[0:MAX_ITEMS_TO_HANDLE]) return ret
def get_dictionary(self, obj): ret = dict() ret['__internals__'] = defaultResolver.get_dictionary(obj) if obj.size > 1024 * 1024: ret['min'] = 'ndarray too big, calculating min would slow down debugging' ret['max'] = 'ndarray too big, calculating max would slow down debugging' else: if self.is_numeric(obj): ret['min'] = obj.min() ret['max'] = obj.max() else: ret['min'] = 'not a numeric object' ret['max'] = 'not a numeric object' ret['shape'] = obj.shape ret['dtype'] = obj.dtype ret['size'] = obj.size ret['[0:%s] ' % (len(obj))] = list(obj[0:MAX_ITEMS_TO_HANDLE]) return ret