@@ -41,12 +41,12 @@ def _plot(self, plots: List[Dict[str, Any]], plot_size: Tuple[float, float] = (1
4141 Plot the given plots.
4242
4343 :param plots: The plots to plot. Each plot should be a dictionary with the following keys:
44- - plot_type (PLOT_TYPES): The type of the plot (e.g., ' time_series' or ' scatter' )
44+ - plot_type (PLOT_TYPES): The type of the plot (e.g., " time_series" or " scatter" )
4545 - data (Any): The data to plot
4646 - x (str): The name of the x-axis column
4747 - y (str): The name of the y-axis column
4848 - hue (str, optional): The name of the hue column. Default is None
49- - color (str, optional): The color of the plot. Default is ' blue'
49+ - color (str, optional): The color of the plot. Default is " blue"
5050 :type plots: List[Dict[str, Any]]
5151 :param plot_size: The size of the plot. Default is (15, 10)
5252 :type plot_size: Tuple[int, int], optional
@@ -62,31 +62,31 @@ def _plot(self, plots: List[Dict[str, Any]], plot_size: Tuple[float, float] = (1
6262 :return: None
6363 """
6464 # Create a new figure and axis
65- fig , ax = plt .subplots (figsize = plot_size , dpi = kwargs .get (' dpi' , 100 ))
65+ fig , ax = plt .subplots (figsize = plot_size , dpi = kwargs .get (" dpi" , 100 ))
6666
6767 # Plot each plot
6868 for plot_info in plots :
69- plot_type = plot_info .get (' plot_type' , None )
70- data = plot_info .get (' data' , None )
69+ plot_type = plot_info .get (" plot_type" , None )
70+ data = plot_info .get (" data" , None )
7171
7272 # Create the plot
7373 plot_strategy = PlotFactory .create_plot (plot_type )
74- plot_strategy .plot (ax , data , ** {k : v for k , v in plot_info .items () if k not in [' plot_type' , ' data' ]})
74+ plot_strategy .plot (ax , data , ** {k : v for k , v in plot_info .items () if k not in [" plot_type" , " data" ]})
7575
7676 # Set the title, x-axis label, and y-axis label of the plot
77- ax .set_title (kwargs .get (' fig_title' , '' ))
78- ax .set_xlabel (kwargs .get (' fig_xlabel' , '' ))
79- ax .set_ylabel (kwargs .get (' fig_ylabel' , '' ))
77+ ax .set_title (kwargs .get (" fig_title" , "" ))
78+ ax .set_xlabel (kwargs .get (" fig_xlabel" , "" ))
79+ ax .set_ylabel (kwargs .get (" fig_ylabel" , "" ))
8080
81- if kwargs .get (' fig_xticks' , None ) is not None :
82- ax .set_xticks (kwargs .get (' fig_xticks' )) # type: ignore
81+ if kwargs .get (" fig_xticks" , None ) is not None :
82+ ax .set_xticks (kwargs .get (" fig_xticks" )) # type: ignore
8383
84- if kwargs .get (' fig_yticks' , None ) is not None :
85- ax .set_yticks (kwargs .get (' fig_yticks' )) # type: ignore
84+ if kwargs .get (" fig_yticks" , None ) is not None :
85+ ax .set_yticks (kwargs .get (" fig_yticks" )) # type: ignore
8686 else :
8787 y_min , y_max = ax .get_ylim ()
8888 if isinstance (y_min , (int , float )) and isinstance (y_max , (int , float )):
89- num_yticks = kwargs .get (' fig_num_yticks' , 6 )
89+ num_yticks = kwargs .get (" fig_num_yticks" , 6 )
9090 yticks = PlotUtils .get_formatted_ticks (y_min , y_max , num_yticks )
9191 ax .set_yticks (yticks )
9292
@@ -95,27 +95,27 @@ def _plot(self, plots: List[Dict[str, Any]], plot_size: Tuple[float, float] = (1
9595 ax .set_ylim (yticks [0 ] - padding , yticks [- 1 ] + padding )
9696 ax .set_yticklabels ([f"{ val :.2f} { unit } " for tick in yticks for val , unit in [Formatter .format_large_number (tick )]])
9797
98- if kwargs .get (' fig_xticklabels' , None ) is not None :
99- ax .set_xticklabels (kwargs .get (' fig_xticklabels' )) # type: ignore
100- if kwargs .get (' fig_yticklabels' , None ) is not None :
101- ax .set_yticklabels (kwargs .get (' fig_yticklabels' )) # type: ignore
102- if kwargs .get (' fig_xticklabels_rotation' , None ) is not None :
98+ if kwargs .get (" fig_xticklabels" , None ) is not None :
99+ ax .set_xticklabels (kwargs .get (" fig_xticklabels" )) # type: ignore
100+ if kwargs .get (" fig_yticklabels" , None ) is not None :
101+ ax .set_yticklabels (kwargs .get (" fig_yticklabels" )) # type: ignore
102+ if kwargs .get (" fig_xticklabels_rotation" , None ) is not None :
103103 ax .set_xticks (ax .get_xticks ())
104- ax .set_xticklabels (ax .get_xticklabels (), rotation = kwargs .get (' fig_xticklabels_rotation' ))
105- if kwargs .get (' fig_yticklabels_rotation' , None ) is not None :
104+ ax .set_xticklabels (ax .get_xticklabels (), rotation = kwargs .get (" fig_xticklabels_rotation" ))
105+ if kwargs .get (" fig_yticklabels_rotation" , None ) is not None :
106106 ax .set_yticks (ax .get_yticks ())
107- ax .set_yticklabels (ax .get_yticklabels (), rotation = kwargs .get (' fig_yticklabels_rotation' ))
107+ ax .set_yticklabels (ax .get_yticklabels (), rotation = kwargs .get (" fig_yticklabels_rotation" ))
108108
109109 # Add the legend to the plot (remove duplicates)
110- if kwargs .get (' legend' , True ):
110+ if kwargs .get (" legend" , True ):
111111 handles , labels = plt .gca ().get_legend_handles_labels ()
112112 by_label = dict (zip (labels , handles ))
113- PlotUtils .set_standard_legend_style (ax , by_label .values (), by_label .keys (), title = kwargs .get (' legend_title' , None ))
113+ PlotUtils .set_standard_legend_style (ax , by_label .values (), by_label .keys (), title = kwargs .get (" legend_title" , None ))
114114 else :
115115 if ax .get_legend ():
116116 ax .get_legend ().remove ()
117117
118- ax .grid (kwargs .get (' grid' , True ))
118+ ax .grid (kwargs .get (" grid" , True ))
119119
120120 # Display the plot
121121 plt .tight_layout ()
@@ -134,7 +134,8 @@ def _process(self, outputs: Optional[List[Output]] = None, **kwargs) -> None:
134134 data , outputs = self .data_fetcher .fetch_data (
135135 experiment = self .experiment ,
136136 target_outputs = outputs ,
137- ** kwargs .get ('fetch_params' , {}))
137+ resample_freq = kwargs .get ("resample_freq" , "1s" ),
138+ ** kwargs .get ("fetch_params" , {}))
138139
139140 if data is None :
140141 self .logger .error ("No data fetched" )
@@ -153,26 +154,26 @@ def _process(self, outputs: Optional[List[Output]] = None, **kwargs) -> None:
153154
154155 if converted and converted .type == "TIME_GRAPH" :
155156 df = df .rename ({"start_time" : "timestamp" }, axis = 1 )
156- df [' end_time' ] = pd .to_datetime (df [' end_time' ])
157+ df [" end_time" ] = pd .to_datetime (df [" end_time" ])
157158
158159 # Apply common preprocessing steps
159- if kwargs .get (' normalize' , True ):
160+ if kwargs .get (" normalize" , True ):
160161 df = self .data_preprocessor .normalize (df )
161- if kwargs .get (' convert_datetime' , True ):
162+ if kwargs .get (" convert_datetime" , True ):
162163 df = self .data_preprocessor .convert_to_datetime (df )
163- if kwargs .get (' resample' , True ):
164- df = self .data_preprocessor .resample (df , frequency = kwargs .get (' resample_freq' , '1s' ))
165- if kwargs .get (' remove_minimum' , False ):
164+ if kwargs .get (" resample" , True ):
165+ df = self .data_preprocessor .resample (df , frequency = kwargs .get (" resample_freq" , "1s" ))
166+ if kwargs .get (" remove_minimum" , False ):
166167 df = self .data_preprocessor .remove_minimum (df )
167168
168169 self .dataframes [shortened ] = df
169170
170171 # Filter out dataframes with less than min_size instances
171- min_size = kwargs .get (' min_size' , 1 )
172+ min_size = kwargs .get (" min_size" , 1 )
172173 self .dataframes = {k : v for k , v in self .dataframes .items () if len (v ) >= min_size }
173174
174175 # Align timestamps if needed
175- if kwargs .get (' align_timestamps' , True ) and self .dataframes :
176+ if kwargs .get (" align_timestamps" , True ) and self .dataframes :
176177 self .dataframes , self .timestamps = DataPreprocessor .align_timestamps (self .dataframes )
177178
178179 # Call module-specific post-processing
0 commit comments