From 6e65b3e9b7220c7e4f86f70b90e07cd2e07f9614 Mon Sep 17 00:00:00 2001 From: ehinrichs <54997013+ehinrichs@users.noreply.github.com> Date: Fri, 24 May 2024 08:26:11 -0600 Subject: [PATCH 1/4] Update to fehmpytests Update to fehmpytests --- fehmpytests/fehmpytests.py | 44 +++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/fehmpytests/fehmpytests.py b/fehmpytests/fehmpytests.py index f66052cf..c3efaeeb 100755 --- a/fehmpytests/fehmpytests.py +++ b/fehmpytests/fehmpytests.py @@ -618,14 +618,25 @@ def test_case(self, name, parameters={}): filenames = glob.glob(os.path.join('input','control','*.files')) subcases = [] for filename in filenames: - subcase = re.sub(os.path.join('input','control',''), '', filename) - subcase = re.sub('.files', '', subcase) + print('\nfilename: ', filename) + + path = os.path.join('input', 'control', ' ') + if os.name == 'nt': # For Windows + subcase = re.sub(r'input[\\/]', '', filename) + subcase = re.sub(r'control[\\/]', '', subcase) + subcase = re.sub(r'\.files$', '', subcase) + else: # For Unix-based systems + subcase = re.sub(os.path.join('input','control',''), '', filename) + subcase = re.sub('.files', '', subcase) + #print('subcase: ', subcase) #File named 'fehmn.files' to be used for tests with single case. if subcase != 'fehmn': subcases.append(subcase) + #print('append subases') else: subcases = [''] + #print('broken subases') break try: @@ -639,25 +650,34 @@ def test_case(self, name, parameters={}): os.chdir( output_dir ) filetypes = ['*.avs','*.csv','*.his','*.out','*.trc','*.ptrk'] test_flag = False + for filetype in filetypes: parameters['filetype'] = filetype - #Check to make sure there are files of this type. - if len(glob.glob(os.path.join('..','compare','')+'*'+subcase+filetype)) > 0: - test_method = \ - self._test_template(filetype, subcase, parameters) + compare_pattern = (os.path.join('..', 'compare', '*' )+ subcase + filetype) + found_files = glob.glob(compare_pattern) + print('\nsubcase: ', subcase) + + print('Checking for files with pattern: ', compare_pattern) + print('Found files: ', found_files) + print('Number of found files: ', len(found_files)) + + if len(found_files) > 0: + test_method = self._test_template(filetype, subcase, parameters) test_method() + print('Test method executed for filetype: ', filetype) test_flag = True - os.chdir( '..' ) + else: + print('Test method NOT executed for filetype: ', filetype) + + os.chdir('..') if not test_flag: - #Write to fail log if switch is on. if self.log: - line = '\nFailed at subcase:'+subcase - line = line+' filetype:'+filetype + line = f'\nFailed at subcase: {subcase} filetype: {filetype}' self.fail_log.write(line) self.fail("Missing any valid comparison files, no test performed") - + finally: - #Allows other tests to be performed after exception. + # Allows other tests to be performed after exception. os.chdir(self.maindir) def _test_template(self, filetype, subcase, parameters={}): From 0929a3982fadf620e7939474496e633af83dd33b Mon Sep 17 00:00:00 2001 From: ehinrichs <54997013+ehinrichs@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:03:55 -0600 Subject: [PATCH 2/4] Updated Fehmpytests Updated Fehmpytests --- fehmpytests/fehmpytests.py | 28 ++++++++------ fehmpytests/fpost.py | 75 +++++++++++++++++++++++++++++--------- 2 files changed, 75 insertions(+), 28 deletions(-) diff --git a/fehmpytests/fehmpytests.py b/fehmpytests/fehmpytests.py index c3efaeeb..5eba7940 100755 --- a/fehmpytests/fehmpytests.py +++ b/fehmpytests/fehmpytests.py @@ -616,9 +616,10 @@ def test_case(self, name, parameters={}): #Search for fehmn control files and extract subcases. filenames = glob.glob(os.path.join('input','control','*.files')) + #print('filenames: ', filenames) subcases = [] for filename in filenames: - print('\nfilename: ', filename) + #print('\nfilename: ', filename) path = os.path.join('input', 'control', ' ') if os.name == 'nt': # For Windows @@ -636,7 +637,7 @@ def test_case(self, name, parameters={}): #print('append subases') else: subcases = [''] - #print('broken subases') + #print('broken subcases') break try: @@ -655,19 +656,19 @@ def test_case(self, name, parameters={}): parameters['filetype'] = filetype compare_pattern = (os.path.join('..', 'compare', '*' )+ subcase + filetype) found_files = glob.glob(compare_pattern) - print('\nsubcase: ', subcase) - print('Checking for files with pattern: ', compare_pattern) - print('Found files: ', found_files) - print('Number of found files: ', len(found_files)) + #print('Checking for files with pattern: ', compare_pattern) + #print('Found files: ', found_files) + #print('Number of found files: ', len(found_files)) if len(found_files) > 0: test_method = self._test_template(filetype, subcase, parameters) test_method() - print('Test method executed for filetype: ', filetype) + #print('Test method executed for filetype: ', filetype) test_flag = True else: - print('Test method NOT executed for filetype: ', filetype) + #print('Test method NOT executed for filetype: ', filetype) + pass os.chdir('..') if not test_flag: @@ -718,7 +719,7 @@ def contour_case(): f_dif = fpost.fdiff(f_new, f_old) msg = 'Incorrect %s at time %s.' - + #If no pre-specified times, grab them from f_dif. if len(values['times']) == 0: times = f_dif.times @@ -734,6 +735,7 @@ def contour_case(): #Check the variables at each time for any significant differences. test_flag = False for t in times: + #print(subcase) #Its possible some times do not have all variables in f_dif. for v in np.intersect1d(variables, list(f_dif[t].keys())): #Measure the difference into a single quantity. @@ -749,6 +751,7 @@ def contour_case(): float(len(f_dif[t][v])) }[test_measure] try: + # print('true? ', difference, '<', mxerr, '=', difference Date: Tue, 4 Jun 2024 11:56:28 -0600 Subject: [PATCH 3/4] Update fpost Update fpost --- fehmpytests/fpost.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fehmpytests/fpost.py b/fehmpytests/fpost.py index 74fdcc3c..a31ee29c 100755 --- a/fehmpytests/fpost.py +++ b/fehmpytests/fpost.py @@ -1045,7 +1045,7 @@ def read(self,filename): # read contents of file #print('valid comparison of: ', fname, ' and ', tmp) pass else: - #print('No valid comparison file. Skipping file: ', fname) + print('\n **WARNING** The file ', tmp , ' is in compare, but not in output. Skipping file...') continue elif '..' not in fname: #print('fname is in output: ', fname) @@ -1055,7 +1055,7 @@ def read(self,filename): # read contents of file #print('valid comparison of: ', fname, ' and ', path) pass else: - # print('No valid comparison file. Skipping file: ', fname) + #print('\n **WARNING** The file ', fname , 'is in output, but doesn''t have a valid compare file. Skipping file...') continue with open(fname, 'r') as self._file: From 123ccf9077f3dc7c0ba0bbad80724be4a4293666 Mon Sep 17 00:00:00 2001 From: ehinrichs <54997013+ehinrichs@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:38:49 -0600 Subject: [PATCH 4/4] Update to fpost Update to fpost --- fehmpytests/fpost.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fehmpytests/fpost.py b/fehmpytests/fpost.py index a31ee29c..f6dfde08 100755 --- a/fehmpytests/fpost.py +++ b/fehmpytests/fpost.py @@ -1039,7 +1039,7 @@ def read(self,filename): # read contents of file if os.name == 'nt': # For Windows tmp=fname.split('\\')[-1] else: - tmp = fname.rsplit('/', 1)[0] + tmp = fname.split('/')[-1] #print('tmp: ', tmp) if os.path.exists(tmp): #print('valid comparison of: ', fname, ' and ', tmp)