Пример #1
0
	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))
Пример #2
0
 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)
Пример #3
0
	def test_genbeads(self):
		cmdl = 'genbeads mymat myname 0 0 0 1 1 1 2 0 0 0 2 0 .1 .4'.split()
		try:
			proc = self.call_one(cmdl, 'call genbeads', out=PIPE,
				universal_newlines=True)
			raw = proc.stdout.read()
		except Error as e:
			self.fail('%s [%s]' % (str(e), self.qjoin(cmdl)))
		finally:
			proc.wait()
		result = lcompare.split_rad(raw)
		expect = [['mymat', 'sphere', 'myname.0'], [0], [0],
		[4, 0, 0, 0, 0.1],
		['mymat', 'sphere', 'myname.1'], [0], [0],
		[4, 0.36, 0.04, 0.104, 0.1],
		['mymat', 'sphere', 'myname.2'], [0], [0],
		[4, 0.651440715413, 0.167781092737, 0.365893348046, 0.1],
		['mymat', 'sphere', 'myname.3'], [0], [0],
		[4, 0.844350245496, 0.366600314978, 0.655866088042, 0.1],
		['mymat', 'sphere', 'myname.4'], [0], [0],
		[4, 0.960791445178, 0.643185551339, 0.897901825177, 0.1],
		]
		try: lcompare.llcompare(result, expect, ignore_empty=True)
		except lcompare.error as e:
			self.fail('%s [%s]' % (str(e), self.qjoin(cmdl)))
Пример #4
0
	def test_lc_split_headers(self):
		htxt = '''example.hdr:
		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'''
		res = lcompare.split_headers(htxt)
		exp = (
				('', ('example.hdr:',)),
				('\t\t', ('Xim','format','conversion','by:')),
				('\t\t', 'FORMAT', '=', ('32-bit_rle_rgbe',)),
				('\t\t',
				('pfilt','-e','2','-x','512','-y','512','-p','1','-r','.67')),
				('\t\t', 'EXPOSURE', '=', ('4.926198e+00',)),
				('\t\t', ('normpat',)),
				('\t\t', ('pfilt','-1','-e','.2',)),
				('\t\t', 'EXPOSURE', '=', ('2.000000e-01',)),
				('\t\t', ('pfilt','-x','128','-y','128',)),
				('\t\t', 'PIXASPECT', '=', ('0.500000',)),
				('\t\t', 'EXPOSURE', '=', ('2.571646e+00',)),
			  )
		try: lcompare.llcompare(res, exp)
		except lcompare.error as e:
				self.fail(('call_one_text ') +str(e))
Пример #5
0
 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_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))
Пример #7
0
	def test_cnt_2d(self):
		# values higher than 1000/1000 will take rather long
		for n,m in ((3,3), (10,5), (100,200), ):#(1000,200)):
			cmd = ['cnt', str(n), str(m)]
			exp = itertools.product(range(n), range(m))
			raw = self._runit(cmd, 'test cnt 2dim')
			res = [[float(ss) for ss in s.split('\t')] for s in raw]
			try: lcompare.llcompare(res, exp)
			except lcompare.error as e:
				self.fail(('test_cnt_2 %d/%d - ' % (n,m)) + str(e))
Пример #8
0
	def test_cnt_3d(self):
		# values higher than 100/100/100 will take rather long
		for n,m,o in ((3,3,3), (10,5,7), (44, 33,22),):# (200,50,10)):
			cmd = ['cnt', str(n), str(m), str(o)]
			exp = itertools.product(range(n), range(m), range(o))
			res = self._runit(cmd, 'test cnt 3dim')
			res = [[float(ss) for ss in s.split('\t')] for s in res]
			try: lcompare.llcompare(res, exp)
			except lcompare.error as e:
				self.fail(('test_cnt_3 %d/%d/%d - ' % (n,m,o)) + str(e))
Пример #9
0
 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))
Пример #10
0
	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))
Пример #11
0
    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)
Пример #12
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))
Пример #13
0
	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))
Пример #14
0
	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))
Пример #15
0
	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))
Пример #16
0
	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))
Пример #17
0
    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))
Пример #18
0
	def test_lc_llcompare(self):
		# with values higher than 44721, total will return a float in e-format.
		for xc, data, exp in (
				(  None,
				   ( ('abcde', 'fgh', '1234', '56.789'),
					 ('xyz', '432', '987.65432')
				   ),
				   ( ('abcde', 'fgh', 1234, 56.789),
					 ('xyz', 432, 987.65432)
				   ),
				),
				(  None,
				   ( (('a', 'b', 'c'),('d', 'e', 'f')),
					 (('0', '1', '2', '3'),('1.1', '2.2', '3.000e-03')),
				   ),
				   ( (('a', 'b', 'c'),('d', 'e', 'f')),
					 (range(4),(1.1, 2.2, 0.003)),
				   ),
				),
				(  lcompare.error, # top level length
				   (('a', 'b', 'c'),('c','d'),('e','f'),),
				   (('a', 'b', 'c'),('c','d'),),
				),
				(  lcompare.error, # top level length
				   (('a', 'b', 'c'),('c','d'),),
				   (('a', 'b', 'c'),('c','d'),('e','f'),),
				),
				(  lcompare.error, # 2nd level length
				   (('a', 'b', 'c'),('c','d'),('e','f','g'),),
				   (('a', 'b', 'c'),('c','d'),('e','f'),),
				),
				(  lcompare.error, # 2nd level length
				   (('a', 'b', 'c'),('c','d'),('e','f'),),
				   (('a', 'b', 'c'),('c','d'),('e','f','g'),),
				),
				(  lcompare.error, # string diff
				   (('a', 'b', 'c'),('c','d'),('e','f','g'),),
				   (('a', 'b', 'c'),('c','d'),('e','f','h'),),
				),
				(  lcompare.error, # int diff
				   (('a', 'b', 'c'),('c','d'),('1','2','3'),),
				   (('a', 'b', 'c'),('c','d'),( 1,  2,  4),),
				),
				(  lcompare.error, # float diff
				   (('a', 'b', 'c'),('c','d'),('1.1','2.2','3.3'),),
				   (('a', 'b', 'c'),('c','d'),( 1.1,  2.2,  3.4),),
				),
				(  lcompare.error, # exponent diff
				   (('a', 'b', 'c'),('c','d'),('1.1','2.2','3.0000e-02'),),
				   (('a', 'b', 'c'),('c','d'),( 1.1,  2.2,  0.003),),
				),
				(  lcompare.error, # fuzzy compare
				   (('a', 'b', 'c'),('c','d'),('1.1','2.2','3.00000003'),),
				   (('a', 'b', 'c'),('c','d'),( 1.1,  2.2,  3.0000003),),
				),
				(  None, # fuzzy compare 
				   (('a', 'b', 'c'),('c','d'),('1.1','2.2','3.000000003'),),
				   (('a', 'b', 'c'),('c','d'),( 1.1,  2.2,  3.00000003),),
				),
				):
			if xc:
				self.assertRaises(xc, lcompare.llcompare, data, exp)
			else:
				try: lcompare.llcompare(data, exp)
				except lcompare.error as e:
					self.fail(('call_one_text ') +str(e))