neuralogic.utils.visualize package

Module contents

draw(drawer: Any, obj: Any, filename: str | None = None, show: bool = True, img_type: str = 'png', *args: Any, **kwargs: Any) Any[source]

Draws the object using the provided drawer.

Parameters:
  • drawer (Any) – The drawer to use.

  • obj (Any) – The object to draw.

  • filename (str, optional) – The filename to draw into. Default: None.

  • show (bool) – Whether to show the image. Default: True.

  • img_type (str) – The image type. Default: β€œpng”.

  • args (Any) – Additional arguments for the drawer.

  • kwargs (Any) – Additional keyword arguments for the drawer.

Returns:

The drawing data, image object, or None if drawn into a file.

Return type:

Union[Any, bytes, None]

draw_grounding(grounding: Any, filename: str | None = None, show: bool = True, img_type: str = 'png', value_detail: int = 0, graphviz_path: str | None = None, *args: Any, **kwargs: Any) Any[source]
Draws sample’s grounding either as an image of type img_type either into:
  • a file - if filename is specified),

  • an IPython Image or Image popup - if show is True

  • or bytes otherwise

Parameters:
  • grounding (Any) – The grounding to draw.

  • filename (str, optional) – The filename to draw into. Default: None.

  • show (bool) – Whether to show the image. Default: True.

  • img_type (str) – The image type. Default: β€œpng”.

  • value_detail (int) – The level of detail for values. Default: 0.

  • graphviz_path (str, optional) – The path to the Graphviz executable. Default: None.

  • args (Any) – Additional arguments for the drawer.

  • kwargs (Any) – Additional keyword arguments for the drawer.

Returns:

The grounding drawing.

Return type:

Union[Any, bytes, None]

draw_model(model: Any, filename: str | None = None, show: bool = True, img_type: str = 'png', value_detail: int = 0, graphviz_path: str | None = None, *args: Any, **kwargs: Any) Any[source]
Draws model either as an image of type img_type either into:
  • a file - if filename is specified),

  • an IPython Image or Image popup - if show is True

  • or bytes otherwise

Parameters:
  • model (NeuralModule) – The model to draw.

  • filename (str, optional) – The filename to draw into. Default: None.

  • show (bool) – Whether to show the image. Default: True.

  • img_type (str) – The image type. Default: β€œpng”.

  • value_detail (int) – The level of detail for values. Default: 0.

  • graphviz_path (str, optional) – The path to the Graphviz executable. Default: None.

  • args (Any) – Additional arguments for the drawer.

  • kwargs (Any) – Additional keyword arguments for the drawer.

Returns:

The model drawing.

Return type:

Union[Any, bytes, None]

draw_sample(sample: Any, filename: str | None = None, show: bool = True, img_type: str = 'png', value_detail: int = 0, graphviz_path: str | None = None, *args: Any, **kwargs: Any) Any[source]
Draws sample either as an image of type img_type either into:
  • a file - if filename is specified),

  • an IPython Image or Image popup - if show is True

  • or bytes otherwise

Parameters:
  • sample (Any) – The sample to draw.

  • filename (str, optional) – The filename to draw into. Default: None.

  • show (bool) – Whether to show the image. Default: True.

  • img_type (str) – The image type. Default: β€œpng”.

  • value_detail (int) – The level of detail for values. Default: 0.

  • graphviz_path (str, optional) – The path to the Graphviz executable. Default: None.

  • args (Any) – Additional arguments for the drawer.

  • kwargs (Any) – Additional keyword arguments for the drawer.

Returns:

The sample drawing.

Return type:

Union[Any, bytes, None]

get_drawing_settings(img_type: str = 'png', value_detail: int = 0, graphviz_path: str | None = None) SettingsProxy[source]

Returns the default settings instance for drawing with a specified image type.

Parameters:
  • img_type (str) – The image type. Default: β€œpng”.

  • value_detail (int) – The level of detail for values. Default: 0.

  • graphviz_path (str, optional) – The path to the Graphviz executable. Default: None.

Returns:

The settings proxy for drawing.

Return type:

SettingsProxy

get_graphviz_path(path: str | None = None) str | None[source]

Get the path to the Graphviz executable

get_grounding_drawer(settings: SettingsProxy) Any[source]

Returns the grounding drawer.

Parameters:

settings (SettingsProxy) – The settings proxy.

Returns:

The grounding drawer.

Return type:

Any

get_model_drawer(settings: SettingsProxy) Any[source]

Returns the model drawer.

Parameters:

settings (SettingsProxy) – The settings proxy.

Returns:

The model drawer.

Return type:

Any

get_sample_drawer(settings: SettingsProxy) Any[source]

Returns the sample drawer.

Parameters:

settings (SettingsProxy) – The settings proxy.

Returns:

The sample drawer.

Return type:

Any

is_jupyter() bool[source]
model_to_dot_source(model: Any) str[source]

Renders the model into its dot source representation.

Parameters:

model (NeuralModule) – The model to render.

Returns:

The dot source representation.

Return type:

str

sample_to_dot_source(sample: Any, value_detail: int = 0) str[source]

Renders the sample into its dot source representation.

Parameters:
  • sample (Any) – The sample to render.

  • value_detail (int) – The level of detail for values. Default: 0.

Returns:

The dot source representation.

Return type:

str

to_dot_source(drawer: Any, obj: Any) str[source]