def display(self, config: DisplayConfig=None) -> Display: config = config or DisplayActive.get() if self._recache: self._update_array_cache() # render display rows just of columns sub_config = DisplayConfig(**config.to_dict(type_show=False)) 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: sub_display = Display.from_values(col, header='', config=sub_config) else: sub_display.append_iterable(col, header='') header = '<' + self.__class__.__name__ + '>' return Display.from_values( sub_display.to_rows()[1:-1], # truncate unused header header = header, config=config )
def test_bus_display_a(self) -> None: f1 = Frame.from_dict( dict(a=(1,2), b=(3,4)), index=('x', 'y'), name='f1') f2 = Frame.from_dict( dict(c=(1,2,3), b=(4,5,6)), index=('x', 'y', 'z'), name='f2') f3 = Frame.from_dict( dict(d=(10,20), b=(50,60)), index=('p', 'q'), name='f3') b1 = Bus.from_frames((f1, f2, f3)) self.assertEqual( b1.display(config=DisplayConfig(type_color=False)).to_rows(), ['<Bus>', '<Index>', 'f1 Frame', 'f2 Frame', 'f3 Frame', '<<U2> <object>']) rows1 = b1.display(config=DisplayConfig( type_color=False, type_show=False)).to_rows() self.assertEqual(rows1, ['f1 Frame', 'f2 Frame', 'f3 Frame']) rows2 = b1.display(config=DisplayConfig( type_color=False, type_show=False, include_index=False)).to_rows() self.assertEqual(rows2, ['Frame', 'Frame', 'Frame'])
def display_wide(self, config: tp.Optional[DisplayConfig] = None ) -> Display: config = config or DisplayActive.get() args = config.to_dict() args.update(dict( display_columns=np.inf, cell_max_width=np.inf, cell_max_width_leftmost=np.inf, )) return self.display(config=DisplayConfig(**args))
def display_wide(self, config: tp.Optional[DisplayConfig] = None ) -> Display: '''Maximize horizontal presentation. {doc} Args: {config} ''' config = config or DisplayActive.get() args = config.to_dict() args.update(dict( display_columns=np.inf, cell_max_width=np.inf, cell_max_width_leftmost=np.inf, )) return self.display(config=DisplayConfig(**args))