@@ -69,7 +69,7 @@ def gtk_run(closure):
6969 Args:
7070 closure Ignored parameter
7171 """
72- tools .warning ("GTK 3.0 is unavailable: %s" % ( err ,) )
72+ tools .warning (f "GTK 3.0 is unavailable: { err } " )
7373
7474# ---------------------------------------------------------------------------- #
7575# Data frame columns selection helper
@@ -91,7 +91,7 @@ def select(data, *only_columns):
9191 if len (only_columns ) == 0 :
9292 return data
9393 # Intelligent selection
94- columns = list ()
94+ columns = []
9595 for only_column in only_columns :
9696 only_column = only_column .lower ()
9797 for column in data .columns :
@@ -136,7 +136,7 @@ def to_string(x):
136136 Converted data to string
137137 """
138138 if type (x ) is float :
139- return "%e" % x
139+ return f" { x :e } "
140140 return str (x ).strip ()
141141
142142 def __init__ (self , data , title = "Display data" ):
@@ -149,7 +149,7 @@ def __init__(self, data, title="Display data"):
149149 # Make and fill list store
150150 store = Gtk .ListStore (* ([str ] * (len (data .columns ) + 1 )))
151151 for row in data .itertuples ():
152- store .append (list ( self .to_string (x ) for x in row ) )
152+ store .append ([ self .to_string (x ) for x in row ] )
153153 # Make the associated tree view
154154 view = Gtk .TreeView (store )
155155 columns = list (data .columns )
@@ -196,17 +196,15 @@ def __init__(self, path_results):
196196 # Ensure directory exist
197197 if not path_results .exists ():
198198 raise tools .UserException (
199- "Result directory %r cannot be accessed or does not exist"
200- % str (path_results )
199+ f"Result directory { str (path_results )!r} cannot be accessed or does not exist"
201200 )
202201 # Load configuration string
203202 path_config = path_results / "config"
204203 try :
205204 data_config = path_config .read_text ().strip ()
206205 except Exception as err :
207206 tools .warning (
208- "Result directory %r: unable to read configuration (%s)"
209- % (str (path_results ), err )
207+ f"Result directory { str (path_results )!r} : unable to read configuration ({ err } )"
210208 )
211209 data_config = None
212210 # Load configuration json
@@ -216,8 +214,7 @@ def __init__(self, path_results):
216214 data_json = json .load (fd )
217215 except Exception as err :
218216 tools .warning (
219- "Result directory %r: unable to read JSON configuration (%s)"
220- % (str (path_results ), err )
217+ f"Result directory { str (path_results )!r} : unable to read JSON configuration ({ err } )"
221218 )
222219 data_json = None
223220 # Load training data
@@ -229,8 +226,7 @@ def __init__(self, path_results):
229226 data_study .index .name = "Step number"
230227 except Exception as err :
231228 tools .warning (
232- "Result directory %r: unable to read training data (%s)"
233- % (str (path_results ), err )
229+ f"Result directory { str (path_results )!r} : unable to read training data ({ err } )"
234230 )
235231 data_study = None
236232 # Load evaluation data
@@ -240,8 +236,7 @@ def __init__(self, path_results):
240236 data_eval .index .name = "Step number"
241237 except Exception as err :
242238 tools .warning (
243- "Result directory %r: unable to read evaluation data (%s)"
244- % (str (path_results ), err )
239+ f"Result directory { str (path_results )!r} : unable to read evaluation data ({ err } )"
245240 )
246241 data_eval = None
247242 # Merge data frames
@@ -284,8 +279,7 @@ def display(self, *only_columns, name=None):
284279 display (
285280 self .get (* only_columns ),
286281 title = (
287- "Session data%s for %r"
288- % (" (subset)" if len (only_columns ) > 0 else "" , self .name )
282+ "Session data{} for {!r}" .format (" (subset)" if len (only_columns ) > 0 else "" , self .name )
289283 ),
290284 )
291285 # Return self to enable chaining
@@ -343,7 +337,7 @@ def compute_epoch(self):
343337 }.get (dataset_name )
344338 if training_size is None :
345339 tools .warning (
346- "Unknown dataset %r , cannot compute the epoch number" % dataset_name
340+ f "Unknown dataset { dataset_name !r } , cannot compute the epoch number"
347341 )
348342 return self
349343 self .data [column_name ] = self .data ["Training point count" ] / training_size
@@ -465,17 +459,15 @@ def include(self, data, *cols, errs=None, lalp=1.0, ccnt=None):
465459 data = data .data
466460 elif not isinstance (data , pandas .DataFrame ):
467461 raise RuntimeError (
468- "Expected a Session or DataFrame for 'data', got a %r"
469- % tools .fullqual (type (data ))
462+ f"Expected a Session or DataFrame for 'data', got a { tools .fullqual (type (data ))!r} "
470463 )
471464 # Get the x-axis values
472465 if self ._idx is None :
473466 x = data .index .to_numpy ()
474467 else :
475468 if self ._idx not in data :
476469 raise RuntimeError (
477- "No column named %r to use as index in the given session/dataframe"
478- % (self ._idx ,)
470+ f"No column named { self ._idx !r} to use as index in the given session/dataframe"
479471 )
480472 x = data [self ._idx ].to_numpy ()
481473 # Select semantic: empty list = select all
@@ -541,17 +533,15 @@ def include_single(self, data, key, col, err=None, lalp=1.0, ccnt=None):
541533 data = data .data
542534 elif not isinstance (data , pandas .DataFrame ):
543535 raise RuntimeError (
544- "Expected a Session or DataFrame for 'data', got a %r"
545- % tools .fullqual (type (data ))
536+ f"Expected a Session or DataFrame for 'data', got a { tools .fullqual (type (data ))!r} "
546537 )
547538 # Get the x-axis values
548539 if self ._idx is None :
549540 x = data .index .to_numpy ()
550541 else :
551542 if self ._idx not in data :
552543 raise RuntimeError (
553- "No column named %r to use as index in the given session/dataframe"
554- % (self ._idx ,)
544+ f"No column named { self ._idx !r} to use as index in the given session/dataframe"
555545 )
556546 x = data [self ._idx ].to_numpy ()
557547 # Pick a new line style and color
@@ -641,15 +631,13 @@ def generator_sum(gen):
641631 if zlabel is not None :
642632 if self ._tax is None :
643633 tools .warning (
644- "No secondary y-axis found, but its label %r was provided"
645- % (zlabel ,)
634+ f"No secondary y-axis found, but its label { zlabel !r} was provided"
646635 )
647636 else :
648637 self ._tax .set_ylabel (zlabel )
649638 elif self ._tax is not None :
650639 tools .warning (
651- "No label provided for the secondary y-axis; using label %r from the primary"
652- % (ylabel ,)
640+ f"No label provided for the secondary y-axis; using label { ylabel !r} from the primary"
653641 )
654642 self ._tax .set_ylabel (ylabel )
655643 self ._ax .set_xlim (left = xmin , right = xmax )
0 commit comments