Source
2830
2830
shutil.rmtree(self.infile + '_blparam.btable')
2831
2831
2832
2832
2833
2833
class sdbaseline_bloutputTest(sdbaseline_unittest_base):
2834
2834
"""
2835
2835
Basic unit tests for task sdbaseline. No interactive testing.
2836
2836
2837
2837
List of tests:
2838
2838
2839
2839
test000 --- no bloutput cases
2840
-
test001 --- no bloutput cases (blformat/bloutput with multiple elements)
2841
2840
2842
-
test010 --- single bloutput cases (bltable)
2843
-
test011 --- single bloutput cases (text)
2844
-
test012 --- single bloutput cases (csv)
2845
-
test013 --- single bloutput cases (blformat with an empty element)
2846
-
test014 --- single bloutput cases (blformat with empty elements)
2841
+
test010 --- single bloutput cases
2842
+
test011 --- single bloutput cases (blformat with extra empty elements)
2847
2843
2848
2844
test020 --- double bloutput cases
2849
-
test021 --- double bloutput cases (blformat with an empty element)
2845
+
test021 --- double bloutput cases (blformat with an extra empty element)
2850
2846
2851
2847
test030 --- triple bloutput cases
2852
-
test031 --- triple bloutput cases (in a different order)
2853
-
test032 --- triple bloutput cases (in a different order)
2854
2848
2855
-
test100 --- sinusoid test for addwn/rejwn
2856
-
test101 --- sinusoid test for addwn/rejwn
2849
+
test100 --- sinusoid test for finite wavenumber patterns
2850
+
test101 --- sinusoid test for infinite wavenumber pattern
2857
2851
"""
2858
2852
2859
2853
infile = 'OrionS_rawACSmod_calave.ms'
2854
+
outfile = 'test.ms'
2855
+
blparam = 'analytic_variable_blparam.txt'
2856
+
2857
+
blfuncs = ['poly', 'cspline', 'sinusoid', 'variable']
2858
+
blout_exts = {'text': '.txt', 'csv': '.csv', 'table': '.bltable'}
2859
+
blout_fmts_short = ['text', 'csv']
2860
+
wns = ['0', '02', '1']
2860
2861
2861
2862
blout_default_root = infile + '_blparam'
2862
-
blout_defaults = {'text': blout_default_root + '.txt',
2863
-
'csv': blout_default_root + '.csv',
2864
-
'table': blout_default_root + '.bltable'}
2863
+
blout_defaults = {}
2864
+
blout_nondefault_root = infile + '_bloutput_nondefault'
2865
+
blout_nondefaults = {}
2866
+
ref_blout_root = 'bloutput_'
2867
+
ref_blout = {}
2868
+
ref_blout_s_root = 'bloutput_sinusoid_addwn012_rejwn'
2869
+
ref_blout_s = {}
2865
2870
2866
-
blout_test_root = 'test'
2867
-
blout_tests = {'text': blout_test_root + '.txt',
2868
-
'csv': blout_test_root + '.csv',
2869
-
'table': blout_test_root + '.bltable'}
2871
+
for fmt in blout_exts.keys():
2872
+
blout_defaults[fmt] = blout_default_root + blout_exts[fmt]
2873
+
blout_nondefaults[fmt] = blout_nondefault_root + blout_exts[fmt]
2870
2874
2871
-
outroot = sdbaseline_unittest_base.taskname + '_bloutputtest'
2872
-
outfile = "test.ms"
2873
-
blparam = 'analytic_variable_blparam.txt'
2874
-
blfunc = 'poly'
2875
-
2876
-
ref_blout = {'text': {'poly': 'bloutput_poly.txt',
2877
-
'cspline': 'bloutput_cspline.txt',
2878
-
'sinusoid': 'bloutput_sinusoid.txt',
2879
-
'variable': 'bloutput_variable.txt'},
2880
-
'csv': {'poly': 'bloutput_poly.csv',
2881
-
'cspline': 'bloutput_cspline.csv',
2882
-
'sinusoid': 'bloutput_sinusoid.csv',
2883
-
'variable': 'bloutput_variable.csv'},
2884
-
'table': {'poly': 'bloutput_poly.bltable',
2885
-
'cspline': 'bloutput_cspline.bltable',
2886
-
'sinusoid': 'bloutput_sinusoid.bltable',
2887
-
'variable': 'bloutput_variable.bltable'}
2888
-
}
2875
+
ref_blout[fmt] = {}
2876
+
for fn in blfuncs:
2877
+
ref_blout[fmt][fn] = ref_blout_root + fn + blout_exts[fmt]
2889
2878
2890
-
blout_s_root = 'bloutput_sinusoid_addwn012_rejwn'
2891
-
blout_s = {'text': {'0': blout_s_root + '0' + '.txt',
2892
-
'02': blout_s_root + '02' + '.txt',
2893
-
'1': blout_s_root + '1' + '.txt'
2894
-
},
2895
-
'csv': {'0': blout_s_root + '0' + '.csv',
2896
-
'02': blout_s_root + '02' + '.csv',
2897
-
'1': blout_s_root + '1' + '.csv'
2898
-
}
2899
-
}
2879
+
ref_blout_s[fmt] = {}
2880
+
for wn in wns:
2881
+
ref_blout_s[fmt][wn] = ref_blout_s_root + wn + blout_exts[fmt]
2900
2882
2901
-
blout_s_addGt4000rej4005_txt = 'bloutput_sinusoid_addwnGt4000_rejwn4005.txt'
2883
+
ref_blout101 = 'bloutput_sinusoid_addwnGt4000_rejwn4005.txt'
2902
2884
2903
2885
base_param = dict(infile=infile,
2904
-
blfunc=blfunc,
2905
2886
datacolumn='float_data',
2906
2887
maskmode='list',
2907
2888
outfile=outfile,
2908
2889
blparam=blparam)
2909
2890
2910
2891
def setUp(self):
2911
-
remove_single_file_dir(self.infile)
2912
-
shutil.copytree(os.path.join(self.datapath, self.infile), self.infile)
2892
+
self._clear_working_directory()
2913
2893
2914
-
remove_single_file_dir(self.blparam)
2915
-
shutil.copyfile(os.path.join(self.datapath, self.blparam), self.blparam)
2894
+
self._copy_data(self.infile)
2895
+
self._copy_data(self.blparam)
2916
2896
2917
-
for fn in ['poly', 'cspline', 'sinusoid', 'variable']:
2918
-
shutil.copyfile(os.path.join(self.datapath, self.ref_blout['text'][fn]),
2919
-
self.ref_blout['text'][fn])
2920
-
shutil.copyfile(os.path.join(self.datapath, self.ref_blout['csv'][fn]),
2921
-
self.ref_blout['csv'][fn])
2922
-
rejwns = [[0], [0, 2], [1]]
2923
-
fmts = ['text', 'csv']
2924
-
lst = [(rejwn, fmt) for rejwn in rejwns for fmt in fmts]
2925
-
for rejwn, fmt in lst:
2926
-
the_file = self.blout_s[fmt][''.join([str(v) for v in rejwn])]
2927
-
shutil.copyfile(os.path.join(self.datapath, the_file), the_file)
2928
-
shutil.copyfile(os.path.join(self.datapath,
2929
-
self.blout_s_addGt4000rej4005_txt),
2930
-
self.blout_s_addGt4000rej4005_txt)
2897
+
for fmt in self.blout_fmts_short:
2898
+
for fn in self.blfuncs:
2899
+
self._copy_data(self.ref_blout[fmt][fn])
2900
+
for wn in self.wns:
2901
+
self._copy_data(self.ref_blout_s[fmt][wn])
2931
2902
2932
-
default(sdbaseline)
2903
+
self._copy_data(self.ref_blout101)
2933
2904
2934
-
for fmt in ['text', 'csv', 'table']:
2935
-
remove_single_file_dir(self.blout_defaults[fmt])
2936
-
remove_single_file_dir(self.blout_tests[fmt])
2905
+
default(sdbaseline)
2937
2906
2938
2907
def tearDown(self):
2908
+
self._clear_working_directory()
2909
+
2910
+
def _clear_working_directory(self):
2939
2911
remove_single_file_dir(self.infile)
2940
-
remove_single_file_dir(self.outroot)
2941
2912
remove_single_file_dir(self.outfile)
2942
2913
remove_single_file_dir(self.blparam)
2943
-
for fn in ['poly', 'cspline', 'sinusoid', 'variable']:
2944
-
remove_single_file_dir(self.ref_blout['text'][fn])
2945
-
remove_single_file_dir(self.ref_blout['csv'][fn])
2946
-
for bfmt, brej in [(f, r) for f in ['text', 'csv'] for r in ['0', '02', '1']]:
2947
-
remove_single_file_dir(self.blout_s[bfmt][brej])
2948
-
remove_single_file_dir(self.blout_s_addGt4000rej4005_txt)
2949
2914
2950
-
for fmt in ['text', 'csv', 'table']:
2951
-
remove_single_file_dir(self.blout_tests[fmt])
2915
+
for fmt in self.blout_fmts_short:
2916
+
for fn in self.blfuncs:
2917
+
remove_single_file_dir(self.ref_blout[fmt][fn])
2918
+
for wn in self.wns:
2919
+
remove_single_file_dir(self.ref_blout_s[fmt][wn])
2920
+
2921
+
remove_single_file_dir(self.ref_blout101)
2922
+
2923
+
for fmt in self.blout_exts.keys():
2924
+
remove_single_file_dir(self.blout_defaults[fmt])
2925
+
remove_single_file_dir(self.blout_nondefaults[fmt])
2952
2926
2953
2927
def exec_sdbaseline(self, **kwargs):
2954
2928
task_param = self.base_param.copy()
2955
2929
for key, value in kwargs.items():
2956
2930
task_param[key] = value
2957
2931
sdbaseline(**task_param)
2958
2932
2959
2933
def check_bloutput(self, bloutput):
2960
2934
for fname in bloutput:
2961
2935
if fname != '':
2962
2936
result_exist = os.path.exists(fname)
2963
2937
self.assertEqual(result_exist, True, msg=fname + 'does not exist!')
2964
2938
2965
2939
def check_bloutputparam_csv(self, bloutputfile, ref_all):
2966
2940
with open(bloutputfile, 'r') as file:
2967
2941
list_all = [row for row in csv.reader(file)]
2968
2942
self.assertEqual(ref_all, list_all,
2969
2943
msg='parameter values of the output csv file are \
2970
2944
not equivalent to referece values!')
2971
2945
2946
+
def _copy_data(self, filename):
2947
+
remote = os.path.join(self.datapath, filename)
2948
+
if os.path.isdir(remote):
2949
+
shutil.copytree(remote, filename)
2950
+
else:
2951
+
shutil.copyfile(remote, filename)
2952
+
2972
2953
def _set_actual_bloutput(self, blfmt, blout):
2973
2954
res = {}
2974
2955
if blfmt == '':
2975
2956
res['name'] = None
2976
2957
res['default'] = None
2977
2958
res['format'] = None
2978
2959
else:
2979
2960
res['name'] = self.blout_defaults[blfmt] if blout == '' else blout
2980
2961
res['default'] = (blout == '')
2981
2962
res['format'] = blfmt
2982
2963
2983
2964
return res
2984
2965
2985
-
def _run_test(self, blformat, bloutput):
2966
+
def _create_test_cases(self, blformat):
2967
+
# generate a full list of possible bloutput for given blformat.
2968
+
# for example, when blformat=['csv', 'text'], the returned value will be:
2969
+
# [ ['',''],['foo.csv',''],['','foo.txt'],['foo.csv','foo.txt'] ]
2970
+
# in case blformat has only one element (or a string) like ['csv'],
2971
+
# string values '' and 'foo.csv' are added to the returned value.
2972
+
2973
+
bloutputs = []
2974
+
2975
+
if isinstance(blformat, str):
2976
+
blformat = [blformat]
2977
+
2978
+
if not isinstance(blformat, list):
2979
+
raise Exception('blformat must be list or string!')
2980
+
2981
+
if len(blformat) == 0:
2982
+
raise Exception('blformat must have one element at least!')
2983
+
2984
+
for i in range(2 ** len(blformat)):
2985
+
bloutput = []
2986
+
idxs = [int(v) for v in str(bin(i))[2:].zfill(len(blformat))]
2987
+
for j in range(len(idxs)):
2988
+
elem = '' if idxs[j] == 0 else self.blout_nondefaults[blformat[j]]
2989
+
bloutput.append(elem)
2990
+
bloutputs.append(bloutput)
2991
+
2992
+
if len(blformat) == 1:
2993
+
bloutputs.append('')
2994
+
bloutputs.append(self.blout_nondefaults[blformat[0]])
2995
+
2996
+
return bloutputs
2997
+
2998
+
def _do_run_test(self, blformat, bloutput):
2986
2999
# print(f'testing blformat={blformat}, bloutput={bloutput}')
2987
3000
2988
-
for blfunc in ['poly', 'cspline', 'sinusoid', 'variable']:
3001
+
for blfunc in self.blfuncs:
2989
3002
result = self.exec_sdbaseline(blfunc=blfunc, blformat=blformat, bloutput=bloutput)
2990
3003
self.assertIsNone(result, msg=f'invalid return value ({result})')
2991
3004
2992
3005
actual_bloutput = []
2993
3006
if isinstance(blformat, str) and isinstance(bloutput, str):
2994
3007
actual_bloutput.append(self._set_actual_bloutput(blformat, bloutput))
2995
3008
elif isinstance(blformat, list) and isinstance(bloutput, list):
2996
3009
self.assertEqual(len(blformat), len(bloutput),
2997
3010
msg=f'{blformat} and {bloutput} have different length!')
2998
3011
for i in range(len(bloutput)):
3001
3014
for f in actual_bloutput:
3002
3015
the_blout = f['name']
3003
3016
blfmt = f['format']
3004
3017
if the_blout is None:
3005
3018
continue
3006
3019
self.assertTrue(os.path.exists(the_blout), msg=f'{the_blout} does not exist!')
3007
3020
if not f['default']:
3008
3021
fdef = self.blout_defaults[blfmt]
3009
3022
self.assertFalse(os.path.exists(fdef), msg=f'{fdef} exists!')
3010
3023
if blfmt != 'table':
3011
-
ref_blout = self.ref_blout[blfmt][blfunc]
3012
-
self.assertEqual(os.system('diff ' + the_blout + ' ' + ref_blout), 0,
3013
-
msg=f'{the_blout} is not equivalent to {ref_blout}')
3024
+
res = filecmp.cmp(the_blout, self.ref_blout[blfmt][blfunc])
3025
+
self.assertTrue(res, msg=f'{the_blout} is not identical with the reference!')
3014
3026
3015
3027
remove_single_file_dir(self.outfile)
3016
3028
remove_files_dirs(self.blout_default_root)
3017
-
remove_files_dirs(self.blout_test_root)
3029
+
remove_files_dirs(self.blout_nondefault_root)
3018
3030
3019
-
def test000(self):
3020
-
# no bloutput cases
3021
-
blformats = ['', ['']]
3022
-
bloutputs = ['', [''], 'test.csv', ['test.csv']]
3023
-
lst = [(blformat, bloutput) for blformat in blformats for bloutput in bloutputs]
3024
-
for blformat, bloutput in lst:
3025
-
self._run_test(blformat=blformat, bloutput=bloutput)
3031
+
def _get_blformat_inclusive(self, blformats):
3032
+
for i in range(len(blformats)):
3033
+
if isinstance(blformats[i], str):
3034
+
blformats[i] = [blformats[i]]
3026
3035
3027
-
def test001(self):
3028
-
# no bloutput cases (blformat/bloutput with multiple elements)
3029
-
bloutputs = [['', '', ''], ['test.csv', 'test.txt', 'test.bltable']]
3030
-
for bloutput in bloutputs:
3031
-
self._run_test(blformat=['', '', ''], bloutput=bloutput)
3036
+
res = [''] * len(blformats[0])
3037
+
for blformat in blformats:
3038
+
for i in range(len(blformat)):
3039
+
if blformat[i] != '':
3040
+
res[i] = blformat[i]
3032
3041
3033
-
def test010(self):
3034
-
# single bloutput (bltable) cases
3035
-
blformats = ['table', ['table']]
3036
-
bloutputs = ['', [''], 'test.bltable', ['test.bltable']]
3037
-
lst = [(blformat, bloutput) for blformat in blformats for bloutput in bloutputs]
3038
-
for blformat, bloutput in lst:
3039
-
self._run_test(blformat=blformat, bloutput=bloutput)
3042
+
if res == ['']:
3043
+
res = ['text']
3044
+
elif res == ['', '']:
3045
+
res = ['text', 'csv']
3046
+
elif res == ['', '', '']:
3047
+
res = ['text', 'csv', 'table']
3040
3048
3041
-
def test011(self):
3042
-
# single bloutput (text) cases
3043
-
blformats = ['text', ['text']]
3044
-
bloutputs = ['', [''], 'test.txt', ['test.txt']]
3045
-
lst = [(blformat, bloutput) for blformat in blformats for bloutput in bloutputs]
3046
-
for blformat, bloutput in lst:
3047
-
self._run_test(blformat=blformat, bloutput=bloutput)
3049
+
return res
3048
3050
3049
-
def test012(self):
3050
-
# single bloutput (csv) cases
3051
-
blformats = ['csv', ['csv']]
3052
-
bloutputs = ['', [''], 'test.csv', ['test.csv']]
3051
+
def _run_test(self, blformats):
3052
+
blfmt_incl = self._get_blformat_inclusive(blformats)
3053
+
bloutputs = self._create_test_cases(blfmt_incl)
3053
3054
lst = [(blformat, bloutput) for blformat in blformats for bloutput in bloutputs]
3054
3055
for blformat, bloutput in lst:
3055
-
self._run_test(blformat=blformat, bloutput=bloutput)
3056
+
self._do_run_test(blformat=blformat, bloutput=bloutput)
3056
3057
3057
-
def test013(self):
3058
-
# single bloutput cases (blformat with an empty element)
3059
-
blformats = [['', 'csv'], ['text', '']]
3060
-
bloutputs = [['', 'test.csv'], ['test.text', '']]
3061
-
lst = [(blformat, bloutput) for blformat in blformats for bloutput in bloutputs]
3062
-
for blformat, bloutput in lst:
3063
-
self._run_test(blformat=blformat, bloutput=bloutput)
3058
+
def test000(self):
3059
+
# no bloutput cases
3060
+
self._run_test(['', ['']])
3061
+
self._run_test([['', '']])
3062
+
self._run_test([['', '', '']])
3064
3063
3065
-
def test014(self):
3064
+
def test010(self):
3065
+
# single bloutput cases
3066
+
self._run_test(['text', ['text']])
3067
+
self._run_test(['csv', ['csv']])
3068
+
self._run_test(['table', ['table']])
3069
+
3070
+
def test011(self):
3066
3071
# single bloutput cases (blformat with empty elements)
3067
-
blformats = [['', '', 'csv'], ['', 'text', ''], ['csv', '', '']]
3068
-
bloutputs = [['', '', 'test.csv'], ['', 'test.text', ''], ['test.csv', '', '']]
3069
-
lst = [(blformat, bloutput) for blformat in blformats for bloutput in bloutputs]
3070
-
for blformat, bloutput in lst:
3071
-
self._run_test(blformat=blformat, bloutput=bloutput)
3072
+
self._run_test([['', 'csv'], ['text', '']])
3073
+
self._run_test([['', '', 'table'], ['', 'text', ''], ['csv', '', '']])
3072
3074
3073
3075
def test020(self):
3074
3076
# double bloutput cases
3075
-
blformat = ['table', 'text']
3076
-
bloutputs = [['', ''], ['test.bltable', ''], ['', 'test.txt'], ['test.bltable', 'test.txt']]
3077
-
for bloutput in bloutputs:
3078
-
self._run_test(blformat=blformat, bloutput=bloutput)
3079
-
3080
-
blformat = ['text', 'table']
3081
-
bloutputs = [['', ''], ['test.txt', ''], ['', 'test.bltable'], ['test.txt', 'test.bltable']]
3082
-
for bloutput in bloutputs:
3083
-
self._run_test(blformat=blformat, bloutput=bloutput)
3084
-
3085
-
blformat = ['table', 'csv']
3086
-
bloutputs = [['', ''], ['test.bltable', ''], ['', 'test.csv'], ['test.bltable', 'test.csv']]
3087
-
for bloutput in bloutputs:
3088
-
self._run_test(blformat=blformat, bloutput=bloutput)
3089
-
3090
-
blformat = ['csv', 'table']
3091
-
bloutputs = [['', ''], ['test.csv', ''], ['', 'test.bltable'], ['test.csv', 'test.bltable']]
3092
-
for bloutput in bloutputs:
3093
-
self._run_test(blformat=blformat, bloutput=bloutput)
3094
-
3095
-
blformat = ['text', 'csv']
3096
-
bloutputs = [['', ''], ['test.txt', ''], ['', 'test.csv'], ['test.txt', 'test.csv']]
3097
-
for bloutput in bloutputs:
3098
-
self._run_test(blformat=blformat, bloutput=bloutput)
3077
+
self._run_test([['table', 'text']])
3078
+
self._run_test([['text', 'table']])
3079
+
self._run_test([['table', 'csv']])
3080
+
self._run_test([['csv', 'table']])
3081
+
self._run_test([['text', 'csv']])
3082
+
self._run_test([['csv', 'text']])
3099
3083
3100
3084
def test021(self):
3101
3085
# double bloutput cases (blformat with an empty element)
3102
-
blformats = [['table', 'text', ''], ['table', '', 'csv'], ['', 'text', 'csv']]
3103
-
bloutputs = [['', '', ''], ['test.bltable', '', ''],
3104
-
['', 'test.txt', ''], ['', '', 'test.csv']]
3105
-
lst = [(blformat, bloutput) for blformat in blformats for bloutput in bloutputs]
3106
-
for blformat, bloutput in lst:
3107
-
self._run_test(blformat=blformat, bloutput=bloutput)
3086
+
self._run_test([['table', 'text', ''], ['table', '', 'csv'], ['', 'text', 'csv']])
3108
3087
3109
3088
def test030(self):
3110
3089
# triple bloutput cases
3111
-
blformat = ['table', 'text', 'csv']
3112
-
bloutputs = [['', '', ''],
3113
-
['test.bltable', '', ''], ['', 'test.txt', ''], ['', '', 'test.csv'],
3114
-
['test.bltable', 'test.txt', ''], ['test.bltable', '', 'test.csv'],
3115
-
['', 'test.txt', 'test.csv'], ['test.bltable', 'test.txt', 'test.csv']]
3116
-
for bloutput in bloutputs:
3117
-
self._run_test(blformat=blformat, bloutput=bloutput)
3118
-
3119
-
def test031(self):
3120
-
# triple bloutput cases (in a different order)
3121
-
blformat = ['text', 'table', 'csv']
3122
-
bloutputs = [['', '', ''],
3123
-
['test.txt', '', ''], ['', 'test.bltable', ''], ['', '', 'test.csv'],
3124
-
['test.txt', 'test.bltable', ''], ['test.txt', '', 'test.csv'],
3125
-
['', 'test.bltable', 'test.csv'], ['test.bltable', 'test.txt', 'test.csv']]
3126
-
for bloutput in bloutputs:
3127
-
self._run_test(blformat=blformat, bloutput=bloutput)
3128
-
3129
-
def test032(self):
3130
-
# triple bloutput cases (in a different order)
3131
-
blformat = ['csv', 'text', 'table']
3132
-
bloutputs = [['', '', ''],
3133
-
['test.csv', '', ''], ['', 'test.txt', ''], ['', '', 'test.bltable'],
3134
-
['test.csv', 'test.txt', ''], ['test.csv', '', 'test.bltable'],
3135
-
['', 'test.txt', 'test.bltable'], ['test.csv', 'test.txt', 'test.bltable']]
3136
-
for bloutput in bloutputs:
3137
-
self._run_test(blformat=blformat, bloutput=bloutput)
3090
+
self._run_test([['table', 'text', 'csv']])
3091
+
self._run_test([['text', 'table', 'csv']])
3092
+
self._run_test([['csv', 'text', 'table']])
3138
3093
3139
3094
def _run_sinusoid_test(self, rejwn):
3140
3095
# print(f'testing {rejwn}...')
3141
3096
3142
-
blformat = ['text', 'csv']
3097
+
blformat = self.blout_fmts_short # ['text', 'csv']
3143
3098
result = self.exec_sdbaseline(blfunc='sinusoid', addwn=[0, 1, 2], rejwn=rejwn,
3144
3099
blformat=blformat, bloutput=['', ''])
3145
3100
self.assertIsNone(result, msg=f'invalid return value ({result})')
3146
3101
3147
3102
for fmt in blformat:
3148
3103
the_blout = self.blout_defaults[fmt]
3149
-
ref_blout = self.blout_s[fmt][''.join([str(v) for v in rejwn])]
3150
-
diff_value = os.system(f'diff {the_blout} {ref_blout}')
3151
-
self.assertEqual(diff_value, 0, msg=f'{the_blout} is not equivalent to {ref_blout}')
3104
+
ref_blout = self.ref_blout_s[fmt][''.join([str(v) for v in rejwn])]
3105
+
res = filecmp.cmp(the_blout, ref_blout)
3106
+
self.assertTrue(res, msg=f'{the_blout} is not identical with the reference!')
3152
3107
3153
3108
remove_single_file_dir(self.outfile)
3154
3109
remove_files_dirs(self.blout_default_root)
3155
-
remove_files_dirs(self.blout_test_root)
3110
+
remove_files_dirs(self.blout_nondefault_root)
3156
3111
3157
3112
def test100(self):
3158
-
# sinusoid test for addwn/rejwn
3113
+
# confirm if bloutput is correctly output for various wavenumber sets
3159
3114
rejwns = [[0], [0, 2], [1]]
3160
3115
for rejwn in rejwns:
3161
3116
self._run_sinusoid_test(rejwn)
3162
3117
3163
3118
def test101(self):
3164
3119
"""Basic Test 0127: addwn>4000, rejwn4005 test"""
3165
3120
3166
3121
blfunc = 'sinusoid'
3167
3122
blformat = ['text', 'csv']
3168
3123
bloutput = ['', '']
3169
3124
addwn = '>4000'
3170
3125
rejwn = [4005]
3171
3126
spw = '0'
3172
3127
applyfft = False
3173
3128
3174
3129
result = self.exec_sdbaseline(blfunc=blfunc, addwn=addwn, rejwn=rejwn, applyfft=applyfft,
3175
3130
blformat=blformat, bloutput=bloutput, spw=spw)
3176
3131
self.assertIsNone(result, msg=f'invalid return value ({result})')
3177
3132
3178
-
cmd = 'diff ' + self.blout_defaults['text'] + ' ' + self.blout_s_addGt4000rej4005_txt
3179
-
diff_val = os.system(cmd)
3180
-
msg = self.blout_defaults['text'] + ' differs with ' + self.blout_s_addGt4000rej4005_txt
3181
-
self.assertEqual(diff_val, 0, msg=msg)
3133
+
the_blout = self.blout_defaults['text']
3134
+
res = filecmp.cmp(the_blout, self.ref_blout101)
3135
+
self.assertTrue(res, msg=f'{the_blout} is not identical with the reference!')
3182
3136
3183
3137
remove_single_file_dir(self.outfile)
3184
3138
remove_files_dirs(self.blout_default_root)
3185
-
remove_files_dirs(self.blout_test_root)
3139
+
remove_files_dirs(self.blout_nondefault_root)
3186
3140
3187
3141
3188
3142
class sdbaseline_autoTest(sdbaseline_unittest_base):
3189
3143
"""
3190
3144
A class that tests maskmode='auto'.
3191
3145
3192
3146
testAutoPolyNoMask : polynomial fitting using all channels but edge=(500, 500)
3193
3147
testAutoChebNoMask : Chebyshev polynomial fitting using all channels but edge=(500, 500)
3194
3148
testAutoCsplNoMask : cspline fitting using all channels but edge=(500, 500)
3195
3149
testAutoSinuNoMask : sinusoidal fitting using all channels but edge=(500, 500)