riptable.Utils.display_options

Display options for formatting and displaying numeric values, datasets, and multisets.

Classes

DisplayOptions

Provides display options for:

class riptable.Utils.display_options.DisplayOptions

Bases: object

Provides display options for:
  1. console screen for customizing width, height, and character buffers

  2. row, columns, and styles when displaying datasets and multisets

  3. formatting headers, footers, and general string widths

  4. formatting numeric types using scientific notation or specifying precision

  5. other miscellaneous display options such as prefixing group by column names

CONSOLE_X_BUFFER

Number of characters for buffer width on console display (default 30).

Type:

int

CONSOLE_X_HTML

Number of characters for buffer width on HTML display (default 340).

Type:

int

CONSOLE_X

Number of characters for console display width (default 150).

Type:

int

CONSOLE_Y

Number of characters for console display height (default 25).

Type:

int

HTML_DISPLAY

Toggle HTML display mode (default True).

Type:

bool

X_PADDING

Number of characters for column buffer in console display (default 4).

Type:

int

Y_PADDING

Number of characters for row buffer in console display (default 3).

Type:

int

ROW_ALL

Toggle display of all rows for Dataset, Multiset, and Struct objects (default False).

Type:

bool

COL_ALL

Toggle display of all columns for Dataset, Multiset, and Struct objects (default False).

Type:

bool

COL_MIN

Minimum columns to display for Dataset, Multiset, and Struct objects (default 1).

Type:

int

COL_MAX

Maximum columns to display for Dataset, Multiset, and Struct objects (default 50).

Type:

int

COL_T

Number of transposed rows to display, which appear as columns for Dataset, Multiset, and Struct objects (default 8).

Type:

int

HEAD_ROWS

Number of rows to display when calling head on a Dataset, Multiset, or Struct object (default 15).

Type:

int

TAIL_ROWS

Number of rows to display when calling tail on a Dataset, Multiset, or Struct object (default 15).

Type:

int

MAX_ROWS

Maximum number of rows to display for Dataset, Multiset, and Struct objects (default 30).

Type:

int

NO_STYLES

Toggle for colors in IPython console (default False). Note, may be difficult to see with light background.

Type:

bool

COLOR_MODE

Color mode for display (default None).

Type:

DisplayColorMode or None, optional

CUSTOM_COMPLETION = bool

Toggle on for attribute completion results that show in alphanumeric key, attribute, then method ordering for Dataset, Multiset, Struct (default False).

This will override the default IPython Completer._complete to a custom variant that allows custom completer dispatching using the IPython.utils.generics.complete_object hook while preserving the custom ordering.

Caution, below are the side effects when toggling this on: - IPython use_jedi is set to False since this approach is currently incompatible with Jedi completion because the code is actually evaluated on TAB. - IPython Completer._complete is monkey patched to change use the custom completion that is backwards compatible with Completer._complete, but allows preserving the order. - As of 20191218, if CUSTOM_COMPLETION is toggled on it results in a one-time registration of custom attribute completion per IPython session as opposed to supporting deregistration.

MAX_HEADER_WIDTH

Maximum number of characters for header strings in a Dataset, Multiset, or Struct object (default 15).

Type:

int

Maximum number of characters for footer strings in Dataset, Multiset, or Struct object (default 15).

Type:

int

MAX_STRING_WIDTH

Maximum number of characters for all strings (default 15).

Type:

int

PRECISION

Number of digits to display to the right of the decimal (default 2).

E_PRECISION

Number of digits to display to the right of the decimal in scientific notation (default 3).

E_THRESHOLD

Power of 10 at which the float flips to scientific notation 10**+/- (default 6).

E_MIN

lower limit before going to scientific notation (default None).

Type:

int or None, optional

E_MAX

Upper limit before going to scientific notation (default None).

Type:

int or None, optional

P_THRESHOLD

Precision threshold for area in between - so small values don’t display as zero (default None).

Type:

int or None, optional

NUMBER_SEPARATOR

Flag for separating thousands in floats and ints (default False).

Type:

bool

NUMBER_SEPARATOR_CHAR

Character for separating ,, , or _ (default DisplayNumberSeparator.Comma).

Type:

DisplayNumberSeparator

GB_PREFIX

Prefix for column names to indicate that they are groupby keys (default “*”).

Type:

str

save_config()
load_config()
reset_config()
e_min()
e_max()
p_threshold()
no_colors()

See also

DisplayTable

builds result tables with display options.

DisplayColorMode

enumerates supported color modes.

get_terminal_size

calculates console height and width.

Examples

CONSOLE_X_HTML sets the number of characters for buffer width on the HTML display. Truncated characters are replaced by ellipsis.

>>> from riptable.Utils.display_options import DisplayOptions
>>> ds = rt.Dataset({'A':[0,6,9], 'B' : [1.2,3.1,9.6], 'C': [-1.6,2.7,4.6], 'D' : [2.4,6.2,19.2]})
>>> ds
#   A      B       C       D
-   -   ----   -----   -----
0   0   1.20   -1.60    2.40
1   6   3.10    2.70    6.20
2   9   9.60    4.60   19.20
>>> DisplayOptions.CONSOLE_X_HTML = 25
>>> ds
#   A       B       ...     D
0   0       1.20    ...     2.40
1   6       3.10    ...     6.20
2   9       9.60    ...     19.20
COLOR_MODE
COL_ALL = False
COL_MAX = 50
COL_MIN = 1
COL_T = 8
CONSOLE_X = 150
CONSOLE_X_BUFFER = 30
CONSOLE_X_HTML = 340
CONSOLE_Y = 25
CUSTOM_COMPLETION: bool = False
E_MAX
E_MIN
E_PRECISION = 3
E_THRESHOLD = 6
GB_PREFIX = '*'
HEAD_ROWS = 15
HTML_DISPLAY = True
MAX_FOOTER_WIDTH = 15
MAX_HEADER_WIDTH = 15
MAX_ROWS = 30
MAX_STRING_WIDTH = 15
NO_STYLES = False
NUMBER_SEPARATOR = False
NUMBER_SEPARATOR_CHAR
PRECISION = 2
P_THRESHOLD
ROW_ALL = False
TAIL_ROWS = 15
X_PADDING = 4
Y_PADDING = 3
_AUTO_SAVE = False
_BAR_GRAPH = False
_BOUNDS
_CONFIG_LOADED = False
_HEAT_MAP = False
_PAINT_MAX = False
_PAINT_MIN = False
_PAINT_SIGNS = False
_PAINT_ZEROS = False
_RESET_OPTIONS = False
_TEST_FOOTERS = False
_TEST_ONE_PASS = False
_TRANSPOSE = False
_USERNAME
__setattr__(name, value)

Implement setattr(self, name, value).

static _get_default_path()
static _get_username()
classmethod e_max()

Returns the upper limit integer before displaying in scientific notation.

Returns:

e_max – Upper limit before going to scientific notation

Return type:

int

classmethod e_min()

Returns the lower limit integer before displaying in scientific notation.

Returns:

e_min – lower limit before going to scientific notation.

Return type:

int

static load_config(path=None, name=None)

Load display config file from the default location if path and name are not supplied. Otherwise load display config settings using path and name. Return bool if applied correctly, otherwise return -1 if resetting display options.

Parameters:
  • path (str, optional) – Path to display config file

  • name (str, optional) – Name of display config file

Returns:

result – True if config was loaded correctly, otherwise False. -1 if a new default config will be saved after a reset

Return type:

bool or int

static no_colors()

Turn off all non-default table styles.

Return type:

str, optional

classmethod p_threshold()

Returns DisplayOption.P_THRESHOLD. Defaults to 10 ** (-1 * DisplayOptions.PRECISION) - 1e-5.

Returns:

p_threshold – The precision threshold for area in between - so small values don’t display as zero

Return type:

float

static reset_config(path=None, name=None)

Reapply display config file from default location if path and name are not supplied. Otherwise override display config settings using path and name.

Parameters:
  • path (str, optional) – Path to display config file

  • name (str, optional) – Name of display config file

Return type:

None

static save_config(path=None, name=None, force_overwrite=False)

Save display options at the default config file path if path and name are not supplied. Otherwise save display options using path and name. If force_overwrite is True, then silently overwrite any previous configs at that file path, otherwise prompt for user input before overwrite.

Parameters:
  • path (str, optional) – Path to display config

  • name (str, optional) – Name of display config

  • force_overwrite (bool) – True to overwrite if file already exists, otherwise prompt user whether to overwrite the file.

Returns:

result – True if config was saved, otherwise False.

Return type:

bool