Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Invalid Escape Sequences #1741

Merged
merged 4 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions framework/CodeInterfaces/AccelerateCFD/AccelerateCFD.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def initialize(self, runInfo, oriInputFiles):
self.romName = xmlFind('./rom/romName')
self.romType = xmlFind('./rom/romType')
# read data from FOM
datai = pd.read_csv(self.fomDataFolder,skiprows=3,header=None,sep='\s+').iloc[:,[0,1,2]].replace('[()]','',regex=True).astype(float)
datai = pd.read_csv(self.fomDataFolder,skiprows=3,header=None,sep=r'\s+').iloc[:,[0,1,2]].replace('[()]','',regex=True).astype(float)
datai = datai.rename(columns={0:'t',1:'ux',2:'uy'})
dataList = [datai]
self.dataFom = pd.concat(dataList,keys=['fom'])
Expand Down Expand Up @@ -322,7 +322,7 @@ def finalizeCodeOutput(self, command, output, workingDir):
# process post-processing file for rom
ppRomFile = os.path.join(workingDir,"rom",self.romType +"_"+ self.romName,"postProcessing","probe","0","Urom")
if os.path.exists(ppRomFile):
datai = pd.read_csv(ppRomFile,skiprows=3,header=None,sep='\s+').iloc[:,[0,1,2]].replace('[()]','',regex=True).astype(float)
datai = pd.read_csv(ppRomFile,skiprows=3,header=None,sep=r'\s+').iloc[:,[0,1,2]].replace('[()]','',regex=True).astype(float)
datai = datai.rename(columns={0:'t',1:'ux',2:'uy'})
dataList = [datai]
romData = pd.concat(dataList,keys=['rom'])
Expand Down
4 changes: 2 additions & 2 deletions framework/CodeInterfaces/Dymola/DymolaInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ def createNewInput(self, currentInputFiles, oriInputFiles, samplerType, **Kwargs
patterns = [# Dymola 1- or 2-line parameter specification
(r'(^\s*%s\s+)%s(\s+%s\s+%s\s+%s\s+%s\s*#\s*%s\s*$)'
% (i, f, f, f, u, u, '%s')),
(r'(^\s*)' + i + '(\s*#\s*%s)'),
(r'(^\s*)' + f + '(\s*#\s*%s)'),
(r'(^\s*)' + i + r'(\s*#\s*%s)'),
(r'(^\s*)' + f + r'(\s*#\s*%s)'),
# From Dymola:
# column 1: Type of initial value
# = -2: special case: for continuing simulation
Expand Down
8 changes: 4 additions & 4 deletions framework/CodeInterfaces/MELCOR/MELCORdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def returnControlFunctions(self, timeBlock):
@ Out, functionValuesForEachTime, dict, {"time":{"functionName":"functionValue"}}
"""
functionValuesForEachTime = {'time': []}
timeOneRegex_name = re.compile("^\s*CONTROL\s+FUNCTION\s+(?P<name>[^\(]*)\s+(\(.*\))?\s*IS\s+.+\s+TYPE.*$")
timeOneRegex_value = re.compile("^\s*VALUE\s+=\s+(?P<value>[^\s]*)")
startRegex = re.compile("\s*CONTROL\s*FUNCTION\s*NUMBER\s*CURRENT\s*VALUE")
regex = re.compile("^\s*(?P<name>( ?([0-9a-zA-Z-]+))*)\s+([0-9]+)\s*(?P<value>((([0-9.-]+)E(\+|-)[0-9][0-9])|((T|F))))\s*.*$")
timeOneRegex_name = re.compile(r"^\s*CONTROL\s+FUNCTION\s+(?P<name>[^\(]*)\s+(\(.*\))?\s*IS\s+.+\s+TYPE.*$")
timeOneRegex_value = re.compile(r"^\s*VALUE\s+=\s+(?P<value>[^\s]*)")
startRegex = re.compile(r"\s*CONTROL\s*FUNCTION\s*NUMBER\s*CURRENT\s*VALUE")
regex = re.compile(r"^\s*(?P<name>( ?([0-9a-zA-Z-]+))*)\s+([0-9]+)\s*(?P<value>((([0-9.-]+)E(\+|-)[0-9][0-9])|((T|F))))\s*.*$")
for time,listOfLines in timeBlock.items():
functionValuesForEachTime['time'].append(float(time))
start = -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self,inputFile):
# Append string of non-varying parts of input file to file storage and reset the collection string
if len(between_str) > 0:
self.fileOrderStorage.append(between_str); between_str = ''
dictname, varname, varvalue = re.split("\['|'] = |'] =|']= ", line)
dictname, varname, varvalue = re.split(r"\['|'] = |'] =|']= ", line)
if dictname in self.AllVarDict.keys():
self.AllVarDict[dictname][varname] = varvalue.strip()
else:
Expand Down Expand Up @@ -119,7 +119,7 @@ def __init__(self,inputFile):
# Append string of non-varying parts of input file to file storage and reset the collection string
if len(between_str) > 0:
self.fileOrderStorage.append(between_str); between_str = ''
dictname, varname, varvalue = re.split("\['|'] = |'] =|']= ", line)
dictname, varname, varvalue = re.split(r"\['|'] = |'] =|']= ", line)
if dictname in self.AllVarDict.keys():
self.AllVarDict[dictname][varname] = varvalue.strip()
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
r"""
Created on May 22, 2015

@author: bobk
Expand Down
2 changes: 1 addition & 1 deletion framework/CodeInterfaces/PHISICS/PhisicsInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def generateCommand(self, inputFiles, executable, clargs=None, fargs=None, preEx
)]].getFilename() + ' -dep ' + inputFiles[mapDict['Depletion_input'.lower(
)]].getFilename() + ' -o ' + self.instantOutput
commandToRun = commandToRun.replace("\n", " ")
commandToRun = re.sub("\s\s+", " ", commandToRun)
commandToRun = re.sub(r"\s\s+", " ", commandToRun)
outputfile = 'out~' + inputFiles[mapDict['inp'.lower()]].getBase()
returnCommand = [('parallel', commandToRun)], outputfile
return returnCommand
Expand Down
2 changes: 1 addition & 1 deletion framework/CodeInterfaces/PHISICS/PhisicsRelapInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def generateCommand(self, inputFiles, executable, clargs=None, fargs=None, preEx
self.outputExt = '.o'
commandToRun = executable + ' -i ' +inputFiles[mapDict['relapInp'.lower()]].getFilename() + ' -o ' + self.outFileName + self.outputExt
commandToRun = commandToRun.replace("\n"," ")
commandToRun = re.sub("\s\s+", " ",commandToRun)
commandToRun = re.sub(r"\s\s+", " ",commandToRun)
returnCommand = [('parallel',commandToRun)], outputfile
return returnCommand

Expand Down
2 changes: 1 addition & 1 deletion framework/CodeInterfaces/RELAP5/RELAPparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def retrieveCardValues(self, listOfCards):
for lineNum, line in enumerate(self.deckLines[deck]):
if all(foundAllCards[deck].values()):
break
if not re.match('^\s*\n',line):
if not re.match(r'^\s*\n',line):
readCard = line.split()[0].strip()
if readCard in deckCards[deck].keys():
foundWord = False
Expand Down
2 changes: 1 addition & 1 deletion framework/CodeInterfaces/RELAP5/Relap5Interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def generateCommand(self,inputFiles,executable,clargs=None,fargs=None, preExec=N
addflags = ''
commandToRun = executable + ' -i ' + inputFiles[index].getFilename() + ' -o ' + outputfile + '.o ' + addflags
commandToRun = commandToRun.replace("\n"," ")
commandToRun = re.sub("\s\s+" , " ", commandToRun )
commandToRun = re.sub(r"\s\s+" , " ", commandToRun )
returnCommand = [('parallel',commandToRun)], outputfile
return returnCommand

Expand Down
2 changes: 1 addition & 1 deletion framework/CodeInterfaces/SCALE/tritonAndOrigenData.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def retrieveConcentrationTables(self):
if uom not in totals:
totals[uom] = []
indexConcTable+=4
timeUom = re.split('(\d+)', self.lines[indexConcTable].split()[0])[-1].strip()
timeUom = re.split(r'(\d+)', self.lines[indexConcTable].split()[0])[-1].strip()
timeGrid = [float(elm.replace(timeUom.strip(),"")) for elm in self.lines[indexConcTable].split()]

if outputDict is None:
Expand Down
2 changes: 1 addition & 1 deletion framework/InputTemplates/TemplateBaseClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _updateCommaSeperatedList(self, node, new, position=None, before=None, after
# OTHER UTILITIES #
################################
def _getRavenLocation(self, which='framework'):
"""
r"""
Returns the (string) path to RAVEN
NOTE this is problematic in mingw windows, since using abspath includes e.g. C:\msys64\home\etc.
@ In, framework, bool, optional, if True then give location of "raven/framework" else "raven/"
Expand Down
6 changes: 3 additions & 3 deletions framework/Optimizers/GeneticAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ def _ahdp(self,a,b,p):
return max(self._GDp(a,b,p),self._GDp(b,a,p))

def _GDp(self,a,b,p):
"""
r"""
Modified Generational Distance Indicator
@ In, a, np.array, old population A
@ In, b, np.array, new population B
Expand All @@ -739,7 +739,7 @@ def _GDp(self,a,b,p):
return (1/n * s)**(1/p)

def _popDist(self,ai,b,q=2):
"""
r"""
Minimum Minkowski distance from a_i to B (nearest point in B)
@ In, ai, 1d array, the ith chromosome in the generation A
@ In, b, np.array, population B
Expand All @@ -761,7 +761,7 @@ def _ahd(self,a,b):
return max(self._GD(a,b),self._GD(b,a))

def _GD(self,a,b):
"""
r"""
Generational Distance Indicator
@ In, a, np.array, old population A
@ In, b, np.array, new population B
Expand Down
2 changes: 1 addition & 1 deletion framework/Optimizers/SimulatedAnnealing.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def _coolingSchedule(self, iter, T0):
self.raiseAnError(NotImplementedError,'cooling schedule type not implemented.')

def _nextNeighbour(self, rlz,fraction=1):
"""
r"""
Perturbs the state to find the next random neighbour based on the cooling schedule
@ In, rlz, dict, current realization
@ In, fraction, float, optional, the current iteration divided by the iteration limit i.e., $\frac{iter}{Limit}$
Expand Down
4 changes: 2 additions & 2 deletions framework/Optimizers/fitness/fitness.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# @profile
def invLinear(rlz,**kwargs):
"""
r"""
Inverse linear fitness method requires that the fitness value is inversely proportional to the objective function
This method is designed such that:
For minimization Problems:
Expand Down Expand Up @@ -76,7 +76,7 @@ def invLinear(rlz,**kwargs):
return fitness

def feasibleFirst(rlz,**kwargs):
"""
r"""
Efficient Parameter-less Feasible First Penalty Fitness method
This method is designed such that:
For minimization Problems:
Expand Down
2 changes: 1 addition & 1 deletion framework/SupervisedLearning/ARMA.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class cls.
specs.addSub(InputData.parameterInputFactory("nyquistScalar", contentType=InputTypes.IntegerType, default=1))
### ARMA zero filter
zeroFilt = InputData.parameterInputFactory('ZeroFilter', contentType=InputTypes.StringType,
descr="""turns on \emph{zero filtering}
descr=r"""turns on \emph{zero filtering}
for the listed targets. Zero filtering is a very specific algorithm, and should not be used without
understanding its application. When zero filtering is enabled, the ARMA will remove all the values from
the training data equal to zero for the target, then train on the remaining data (including Fourier detrending
Expand Down
2 changes: 1 addition & 1 deletion framework/contrib/pyDOE/doe_factorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def fracfact(gen):
"""
# Recognize letters and combinations
#### fixed for python 3.7 by alfoa
A = [item for item in re.split('\-|\s|\+', gen) if item] # remove empty strings
A = [item for item in re.split(r'\-|\s|\+', gen) if item] # remove empty strings

C = [len(item) for item in A]

Expand Down
5 changes: 2 additions & 3 deletions scripts/TestHarness/testers/RavenFramework.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os
import subprocess
import sys
import distutils.version
import platform
from Tester import Tester
import OrderedCSVDiffer
Expand Down Expand Up @@ -209,8 +208,8 @@ def check_runnable(self):
if not found:
self.set_skip('skipped (Unable to import library: "'+libraryName+'")')
return False
if distutils.version.LooseVersion(actualVersion) < \
distutils.version.LooseVersion(libraryVersion):
if library_handler.parseVersion(actualVersion) < \
library_handler.parseVersion(libraryVersion):
self.set_skip('skipped (Outdated library: "'+libraryName+'")')
return False
i += 2
Expand Down
5 changes: 2 additions & 3 deletions scripts/TestHarness/testers/RavenPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import os
import sys
import subprocess
import distutils.version
from Tester import Tester

scriptsDir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
Expand Down Expand Up @@ -130,8 +129,8 @@ def check_runnable(self):
if not found:
self.set_skip('skipped (Unable to import library: "'+libraryName+'")')
return False
if distutils.version.LooseVersion(actualVersion) < \
distutils.version.LooseVersion(libraryVersion):
if library_handler.parseVersion(actualVersion) < \
library_handler.parseVersion(libraryVersion):
self.set_skip('skipped (Outdated library: "'+libraryName+'")')
return False
i += 2
Expand Down
17 changes: 17 additions & 0 deletions scripts/library_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""
import os
import sys
import re
import platform
import argparse
import subprocess
Expand Down Expand Up @@ -112,6 +113,22 @@ def checkLibraries(buildReport=False):
return messages
return missing, notQA

def parseVersion(versionString):
"""
Parses a version string into its components
@ In, versionStirng, str, the version string to parse
@ Out, version, list, list of components as integers and strings
"""
version = []
for part in re.split(r'([0-9]+|[a-z]+|\.)',versionString):
if len(part) == 0 or part == ".":
continue
try:
version.append(int(part))
except ValueError:
version.append(part)
return version

def checkSameVersion(expected, received):
"""
Compares "expected" to "received" for a version match.
Expand Down