Skip to content

Commit

Permalink
add possibility to save results from draw_pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasbtnfr committed Mar 21, 2023
1 parent 19049bf commit 836902e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions skmine/periodic/cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def get_residuals(self, *patterns_id, sort="time"):
return residuals_transf_pd


def draw_pattern(self, pattern_id):
def draw_pattern(self, pattern_id, directory=None):
"""
Visually display a pattern based on its id from the discover command.
Expand All @@ -425,6 +425,9 @@ def draw_pattern(self, pattern_id):
pattern_id : int
The ID of the pattern to be displayed. This ID is to be retrieved directly from the discover command.
directory : str, default=None
Directory where the generated image and the DOT file are stored
Returns
-------
Digraph
Expand All @@ -440,4 +443,8 @@ def draw_pattern(self, pattern_id):
if isinstance(nid, int):
if "event" in pattern[nid].keys():
pattern[nid]["event"] = list(self.data_details.map_ev_num.keys())[int(pattern[nid]["event"])]
return draw_pattern(pattern)

graph = draw_pattern(pattern)
if directory:
graph.render(directory=directory)
return graph

0 comments on commit 836902e

Please sign in to comment.