riptable.rt_display

Classes

DisplayCell

Wrapper around a string for styled console or html display.

DisplayColumn

New display column class for holding final display data.

DisplayDetect

DisplayString

DisplayTable

DisplayText

Only uses two colors: green and purple OR cyan and blue

class riptable.rt_display.DisplayCell(string, value=None, color=None, html=False, colspan=None, align=None)

Wrapper around a string for styled console or html display. Original value can also be stored for future column or table-wide math operations.

color_mode_dict
darkbg_styles
lightbg_styles
no_styles
__len__()
__repr__()

Return repr(self).

__str__()

Return str(self).

display(html=False, plain=False)
paint_cell()
class riptable.rt_display.DisplayColumn(data, row_break=None, color=None, header='', align=DisplayJustification.Right, html=False, itemformat=None, footer=None)

New display column class for holding final display data.

Responsible for:

-adding a row break character to each array at the appropriate spot -painting display cells -adding padding for console -replacing whitespace with   for HTML -orchestrating math operations that span the whole column

property data

does not check for any formatting that has been applied. This routine is to assist in modifying repeated values in multikey groupby operations.

Type:

Return string data array. Note

property display_width

When columns are being fit during display, need to account for padding between them, otherwise overflow will occur and table will break.

property footer
property header
css_color_classes
css_decoration_classes
css_justification_classes
__getitem__(index)
__repr__()

Return repr(self).

__setitem__(index, value)
__str__()

Return str(self).

_build_end(end, final_color=None, plain=False, justification=None)
align_column(align, col_slice=slice(None, None, None))
static align_console_string(string, width, align=DisplayJustification.Right)

Pad string for correct alignment in console table columns.

static align_html(align=DisplayJustification.Right)
build_header(final_color=None, plain=False, align=None)
build_summary()
paint_column(color, col_slice=None, badrows=None)

Called when a column needs to be colored For instance the left side may be row numbered

paint_highlightmax()

not implemented, maybe for future Dataset.style() call Will paint max value of each numeric column gold.

paint_posneg()

*not implemented, maybe for future Dataset.style() call Will paint positive values green, negative values red for all numeric columns in IPython console.

plain_string_list()
static style_classes_html(itemformat=None)

Calls routines to add a CSS class for every styling option in the ItemFormat object

style_column(style, col_slice=None, badrows=None)

This will replace paint_column as a single styling call for all column properties.

styled_string_list()
static text_decoration_html(style=None)
class riptable.rt_display.DisplayDetect

Bases: object

ColorMode
ForceRepr = False
Mode = 0
static get_display_mode()
class riptable.rt_display.DisplayString(string)

Bases: object

__repr__()

Return repr(self).

__str__()

Return str(self).

_repr_html_()
class riptable.rt_display.DisplayTable(attribs=None)

Bases: object

DebugMode = False
FORCE_REPR = False
INVALID_DATA
TestFooter = False
console_x_offset = 3
options
add_required_columns(header_names, table_data, footers, masked=False, gbkeys=None, transpose=False, color=None, style=None)

header_names : list of string header names (not tuples) table_data : list of arrays footers : list of footer rows (lists of ColHeader tuples) masked : flag to indicate that the column has already been trimmed (build column does not need to apply a row mask) gbkeys : dictionary of groupby keys - columns need to be painted differently

all_columns_console(console_width, left_offset, headers, columns)
all_columns_console_multiline(console_width, left_offset, headers, columns)

not implemented only supports two-line headers

build_column(header, column, masked=False, footer=None, style=None)

All DisplayColumns built for final display will funnel through this function. Any row breaks will be added here if necessary.

build_final_ends(plain=False, badcols=None, badrows=None)
build_final_headers_console(plain=False)

specifically for multi-line Translates the tables header tuples into console strings with spaces for padding Note: this routine is very similar to build_final_headers_html. Keeping them separate for readability.

build_final_headers_html(plain=False)

Translates the tables header tuples into HTML tags. Note: this routine is very similar to build_final_headers_console. Keeping them separate for readability.

build_result_table(header_tups, main_data, nrows, footer_tups=None, keys=None, sortkeys=None, from_str=False, sorted_row_idx=None, transpose_on=False, row_numbers=None, right_cols=None, badrows=None, badcols=None, styles=None, callback=None)

Step 1: save all parameters into self namespace, as build_result_table is broken down into several functions. Step 2: if set_view has been called, only display the specified columns. if sort_values has been called, move those columns to the front. Step 3: build a row mask. if the table is too large to display, pull the first and last rows for display. if a sorted index is present, apply it. Step 4: measure the table. groupby key columns will always be included. fit as many columns as possible into the console. if the display is for html, defaults have been set to a hard-coded console width. other console width is detected upon each display. if there are too many columns to display, a column break will be set. Step 5: build the table. the result table is broken down into three parts: headers, left side, and main table. the headers are column names combined with left headers, or numbers if the table is transposed. the left side is row numbers, row labels, or groupby keys. the main table is first and last columns that would fit in the display. use the DisplayColumn class to organize the data for future styling. If the table is abbreviated, include a row break in each column. Step 6: style the table. html_on will let DisplayColumn and DisplayCell know how to “paint” the individual cells. Step 7: if the header has multiple lines and/or needs to be transposed, fix it up now. Step 8: transpose the table for final display. we build the table by column, but it needs to be displayed by row. if the table should be transposed, don’t rotate it - clean up the headers. Step 9: pass the table string to our console or html routine for final output.

TODO: reduce the measuring and building to one pass over the data. currently rendering time is not an issue. ~15ms

build_result_table_new(header_tups, main_data, nrows, keys=None, sortkeys=None, from_str=False, sorted_row_idx=None, transpose_on=False, row_numbers=None, right_cols=None, footer_tups=None, badcols=None, badrows=None, styles=None, callback=None)
callback: func, default None

callback to signature

build_row_mask(head, tail, total)
build_transposed_columns(columns)

Transposed column data needs to be constructed differently. Widths will be calculated as a maximum items in multiple arrays. At the end of the table’s construction, it will remain as a list of rows.

classmethod console_detect_settings()

For debugging console display.

static display_detect()

Call to redetect the display mode. This is useful when launching a qtconsole from jupyter lab.

static display_html(html=None)
Parameters:

html (defaults to None. Set to True to force html.) – set to None to return the current mode.

static display_precision(precision=2)
Parameters:

precision (defaults to 2. How many places after the decimal to display.) – set to None to return the current precision.

Examples

rt.display_precision(4)

static display_rows(rows=None)
Parameters:
  • rows (defaults to None. How many top and bottom rows to display in a Dataset.) – set to None to return the current rows.

  • Display.options.HEAD_ROWS/TAIL_ROWS (Contolled by) –

See also

Display.options.TAIL_ROWS, Display.options.HEAD_ROWS

Examples

rt.display_rows(20)

static display_threshold(threshold=6)
Parameters:

precision (defaults to 6. How many powers of 10 before flipping to scientific notation.) – set to None to return the current threshold.

Notes

E_THRESHOLD = 6 # power of 10 at which the float flips to scientific notation 10**+/- E_PRECISION = 3 # number of digits to display to the right of the decimal (sci notation)

Examples

rt.display_threshold(6)

fit_max_columns(headers, columns, total_width, console_width, footers=None)

The display will attempt to fit as many columns as possible into the console. HTML display has been assigned a default value for self._console_x (see DisplayTable.__init__)

If the user changes their self.options.COL_ALL to True, all columns will be displayed on the same line. Note: this will break console display for large tables and should only be used in jupyter lab now.

in progress If the user requested all columns to be shown - regardless of width, the display will split them up into separate views with the maximum columns per line.

fix_multiline_footers(plain=False, badcols=None, badrows=None)
fix_multiline_headers()

Fixes multi-line headers if a column break was present. cell_spans in ColHeader might need to be changed. Need use cases for more than two lines, but the same loop should work.

fix_repeated_keys(columns, repeat_string='.')

Display a different string when the first column of a multikey groupby is repeated. TODO: add support for the same behavior with repeated keys in multiple columns.

footers_to_string(footer_row)

Takes row of footer tuples and turns into string list. For adding/styling multiline footers.

get_bad_color()

put in the bad_col dictionary

get_sort_col_idx(col_names)
class riptable.rt_display.DisplayText(text)

Bases: object

Only uses two colors: green and purple OR cyan and blue For HTML

ds = rt.Dataset({‘test’: rt.arange(10)}) schema = {‘Description’: ‘This is a structure’, ‘Steward’: ‘Nick’} ds.apply_schema(schema) ds.info()

ESC = '\x1b['
HEADER_DARK = '1;36m'
HEADER_LIGHT = '1;34m'
RESET = '\x1b[00m'
TITLE_DARK = '1;32m'
TITLE_LIGHT = '1;35m'
__repr__()

Return repr(self).

__str__()

Return str(self).

static _as_if_dark()
static _format(txt, fmt)
static _header_color()
_repr_html_()
static _title_color()
static header_format(txt)
static title_format(txt)