From f8e38b7dd8cb2ee493e78c771f1cdcb7faa5caab Mon Sep 17 00:00:00 2001 From: Gaspard Jankowiak Date: Fri, 1 Mar 2024 14:50:02 +0100 Subject: [PATCH] raw strings for regexes --- Minimization/Tools.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Minimization/Tools.py b/Minimization/Tools.py index ef67272..734f634 100755 --- a/Minimization/Tools.py +++ b/Minimization/Tools.py @@ -114,15 +114,15 @@ class Reading: options={} for i in range(len(self.OPT)): - if re.match( "^DATA_FILE:$", self.OPT[i][0] ): + if re.match( r"^DATA_FILE:$", self.OPT[i][0] ): options['datafile'] = str(self.OPT[i][1]) file_exists(options['datafile'], "Data File") - elif re.match( "^TITLE:$", self.OPT[i][0] ): + elif re.match( r"^TITLE:$", self.OPT[i][0] ): options['title'] = str(self.OPT[i][1]) print("Title:\t\t", options['title']) - elif re.match( "^SAVE_FOLDER:$", self.OPT[i][0] ): + elif re.match( r"^SAVE_FOLDER:$", self.OPT[i][0] ): options['folder'] = str(self.OPT[i][1]) if os.path.exists(options['folder'])==0: os.makedirs(options['folder']) @@ -131,34 +131,34 @@ class Reading: elif os.path.exists(options['folder'])==1: print("Saving Folder:\t", options['folder']) - elif re.match( "^q_MIN\(nm\^-1\):$", self.OPT[i][0] ): + elif re.match( r"^q_MIN\(nm\^-1\):$", self.OPT[i][0] ): options['qmin'] = check_float_positive(self.OPT[i][1], "qmin") print("q range:\t(%s .." %options['qmin'], ) - elif re.match( "^q_MAX\(nm\^-1\):$", self.OPT[i][0] ): + elif re.match( r"^q_MAX\(nm\^-1\):$", self.OPT[i][0] ): options['qmax'] = check_float_positive(self.OPT[i][1], "qmax") print("%s) nm^-1\n" %options['qmax'], ) - elif re.match( "^MODEL:$", self.OPT[i][0] ): + elif re.match( r"^MODEL:$", self.OPT[i][0] ): options['function'] = str(self.OPT[i][1]) print("Function:\t", options['function']) - elif re.match( "^TEMPERATURE\(none=0\):$", self.OPT[i][0] ): + elif re.match( r"^TEMPERATURE\(none=0\):$", self.OPT[i][0] ): options['temp'] = check_float_positive(self.OPT[i][1], "Temperarure") if options['temp'] != 0: print("Temperarure:\t", options['temp']) else: print("Temperarure:\tNo Simulated Annealing") - elif re.match( "^BINNING:$", self.OPT[i][0] ): + elif re.match( r"^BINNING:$", self.OPT[i][0] ): options['bing'] = check_int(self.OPT[i][1], "Binning") print("Binning:\t", options['bing']) - elif re.match( "^ERROR\(0\.\.1\):$", self.OPT[i][0] ): + elif re.match( r"^ERROR\(0\.\.1\):$", self.OPT[i][0] ): options['err_mul'] = check_float_positive(self.OPT[i][1], "Error Mult.") print("Error Mult.:\t", options['err_mul']) - elif re.match( "^PLOT\(0-1\):$", self.OPT[i][0] ): + elif re.match( r"^PLOT\(0-1\):$", self.OPT[i][0] ): options['plot'] = check_int(self.OPT[i][1], "Plot") check_binary(options['plot'], "Plot") print("Plot:\t\t", options['plot']) @@ -186,7 +186,7 @@ class Reading: L_LIM=[] H_LIM=[] for i in range(len(self.PARA)): - if not re.match( "^#" , self.PARA[i][0] ): + if not re.match( r"^#" , self.PARA[i][0] ): NAME.append(self.PARA[i][0]) PAR.append(float(self.PARA[i][1])) FIX.append(self.PARA[i][2]) @@ -241,7 +241,7 @@ class Reading: L_LIM=[] H_LIM=[] for i in range(len(self.PARA)): - if not re.match( "^#" , self.PARA[i][0] ): + if not re.match( r"^#" , self.PARA[i][0] ): NAME.append(self.PARA[i][0]) PAR.append(float(self.PARA[i][1])) FIX.append(self.PARA[i][2])