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, settings: DrawingSettings | 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.
settings (DrawingSettings, optional) β Styling settings. When provided, they control value detail and graph styling, while
filename,img_typeandgraphviz_pathfrom this call still control the output.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, settings: DrawingSettings | 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.
settings (DrawingSettings, optional) β Styling settings. When provided, they control value detail and graph styling, while
filename,img_typeandgraphviz_pathfrom this call still control the output.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_pipeline(pipeline: Any, filename: str | None = None, show: bool = True, img_type: str = 'png', value_detail: int = 0, graphviz_path: str | None = None, settings: DrawingSettings | None = None, *args: Any, **kwargs: Any) Any[source]ο
- Draws a backend pipeline 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:
pipeline (Any) β The backend pipeline (
cz.cvut.fel.ida.pipelines.Pipeline) 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.
settings (DrawingSettings, optional) β Styling settings. When provided, they control value detail and graph styling, while
filename,img_typeandgraphviz_pathfrom this call still control the output.args (Any) β Additional arguments for the drawer.
kwargs (Any) β Additional keyword arguments for the drawer.
- Returns:
The pipeline 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, settings: DrawingSettings | 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.
settings (DrawingSettings, optional) β Styling settings. When provided, they control value detail and graph styling, while
filename,img_typeandgraphviz_pathfrom this call still control the output.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) DrawingSettings[source]ο
Returns standalone drawing settings configured with the specified image type.
- Parameters:
img_type (str) β The image type. Default: βpngβ.
value_detail (int) β The level of detail for values (0, 1 or 2). Default: 0.
graphviz_path (str, optional) β The path to the Graphviz executable. Default: None.
- Returns:
Standalone drawing settings. Style and value detail can be further configured on the returned object before it is passed to a drawer.
- Return type:
DrawingSettings
- get_graphviz_path(path: str | None = None) str | None[source]ο
Get the path to the Graphviz executable
- get_grounding_drawer(settings: DrawingSettings) Any[source]ο
Returns the grounding drawer.
- Parameters:
settings (DrawingSettings) β The drawing settings.
- Returns:
The grounding drawer.
- Return type:
Any
- get_model_drawer(settings: DrawingSettings) Any[source]ο
Returns the model drawer.
- Parameters:
settings (DrawingSettings) β The drawing settings.
- Returns:
The model drawer.
- Return type:
Any
- get_pipeline_drawer(settings: DrawingSettings) Any[source]ο
Returns the pipeline drawer.
- Parameters:
settings (DrawingSettings) β The drawing settings.
- Returns:
The pipeline drawer.
- Return type:
Any
- get_sample_drawer(settings: DrawingSettings) Any[source]ο
Returns the sample drawer.
- Parameters:
settings (DrawingSettings) β The drawing settings.
- Returns:
The sample drawer.
- Return type:
Any
- graphml_to_networkx(graphml: str | None) Any[source]ο
Loads a GraphML string into a networkx graph.
- Parameters:
graphml (str | None) β The GraphML source.
- Returns:
The graph read from the GraphML source.
- Return type:
networkx.DiGraph
- model_to_dot_source(model: Any, settings: DrawingSettings | None = None) str[source]ο
Renders the model into its dot source representation.
- Parameters:
model (NeuralModule) β The model to render.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided, they are used instead of the defaults.
- Returns:
The dot source representation.
- Return type:
str
- model_to_graphml_source(model: Any, value_detail: int = 0, settings: DrawingSettings | None = None) str | None[source]ο
Renders the model into its GraphML source representation.
- Parameters:
model (NeuralModule) β The model to render.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- Returns:
The GraphML source, or None if the backend graphviz-based conversion failed.
- Return type:
str | None
- model_to_networkx(model: Any, value_detail: int = 0, settings: DrawingSettings | None = None) Any[source]ο
Converts the model into a networkx graph.
- Parameters:
model (NeuralModule) β The model to convert.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- Returns:
The model as a directed graph. Node labels are stored in the βlabelβ attribute.
- Return type:
networkx.DiGraph
- pipeline_to_dot_source(pipeline: Any, value_detail: int = 0, settings: DrawingSettings | None = None) str[source]ο
Renders the pipeline into its dot source representation.
- Parameters:
pipeline (Any) β The backend pipeline to render.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- Returns:
The dot source representation.
- Return type:
str
- pipeline_to_graphml_source(pipeline: Any, value_detail: int = 0, settings: DrawingSettings | None = None) str | None[source]ο
Renders the pipeline into its GraphML source representation.
- Parameters:
pipeline (Any) β The backend pipeline to render.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- Returns:
The GraphML source, or None if the backend graphviz-based conversion failed.
- Return type:
str | None
- pipeline_to_networkx(pipeline: Any, value_detail: int = 0, settings: DrawingSettings | None = None) Any[source]ο
Converts the pipeline into a networkx graph.
- Parameters:
pipeline (Any) β The backend pipeline to convert.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- Returns:
The pipeline as a directed graph. Node labels are stored in the βlabelβ attribute.
- Return type:
networkx.DiGraph
- sample_to_dot_source(sample: Any, value_detail: int = 0, settings: DrawingSettings | None = None) 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.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- Returns:
The dot source representation.
- Return type:
str
- sample_to_graphml_source(sample: Any, value_detail: int = 0, settings: DrawingSettings | None = None) str | None[source]ο
Renders the sample into its GraphML source representation.
- Parameters:
sample (Any) β The sample to render.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- Returns:
The GraphML source, or None if the backend graphviz-based conversion failed.
- Return type:
str | None
- sample_to_networkx(sample: Any, value_detail: int = 0, settings: DrawingSettings | None = None) Any[source]ο
Converts the sample into a networkx graph.
- Parameters:
sample (Any) β The sample to convert.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- Returns:
The sample as a directed graph. Node labels are stored in the βlabelβ attribute.
- Return type:
networkx.DiGraph
- save_model_graphml(model: Any, path: str, value_detail: int = 0, settings: DrawingSettings | None = None) None[source]ο
Saves the model graph as a GraphML file consumable by networkx.
- Parameters:
model (NeuralModule) β The model to save.
path (str) β The destination file path. Parent directories are created if needed.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- save_pipeline_graphml(pipeline: Any, path: str, value_detail: int = 0, settings: DrawingSettings | None = None) None[source]ο
Saves the pipeline graph as a GraphML file consumable by networkx.
- Parameters:
pipeline (Any) β The backend pipeline to save.
path (str) β The destination file path. Parent directories are created if needed.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- save_sample_graphml(sample: Any, path: str, value_detail: int = 0, settings: DrawingSettings | None = None) None[source]ο
Saves the sample graph as a GraphML file consumable by networkx.
- Parameters:
sample (Any) β The sample to save.
path (str) β The destination file path. Parent directories are created if needed.
value_detail (int) β The level of detail for values. Default: 0.
settings (DrawingSettings, optional) β Standalone drawing settings. When provided,
value_detailis ignored.
- to_graphml_source(drawer: Any, obj: Any) str | None[source]ο
Renders the object into its GraphML source representation.
- Parameters:
drawer (Any) β The drawer to use.
obj (Any) β The object to render.
- Returns:
The GraphML source, or None if the backend graphviz-based conversion failed.
- Return type:
str | None