boilercore_docs.nbs#

Documentation utilities.

Module Contents#

Classes#

Paths

Paths.

Functions#

init_nb_env

Initialize the environment which will be inherited for notebook execution.

init

Initialize a documentation notebook.

copy_deps

Copy dependencies to the destination directory.

set_display_options

Set display options.

nowarn

Don’t raise any warnings. Optionally capture output for pesky warnings.

display_dataframe_with_math

Display a dataframe with MathJax-rendered math.

convert_tex_to_html

Manually apply the MyST parser to convert \(-\) into MathJax’s HTML code.

style_df

Style a dataframe.

display_dfs

Display formatted DataFrames.

get_df_formatter

Get formatter for the dataframe.

format_cell

Format individual cells.

get_formatter

Get the formatter depending on the type of the instance.

truncate

Truncate long dataframes, showing only the head and tail.

Data#

FONT_SCALE

Plot font scale.

PRECISION

The desired precision.

FLOAT_SPEC

The desired float specification for formatted output.

HIDE

Hide unsuppressed output. Can’t use semicolon due to black autoformatter.

DISPLAY_ROWS

The number of rows to display in a dataframe.

API#

boilercore_docs.nbs.FONT_SCALE#

1.3

Plot font scale.

boilercore_docs.nbs.PRECISION#

4

The desired precision.

boilercore_docs.nbs.FLOAT_SPEC#

None

The desired float specification for formatted output.

boilercore_docs.nbs.HIDE#

‘display(…)’

Hide unsuppressed output. Can’t use semicolon due to black autoformatter.

boilercore_docs.nbs.DISPLAY_ROWS#

20

The number of rows to display in a dataframe.

boilercore_docs.nbs.init_nb_env()#

Initialize the environment which will be inherited for notebook execution.

class boilercore_docs.nbs.Paths#

Paths.

root: pathlib.Path#

None

docs: pathlib.Path#

None

deps: pathlib.Path#

None

boilercore_docs.nbs.init(
font_scale: float = FONT_SCALE,
) boilercore_docs.nbs.Paths#

Initialize a documentation notebook.

boilercore_docs.nbs.copy_deps(
src,
dst,
)#

Copy dependencies to the destination directory.

boilercore_docs.nbs.set_display_options(
font_scale,
)#

Set display options.

boilercore_docs.nbs.nowarn(
capture: bool = False,
)#

Don’t raise any warnings. Optionally capture output for pesky warnings.

boilercore_docs.nbs.display_dataframe_with_math(
df,
raw=False,
)#

Display a dataframe with MathJax-rendered math.

boilercore_docs.nbs.convert_tex_to_html(
html,
raw=False,
)#

Manually apply the MyST parser to convert \(-\) into MathJax’s HTML code.

boilercore_docs.nbs.style_df(
df: boilercore_docs.types.DfOrS,
head: bool = False,
)#

Style a dataframe.

boilercore_docs.nbs.display_dfs(
*dfs: boilercore_docs.types.DfOrS,
head: bool = False,
)#

Display formatted DataFrames.

When a mapping of column names to callables is given to the Pandas styler, the callable will be used internally by Pandas to produce formatted strings. This differs from elementwise formatting, in which Pandas expects the callable to actually process the value and return the formatted string.

boilercore_docs.nbs.get_df_formatter(
df: pandas.DataFrame,
truncated: bool,
) collections.abc.Callable[..., str] | dict[str, collections.abc.Callable[..., str]]#

Get formatter for the dataframe.

boilercore_docs.nbs.format_cell(
cell,
) str#

Format individual cells.

boilercore_docs.nbs.get_formatter(
instance: Any,
) collections.abc.Callable[..., str]#

Get the formatter depending on the type of the instance.

boilercore_docs.nbs.truncate(
df: boilercore_docs.types.DfOrS,
head: bool = False,
) tuple[pandas.DataFrame, bool]#

Truncate long dataframes, showing only the head and tail.