def display(self, config: tp.Optional[DisplayConfig] = None) -> Display: config = config or DisplayActive.get() if self._recache: self._update_array_cache() # render display rows just of columns # sub_config_type = DisplayConfig(**config.to_dict(type_show=False)) # sub_config_no_type = DisplayConfig(**config.to_dict(type_show=False)) sub_config = config sub_display = None for d in range(self._depth): # as a slice this is far more efficient as no copy is made col = self._labels[:, d] # repeats = col == np.roll(col, 1) # repeats[0] = False # col[repeats] = '.' # TODO: spacer may not be best if sub_display is None: # the first sub_display = Display.from_values(col, header=DisplayHeader( self.__class__, self._name), config=sub_config, outermost=True, index_depth=0, columns_depth=1) else: sub_display.extend_iterable(col, header='') return sub_display
def display(self, config: tp.Optional[DisplayConfig] = None) -> Display: '''Return a Display of the Bus. ''' # NOTE: the key change is providing the Bus as the displayed class config = config or DisplayActive.get() d = Display([], config=config, outermost=True, index_depth=1, header_depth=2) # series and index header display_index = self._index.display(config=config) d.extend_display(display_index) d.extend_display( Display.from_values( self._series.values, # do not force loading with self.values header='', config=config)) display_cls = Display.from_values( (), header=DisplayHeader(self.__class__, self._series._name), config=config) d.insert_displays(display_cls.flatten()) return d
def display( self, config: tp.Optional[DisplayConfig] = None, *, style_config: tp.Optional[StyleConfig] = None, ) -> Display: '''{doc} Args: {config} ''' # NOTE: the key change over serires is providing the Bus as the displayed class config = config or DisplayActive.get() display_cls = Display.from_values( (), header=DisplayHeader(self.__class__, self._series._name), config=config) array = np.empty(shape=len(self._index), dtype=DTYPE_OBJECT) # NOTE: do not load FrameDeferred, so concate contained Series's values directly np.concatenate([b._values_mutable for b in self._series.values], out=array) array.flags.writeable = False series = Series(array, index=self._index, own_index=True) return series._display( config, display_cls=display_cls, style_config=style_config, )
def display(self, config: tp.Optional[DisplayConfig] = None ) -> Display: '''Return a Display of the Series. ''' config = config or DisplayActive.get() d = Display([], config=config, outermost=True, index_depth=1, columns_depth=2) # series and index header display_index = self._index.display(config=config) d.extend_display(display_index) d.extend_display(Display.from_values( self.values, header='', config=config)) display_cls = Display.from_values((), header=DisplayHeader(self.__class__, self._name), config=config) d.insert_displays(display_cls.flatten()) return d
def display( self, config: tp.Optional[DisplayConfig] = None, ) -> Display: '''{doc} Args: {config} ''' config = config or DisplayActive.get() if self._recache: self._update_array_cache() header: tp.Optional[DisplayHeader] if config.type_show: header = DisplayHeader(self.__class__, self._name) header_depth = 1 else: header = None header_depth = 0 return Display.from_values( self.values, header=header, config=config, outermost=True, index_depth=0, header_depth=header_depth, )
def display(self, config: tp.Optional[DisplayConfig] = None, *, style_config: tp.Optional[StyleConfig] = None, ) -> Display: '''{doc} Args: {config} ''' if self._assign_axis: self._update_axis_labels() drop_column_dtype = False if self._axis == 0: if not self._retain_labels: index = self.index.rename("Concatenated") else: index = self._bus.index.rename("Frames") columns = self.columns.rename("Aligned") else: index = self.index.rename("Aligned") if not self._retain_labels: columns = self.columns.rename("Concatenated") else: columns = self._bus.index.rename("Frames") drop_column_dtype = True config = config or DisplayConfig() def placeholder_gen() -> tp.Iterator[tp.Iterable[tp.Any]]: assert config is not None yield from repeat(tuple(repeat(config.cell_placeholder, times=len(index))), times=len(columns)) d = Display.from_params( index=index, columns=columns, header=DisplayHeader(self.__class__, self.name), column_forward_iter=placeholder_gen, column_reverse_iter=placeholder_gen, column_default_iter=placeholder_gen, config=config, style_config=style_config, ) # Strip out the dtype information! if config.type_show: if drop_column_dtype: # First Column Row -> last element is the dtype of the column # Guaranteed to not be index hierarchy as buses cannot have index hierarchies d._rows[1].pop() # Since placeholder_gen is not a ndarray, there is no dtype to append in the final row # However, in the case of a center ellipsis being added, an ellipsis will be # awkwardly placed direclty adjacent to the index dtype information. if d._rows[-1][-1] == Display.CELL_ELLIPSIS: d._rows[-1].pop() return d
def display(self, config: tp.Optional[DisplayConfig] = None) -> Display: config = config or DisplayActive.get() items = ((label, f.__class__) for label, f in self._items) series = Series.from_items(items, name=self._name) display_cls = Display.from_values( (), header=DisplayHeader(self.__class__, self._name), config=config) return series._display(config, display_cls)
def display(self, config: tp.Optional[DisplayConfig] = None) -> Display: '''{doc} Args: {config} ''' # NOTE: the key change over serires is providing the Bus as the displayed class config = config or DisplayActive.get() display_cls = Display.from_values( (), header=DisplayHeader(self.__class__, self._series._name), config=config) return self._series._display(config, display_cls)
def display(self, config: tp.Optional[DisplayConfig] = None, ) -> Display: config = config or DisplayActive.get() if self._recache: self._update_array_cache() return Display.from_values(self.values, header=DisplayHeader(self.__class__, self._name), config=config, outermost=True, index_depth=0, columns_depth=1 )
def display( self, config: tp.Optional[DisplayConfig] = None, *, style_config: tp.Optional[StyleConfig] = None, ) -> Display: '''Provide a :obj:`Series`-style display of the :obj:`Batch`. Note that if the held iterator is a generator, this display will exhaust the generator. ''' config = config or DisplayActive.get() items = ((label, f.__class__) for label, f in self._items) series = Series.from_items(items, name=self._name) display_cls = Display.from_values( (), header=DisplayHeader(self.__class__, self._name), config=config) return series._display( config, display_cls=display_cls, style_config=style_config, )