API

This page documents the supported top-level public API from drcutils.__all__.

Top-level groups:

  • Module facades: brand, data, runtime, viz

  • Brand utilities: COLORS, flag, watermark

  • Data utility: convert

  • Runtime helpers: is_notebook, is_google_colab

  • Visualization helpers: export_figure, get_figure_preset, visualize_network, visualize_stl

Public package exports for drcutils.

drcutils.convert(thing_to_convert_from, thing_to_convert_to, from_kwargs=None, to_kwargs=None)[source]

Convert supported files to another supported format.

Parameters:
  • thing_to_convert_from – Source file path.

  • thing_to_convert_to – Target file path.

  • from_kwargs – Optional keyword args for the input reader.

  • to_kwargs – Optional keyword args for the output writer.

Raises:

ValueError – If conversion is unsupported.

drcutils.export_figure(fig, outpath_stem, *, targets=None, formats=None, dpi=300, transparent=False, tight=True, font_family=None, base_fontsize=None, embed_fonts=True, metadata=None)[source]

Export a Matplotlib figure for publication presets.

Parameters:
  • fig – Matplotlib figure object to export.

  • outpath_stem – Base output path stem.

  • targets – Preset targets to render.

  • formats – Output formats such as pdf, png, or svg.

  • dpi – Raster resolution for bitmap outputs.

  • transparent – Whether to export with transparent background.

  • tight – Whether to save with tight bounding boxes.

  • font_family – Optional font family override.

  • base_fontsize – Optional base font size override.

  • embed_fonts – Whether to configure embedded/export-friendly fonts.

  • metadata – Optional metadata mapping passed to savefig.

Returns:

A dictionary containing generated file paths, resolved settings, and warnings.

drcutils.flag(output_filepath=None, size=None)[source]

Create a DRC color flag image.

drcutils.get_figure_preset(target)[source]

Return figure preset settings for a named target.

Parameters:

target – One of one_col, two_col, or slide_16x9.

Returns:

A dictionary with width, height, and font scale.

Raises:

ValueError – If target is unknown.

drcutils.is_google_colab()[source]

Determine whether or not the environment is in Google Colab.

Returns:

True when running in Google Colab.

drcutils.is_notebook()[source]

Determine whether or not the environment is in a notebook.

Returns:

True when running in a notebook runtime.

drcutils.visualize_network(path, height=500, port=8000)[source]

Visualize a neural network with Netron.

Parameters:
  • path – Filepath to the saved neural network.

  • height – Height of the iframe visualization in pixels.

  • port – Port on which the visualization is served.

Returns:

None. Opens the visualization in an iframe (notebook) or browser (terminal).

drcutils.visualize_stl(filepath, color='#ffffff')[source]

Visualize an STL mesh as a Plotly figure.

Parameters:
  • filepath – Path to the STL file.

  • color – Hex color used for mesh shading.

Returns:

A Plotly figure containing a single Mesh3d trace.

Raises:

ImportError – If Plotly is not installed.

drcutils.watermark(filepath, output_filepath=None, watermark_filepath=None, box=None, *, logo_layout='stacked', logo_variant='auto', on_black='auto')[source]

Watermark an image using packaged DRC assets or a custom watermark file.