def test_xform_e_mx(self): cmd = 'xform -e -mx'.split() + [ts.datafile('xform_2.dat')] result = self._runit(cmd) expect = lcompare.split_radfile(ts.datafile('xform_res2.dat')) try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e),cmd))
def test_phisto(self): if os.name == 'nt': phisto = 'phisto' else: phisto = 'phisto' hgradpic = ts.datafile('gradients', 'h_gradient.hdr') vgradpic = ts.datafile('gradients', 'v_gradient.hdr') datafn = ts.datafile('gradients', 'gradient.histo') with open(datafn, 'r') as df: dtxt = df.read() expect = lcompare.split_rad(dtxt) for picfn in (hgradpic, vgradpic): hcmd = [phisto, picfn] err_msg = None try: result = self._runit(hcmd) lcompare.llcompare(result, expect) except AssertionError as e: with open(picfn, 'rb') as picf: hcmd = [phisto] result = self._runit(hcmd, _in=picf) try: lcompare.llcompare(result, expect) err_msg = 'Phisto fails with spaces in file name paths.' except Exception as e: err_msg = str(e) except Exception as e: err_msg = str(e) if err_msg: self.fail(err_msg)
def test_xform_e_mx(self): cmd = 'xform -e -mx'.split() + [ts.datafile('xform_2.dat')] result = self._runit(cmd) expect = lcompare.split_radfile(ts.datafile('xform_res2.dat')) try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e), cmd))
def test_lam(self): dat_de = ts.datafile('lam_de.dat') dat_en = ts.datafile('lam_en.dat') cmd = ['rlam', '-t:', dat_de, dat_en] result = self._runit(cmd) expect = [ ['eins:one'], ['zwei:two'], ['drei:three'], ['vier:four'], ['fuenf:five'], ] try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e),cmd))
def test_call_1_bin(self): exp = (2160, 8640, 4320, 1080, 7560) cntcmd = ['total', '-of'] tfn = ts.datafile('histo.dat') res = self._runit(cntcmd, 'run one process', _in=tfn, nl=False) resl = struct.unpack('f'*len(exp), res) try: lcompare.lcompare(resl, exp) except lcompare.error as e: self.fail(('call_one_text n=%d -- ' % n) +str(e))
def test_getinfo_d(self): picfile = ts.datafile('Earth128.pic') cmd = ['getinfo', '-d', picfile] result = self._runit(cmd) exps = '''%s: -Y 128 +X 128\n''' % picfile expect = lcompare.split_headers(exps) try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e),cmd))
def test_call_1_bin(self): exp = (2160, 8640, 4320, 1080, 7560) cntcmd = ['total', '-of'] tfn = ts.datafile('histo.dat') res = self._runit(cntcmd, 'run one process', _in=tfn, nl=False) resl = struct.unpack('f' * len(exp), res) try: lcompare.lcompare(resl, exp) except lcompare.error as e: self.fail(('call_one_text n=%d -- ' % n) + str(e))
def test_getinfo_d(self): picfile = ts.datafile('Earth128.pic') cmd = ['getinfo', '-d', picfile] result = self._runit(cmd) exps = '''%s: -Y 128 +X 128\n''' % picfile expect = lcompare.split_headers(exps) try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e), cmd))
def test_lc_split_radfile(self): df = ts.datafile('window_src.rad') exp = ([['#'], ['#', 'A', 'plain', 'old', 'glass', 'window'], ['#'], [], ['void', 'light', 'window_light'], [0], [0], [3, 1, 1, 1], [], ['window_light', 'polygon', 'window'], [0], [0], [12], [23.5, 43, 30], [23.5, 26, 30], [-23.5, 26, 30], [-23.5, 43, 30], []]) resl = lcompare.split_radfile(df) try: lcompare.lcompare(resl, exp) except lcompare.error as e: print(resl, exp) self.fail(('call_one_text n=%d -- ' % n) +str(e))
def test_rlux(self): octfn = ts.datafile('corner', 'corner.oct') data = '''0.5 0.5 1.5 0 0 -1 0.3 0.7 0.5 0 0 -1 0.7 0.3 0.5 0 0 -1 0.5 0.5 0.5 0 1 0 0.5 0.5 0.5 -1 0 0 -1 0.5 0.5 1 0 0 0.5 2 0.5 0 -1 0 ''' exp = [[37796.5481], [0], [37796.5481], [0], [0], [46062.1953], [0], []] cmd = ['rlux', octfn] resl = self._runit(cmd, data) lcompare.llcompare(resl, exp)
def test_ttyimage(self): # We just do a few spot checks here picfile = ts.datafile('Earth128.pic') cmd = ['ttyimage', picfile] result = self._runit(cmd) expect = [ [ 0, [ '################################################################' '################################################################' ] ], [ 7, [ '#########################@%,,.?++&%%###$&###############@&:.....' '.......,,.......,,.,,;..+?,...,.:*+.:&#########@################' ] ], [ 23, [ '.......;,:.....,++*+?++++;+;:,::,..,,;+;;+...................,;,' '..,:;+::+;;:;;:;;;;;:;+;;;;;;;;;:;+;;;;;%%$@%$&%#?.....,#%......' ] ], [ 54, [ '................................,,,.......................*%?$@#' '###########@$%%%;.........:?:.....,?+;:....;,...................' ] ], [ 99, [ '.....................................+++........................' '................................................................' ] ], ] for l in expect: self.assertEqual( result[l[0]], l[1], '%s : %s != %s [line %s]' % (cmd, result[l[0]], l[1], l[0]))
def test_histo(self): infile = ts.datafile('histo.dat') cmd = 'histo -0.5 8.5 9'.split() result = self._runit(cmd, infile) expect = [ [0, 720, 240, 432, 1080, 270], [1, 720, 240, 432, 1080, 270], [2, 720, 240, 432, 0, 270], [3, 0, 240, 432, 0, 270], [4, 0, 240, 432, 0, 270], [5, 0, 240, 0, 0, 270], [6, 0, 240, 0, 0, 270], [7, 0, 240, 0, 0, 270], [8, 0, 240, 0, 0, 0], ] try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e),cmd))
def test_histo_p(self): infile = ts.datafile('histo.dat') cmd = 'histo -p -0.5 8.5 9'.split() result = self._runit(cmd, infile) expect = [ [0, 33.333333, 11.111111, 20.0, 50.0, 12.5], [1, 33.333333, 11.111111, 20.0, 50.0, 12.5], [2, 33.333333, 11.111111, 20.0, 0.0, 12.5], [3, 0.0, 11.111111, 20.0, 0.0, 12.5], [4, 0.0, 11.111111, 20.0, 0.0, 12.5], [5, 0.0, 11.111111, 0.0, 0.0, 12.5], [6, 0.0, 11.111111, 0.0, 0.0, 12.5], [7, 0.0, 11.111111, 0.0, 0.0, 12.5], [8, 0.0, 11.111111, 0.0, 0.0, 0.0], ] try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e),cmd))
def test_histo_c(self): infile = ts.datafile('histo.dat') cmd = 'histo -c -0.5 8.5 9'.split() result = self._runit(cmd, infile) expect = [ [-0.5, 0, 0, 0, 0, 0], [0.5, 720, 240, 432, 1080, 270], [1.5, 1440, 480, 864, 2160, 540], [2.5, 2160, 720, 1296, 2160, 810], [3.5, 2160, 960, 1728, 2160, 1080], [4.5, 2160, 1200, 2160, 2160, 1350], [5.5, 2160, 1440, 2160, 2160, 1620], [6.5, 2160, 1680, 2160, 2160, 1890], [7.5, 2160, 1920, 2160, 2160, 2160], [8.5, 2160, 2160, 2160, 2160, 2160], ] try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e),cmd))
def test_histo_pc(self): infile = ts.datafile('histo.dat') cmd = 'histo -p -c -0.5 8.5 9'.split() result = self._runit(cmd, infile) expect = [ [-0.5, 0.0, 0.0, 0.0, 0.0, 0.0], [0.5, 33.333333, 11.111111, 20.0, 50.0, 12.5], [1.5, 66.666667, 22.222222, 40.0, 100.0, 25.0], [2.5, 100.0, 33.333333, 60.0, 100.0, 37.5], [3.5, 100.0, 44.444444, 80.0, 100.0, 50.0], [4.5, 100.0, 55.555556, 100.0, 100.0, 62.5], [5.5, 100.0, 66.666667, 100.0, 100.0, 75.0], [6.5, 100.0, 77.777778, 100.0, 100.0, 87.5], [7.5, 100.0, 88.888889, 100.0, 100.0, 100.0], [8.5, 100.0, 100.0, 100.0, 100.0, 100.0], ] try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e),cmd))
def test_getinfo(self): picfile = ts.datafile('Earth128.pic') cmd = ['getinfo', picfile] result = self._runit(cmd) exps = '''%s: Xim format conversion by: FORMAT=32-bit_rle_rgbe pfilt -e 2 -x 512 -y 512 -p 1 -r .67 EXPOSURE=4.926198e+00 normpat pfilt -1 -e .2 EXPOSURE=2.000000e-01 pfilt -x 128 -y 128 PIXASPECT=0.500000 EXPOSURE=2.571646e+00 ''' % picfile expect = lcompare.split_headers(exps) try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e),cmd))
def test_getinfo(self): picfile = ts.datafile('Earth128.pic') cmd = ['getinfo', picfile] result = self._runit(cmd) exps = '''%s: Xim format conversion by: FORMAT=32-bit_rle_rgbe pfilt -e 2 -x 512 -y 512 -p 1 -r .67 EXPOSURE=4.926198e+00 normpat pfilt -1 -e .2 EXPOSURE=2.000000e-01 pfilt -x 128 -y 128 PIXASPECT=0.500000 EXPOSURE=2.571646e+00 ''' % picfile expect = lcompare.split_headers(exps) try: lcompare.llcompare(result, expect, ignore_empty=1) except lcompare.error as e: self.fail('%s [%s]' % (str(e), cmd))
def test_fc_hgradient(self): # Best we can do without a hdr file parser: # * We have a picture with a horizontal gradient. # * Run falsecolor on it with all permutations of palettes, # regular/lines/bands/posterize, and -i/-ip. # * Convert to text (ttyimage) and extract one scanline. # * Compare with expected text lines as stored here. # We don't currently test the legend, users will notice errors there. hgradpic = ts.datafile('gradients', 'h_gradient.hdr') pals = ('def', 'eco', 'hot', 'pm3d', 'spec') typeargs = ( (['-i'], { 'def': ' .....,,,,:::::;;;;;;;;;;:::::::' '::::,,,,,,,,,,,,,,,.......................,,,,,,' ',:::::;;++??%%&&**$$@@@@@@@@@@@@\n', 'eco': ' ...............,,,' ',,,,,,,::::::::::::::::::::;;;;;;;;;;+++++++????' '?%%%%%&&&&****$$$$@@@###########\n', 'hot': ' .........,,,,,,::::::::::::' ':;;;;;;;+++++???%%%%&&&**$$@@###################' '################################\n', 'pm3d': ' ...............................' '..................,,,,,,,,,,,,,,,::::::::;;;;;;;' '++++????%%%%&&***$$@@###########\n', 'spec': '.....,,,,,,:::::;;;;;;++++++?????%%%%%%&&&&&&&&&' '&&&&&%%%%%%%%%%%%%%?????????????+++++++++++++++;' ';;;;;;;;;;;;;:::::::::::::::::::\n', }), (['-cl', '-ip'], { 'def': ' ...........,..,,,,,,,::::::;;::;;;;;;;;;' ';::++++++++??????,,??%%%%%%%%%%..&&&&&&&&&****,,' '****$$$$$$$$$%&@@@@@@@@@########\n', 'eco': ' ..........., ,,,,,,,::::::..::;;;;;;;;;' ';,,++++++++??????::??%%%%%%%%%%;;&&&&&&&&&****??' '****$$$$$$$$$*$@@@@@@@@@########\n', 'hot': ' ..........., .,,,,,,,::::::,:::;;;;;;;;;' ';;;++++++++??????%%??%%%%%%%%%%##&&&&&&&&&****##' '****$$$$$$$$$##@@@@@@@@@########\n', 'pm3d': ' ...........,..,,,,,,,::::::..::;;;;;;;;;' ';..++++++++??????.,??%%%%%%%%%%,,&&&&&&&&&****;;' '****$$$$$$$$$&*@@@@@@@@@########\n', 'spec': ' ,, ...........,;;,,,,,,,::::::%%::;;;;;;;;;' ';&&++++++++??????%%??%%%%%%%%%%?+&&&&&&&&&****+;' '****$$$$$$$$$::@@@@@@@@@########\n', }), (['-cl', '-i'], { 'def': ' .. ;; ' ' :: ,, .. ,,' ' %& \n', 'eco': ' .. ' ' ,, :: ;; ??' ' *$ \n', 'hot': ' . ,: ' ' ;; %% ## ##' ' ## \n', 'pm3d': ' .. .. ' ' .. ., ,, ;;' ' &* \n', 'spec': ' ,, ;; %% ' ' && %% ?+ +;' ' :: \n', }), (['-cb', '-ip'], { 'def': ' ..............,,,,,,,:::::;;;::;;;;;;;;;' ';:::+++++++?????,,,??%%%%%%%%%%...&&&&&&&&****,,' ',***$$$$$$$$%%&&@@@@@@@@########\n', 'eco': ' ........... ,,,,,,,:::::...::;;;;;;;;;' ';,,,+++++++?????:::??%%%%%%%%%%;;;&&&&&&&&****??' '?***$$$$$$$$**$$@@@@@@@@########\n', 'hot': ' ........... .,,,,,,,:::::,,:::;;;;;;;;;' ';;;;+++++++?????%%%??%%%%%%%%%%###&&&&&&&&****##' '#***$$$$$$$$####@@@@@@@@########\n', 'pm3d': ' ..............,,,,,,,:::::...::;;;;;;;;;' ';...+++++++?????..,??%%%%%%%%%%,,:&&&&&&&&****;;' '+***$$$$$$$$&&**@@@@@@@@########\n', 'spec': ' .,, ...........;;;,,,,,,,:::::%%%::;;;;;;;;;' ';&&&+++++++?????%%%??%%%%%%%%%%?++&&&&&&&&****+;' ';***$$$$$$$$;:::@@@@@@@@########\n', }), (['-cb', '-i'], { 'def': ' ... ;;; ' ' ::: ,,, ... ,,' ', %%&& \n', 'eco': ' ... ' ' ,,, ::: ;;; ??' '? **$$ \n', 'hot': ' . ,,: ' ' ;;; %%% ### ##' '# #### \n', 'pm3d': ' ... ... ' ' ... .., ,,: ;;' '+ &&** \n', 'spec': ' .,, ;;; %%% ' ' &&& %%% ?++ +;' '; ;::: \n', }), (['-cp', '-i'], { 'def': ' ...............;;;;;;;;;;;;;;;:::::' '::::::::::,,,,,,,,,,,,,,,...............,,,,,,,,' ',,,,,,%%%%%%%%%%%%%%%@@@@@@@@@@@\n', 'eco': ' ...............,,,,,' ',,,,,,,,,,:::::::::::::::;;;;;;;;;;;;;;;????????' '??????***************###########\n', 'hot': ' ,,,,,,,,,,,,,,,;;;;;' ';;;;;;;;;;%%%%%%%%%%%%%%%#######################' '################################\n', 'pm3d': ' ...................................' '.........................,,,,,,,,,,,,,,,;;;;;;;;' ';;;;;;&&&&&&&&&&&&&&&###########\n', 'spec': ',,,,,,,,,,,,,;;;;;;;;;;;;;;;%%%%%%%%%%%%%%%&&&&&' '&&&&&&&&&&%%%%%%%%%%%%%%%???????????????;;;;;;;;' ';;;;;;::::::::::::::::::::::::::\n', }), ) for ta, expd in typeargs: for pal in pals: exp = expd[pal] if pal == 'def': pa = [] else: pa = ['-pal', pal] hfccmd = ['falsecolor', '-lw', '0'] + pa + ta + [hgradpic] ttycmd = ['ttyimage'] result = self._runit((hfccmd, ttycmd), hgradpic) line = result[64] if not exp: print(ta) print('"%s"' % line) #print('"%s"' % exp) continue self.assertEqual( line, exp, )
def test_fc_hgradient(self): # Best we can do without a hdr file parser: # * We have a picture with a horizontal gradient. # * Run falsecolor on it with all permutations of palettes, # regular/lines/bands/posterize, and -i/-ip. # * Convert to text (ttyimage) and extract one scanline. # * Compare with expected text lines as stored here. # We don't currently test the legend, users will notice errors there. hgradpic = ts.datafile('gradients', 'h_gradient.hdr') pals = ('def', 'eco', 'hot', 'pm3d', 'spec') typeargs = ( (['-i'], { 'def': ' .....,,,,:::::;;;;;;;;;;:::::::' '::::,,,,,,,,,,,,,,,.......................,,,,,,' ',:::::;;++??%%&&**$$@@@@@@@@@@@@\n', 'eco': ' ...............,,,' ',,,,,,,::::::::::::::::::::;;;;;;;;;;+++++++????' '?%%%%%&&&&****$$$$@@@###########\n', 'hot': ' .........,,,,,,::::::::::::' ':;;;;;;;+++++???%%%%&&&**$$@@###################' '################################\n', 'pm3d': ' ...............................' '..................,,,,,,,,,,,,,,,::::::::;;;;;;;' '++++????%%%%&&***$$@@###########\n', 'spec': '.....,,,,,,:::::;;;;;;++++++?????%%%%%%&&&&&&&&&' '&&&&&%%%%%%%%%%%%%%?????????????+++++++++++++++;' ';;;;;;;;;;;;;:::::::::::::::::::\n', } ), (['-cl', '-ip'], { 'def': ' ...........,..,,,,,,,::::::;;::;;;;;;;;;' ';::++++++++??????,,??%%%%%%%%%%..&&&&&&&&&****,,' '****$$$$$$$$$%&@@@@@@@@@########\n', 'eco': ' ..........., ,,,,,,,::::::..::;;;;;;;;;' ';,,++++++++??????::??%%%%%%%%%%;;&&&&&&&&&****??' '****$$$$$$$$$*$@@@@@@@@@########\n', 'hot': ' ..........., .,,,,,,,::::::,:::;;;;;;;;;' ';;;++++++++??????%%??%%%%%%%%%%##&&&&&&&&&****##' '****$$$$$$$$$##@@@@@@@@@########\n', 'pm3d': ' ...........,..,,,,,,,::::::..::;;;;;;;;;' ';..++++++++??????.,??%%%%%%%%%%,,&&&&&&&&&****;;' '****$$$$$$$$$&*@@@@@@@@@########\n', 'spec': ' ,, ...........,;;,,,,,,,::::::%%::;;;;;;;;;' ';&&++++++++??????%%??%%%%%%%%%%?+&&&&&&&&&****+;' '****$$$$$$$$$::@@@@@@@@@########\n', } ), (['-cl', '-i'], { 'def': ' .. ;; ' ' :: ,, .. ,,' ' %& \n', 'eco': ' .. ' ' ,, :: ;; ??' ' *$ \n', 'hot': ' . ,: ' ' ;; %% ## ##' ' ## \n', 'pm3d': ' .. .. ' ' .. ., ,, ;;' ' &* \n', 'spec': ' ,, ;; %% ' ' && %% ?+ +;' ' :: \n', } ), (['-cb', '-ip'], { 'def': ' ..............,,,,,,,:::::;;;::;;;;;;;;;' ';:::+++++++?????,,,??%%%%%%%%%%...&&&&&&&&****,,' ',***$$$$$$$$%%&&@@@@@@@@########\n', 'eco': ' ........... ,,,,,,,:::::...::;;;;;;;;;' ';,,,+++++++?????:::??%%%%%%%%%%;;;&&&&&&&&****??' '?***$$$$$$$$**$$@@@@@@@@########\n', 'hot': ' ........... .,,,,,,,:::::,,:::;;;;;;;;;' ';;;;+++++++?????%%%??%%%%%%%%%%###&&&&&&&&****##' '#***$$$$$$$$####@@@@@@@@########\n', 'pm3d': ' ..............,,,,,,,:::::...::;;;;;;;;;' ';...+++++++?????..,??%%%%%%%%%%,,:&&&&&&&&****;;' '+***$$$$$$$$&&**@@@@@@@@########\n', 'spec': ' .,, ...........;;;,,,,,,,:::::%%%::;;;;;;;;;' ';&&&+++++++?????%%%??%%%%%%%%%%?++&&&&&&&&****+;' ';***$$$$$$$$;:::@@@@@@@@########\n', } ), (['-cb', '-i'], { 'def': ' ... ;;; ' ' ::: ,,, ... ,,' ', %%&& \n', 'eco': ' ... ' ' ,,, ::: ;;; ??' '? **$$ \n', 'hot': ' . ,,: ' ' ;;; %%% ### ##' '# #### \n', 'pm3d': ' ... ... ' ' ... .., ,,: ;;' '+ &&** \n', 'spec': ' .,, ;;; %%% ' ' &&& %%% ?++ +;' '; ;::: \n', } ), (['-cp', '-i'], { 'def': ' ...............;;;;;;;;;;;;;;;:::::' '::::::::::,,,,,,,,,,,,,,,...............,,,,,,,,' ',,,,,,%%%%%%%%%%%%%%%@@@@@@@@@@@\n', 'eco': ' ...............,,,,,' ',,,,,,,,,,:::::::::::::::;;;;;;;;;;;;;;;????????' '??????***************###########\n', 'hot': ' ,,,,,,,,,,,,,,,;;;;;' ';;;;;;;;;;%%%%%%%%%%%%%%%#######################' '################################\n', 'pm3d': ' ...................................' '.........................,,,,,,,,,,,,,,,;;;;;;;;' ';;;;;;&&&&&&&&&&&&&&&###########\n', 'spec': ',,,,,,,,,,,,,;;;;;;;;;;;;;;;%%%%%%%%%%%%%%%&&&&&' '&&&&&&&&&&%%%%%%%%%%%%%%%???????????????;;;;;;;;' ';;;;;;::::::::::::::::::::::::::\n', } ), ) for ta, expd in typeargs: for pal in pals: exp = expd[pal] if pal == 'def': pa = [] else: pa = ['-pal', pal] hfccmd = ['falsecolor', '-lw', '0'] + pa + ta + [hgradpic] ttycmd = ['ttyimage'] result = self._runit((hfccmd, ttycmd), hgradpic) line = result[64] if not exp: print(ta) print('"%s"' % line) #print('"%s"' % exp) continue self.assertEqual(line, exp,)